title: Rounding tax amount for Paypal
body: <p>In a US e-commerce webshop I am looking for input on how to solve an issue with <a href="https://developer.paypal.com/docs/api/orders/v2/" rel="nofollow noreferrer">Paypal Orders API</a></p>
  <p><strong>Example</strong></p>
  <p>The price per lamp excluding tax is <strong>$1547</strong></p>
  <p>A customer adds 2 of these lamps to his shopping basket</p>
  <p>A third party service will calculate the tax amount for the two lamps to be <strong>$274.59</strong></p>
  <p>The total price for 2 lamps including tax is
  2*1547 + 274.59 = <strong>$3368.59</strong></p>
  <p>When paying using Paypal we need to send the different amounts to Paypal Orders API.</p>
  <p>This is where the issue occur with the tax amount.
  Paypal want's it &quot;pr unit&quot;, meaning 274.59 / 2 = <strong>$137.295</strong></p>
  <p><strong>But Paypal will only accept 2 digits :-(</strong></p>
  <p>Below is how the order should be sent if 3 digits was allowed:</p>
  <pre><code>&quot;purchase_units&quot;: [{
          &quot;amount&quot;: {
              &quot;currency_code&quot;: &quot;USD&quot;,
              &quot;value&quot;: &quot;3368.59&quot;,
              &quot;breakdown&quot;: {
                  &quot;item_total&quot;: {
                      &quot;currency_code&quot;: &quot;USD&quot;,
                      &quot;value&quot;: &quot;3094&quot;
                  },
                  &quot;tax_total&quot;: {
                      &quot;currency_code&quot;: &quot;USD&quot;,
                      &quot;value&quot;: &quot;274.59&quot;
                  }
              }
          },
          &quot;items&quot;: [{
                  &quot;name&quot;: &quot;Oval lamp&quot;,
                  &quot;tax&quot;: {
                      &quot;currency_code&quot;: &quot;USD&quot;,
                      &quot;value&quot;: &quot;137.295&quot;
                  },
                  &quot;unit_amount&quot;: {
                      &quot;currency_code&quot;: &quot;USD&quot;,
                      &quot;value&quot;: &quot;1547&quot;
                  },
                  &quot;quantity&quot;: &quot;2&quot;
              }
          ]]
  </code></pre>
  <p>This will give me an error:</p>
  <pre><code>&quot;details&quot;: [
      {
          &quot;field&quot;: &quot;/purchase_units/0item/0/tax/value&quot;,
          &quot;value&quot;: &quot;137.295&quot;,
          &quot;issue&quot;: &quot;DECIMAL_PRECISION&quot;,
          &quot;description&quot;: &quot;If the currency supports decimals, only two decimal place precision is supported.&quot;
      }
  ]
  </code></pre>
  <p>If I then round the tax from $137.295 to $137.30 I get this error:</p>
  <pre><code> &quot;details&quot;: [
      {
          &quot;field&quot;: &quot;/purchase_units/0/amount/breakdown/tax_total/value&quot;,
          &quot;value&quot;: &quot;274.59&quot;,
          &quot;issue&quot;: &quot;TAX_TOTAL_MISMATCH&quot;,
          &quot;description&quot;: &quot;Should equal sum of (tax * quantity) across all items for a given purchase_unit&quot;
      }
  ]
  </code></pre>
  <p>If I update the total tax amount from 274.59 to 274.6 I get this error:</p>
  <pre><code>&quot;details&quot;: [
      {
          &quot;field&quot;: &quot;/purchase_units/0/amount/value&quot;,
          &quot;value&quot;: &quot;3368.59&quot;,
          &quot;issue&quot;: &quot;AMOUNT_MISMATCH&quot;,
          &quot;description&quot;: &quot;Should equal item_total + tax_total + shipping + handling + insurance - shipping_discount - discount.&quot;
      }
  ]
  </code></pre>
  <p>My only option now is to change the total amount from $3368.59 to $3368.6, but that is not correct!</p>
  <p>Any input is appreciated</p>