Performing Tax Calculation With TaxJar
Calculating tax through the Web Checkout SDK can be done by following the steps below.
If a TaxJar connection hasn't already been set up, be sure to add this connection within the dashboard.
Upon connecting, add your sandbox API token while testing the connection.
You should now be all set to calculate tax from the checkout.
<aside> 💡 Tax calculation is available with the Universal Checkout starting version 1.11.0-beta.0
</aside>
Tax calculation will be called automatically when the three following options are provided: orderDetails
, businessDetails
and customerDetails
.
You can set these at the initialisation of the checkout, or using the setters: setOrderDetails
, setBusinessDetails
and setCustomerDetails
. If you update one of the options using the setters, tax will be automatically (re)calculated.
Use onAmountChange
to receive the calculated tax, and update your UI and internal logic accordingly.
When tax is successfully calculated, the internal orderDetails
is automatically updated with the new total amount. You don't have to call setOrderDetails
after onAmountChange
is called.
You can define orderDetails
, businessDetails
and customerDetails
when calling primer.checkout()
.
orderDetails
orderDetails
will take the place of purchaseInfo
(now deprecated). It's advised to use orderDetails
for all transactions, even if tax calculation is not needed.