Avalara AvaTax with Stripe.js
The new AvaTax.js library makes it easy to calculate taxes with browser-based shopping carts and other web commerce environments – providing real-time tax calculation results during the checkout process. Those accurate, on-demand tax calculations can be consumed at time of checkout, allowing you to display the results to your shoppers or use them in your payment processing. This diagram is a typical process flow for an E-commerce scenario.
Let’s take a look at an easy example where AvaTax.js can be used in conjunction with Stripe.js to calculate tax and create a payment authorization token.
You’ll need to include the core files (AvaTax.php and AvaTax.js) available here in your site directory.
- Enter your AvaTax account credentials in the AvaTax.php proxy file. If you don't have an AvaTax account yet, you can sign up for a free trial account.
- Include the AvaTax.js reference in your page.
- Call the methods provided to calculate tax. The request parameters in your actual call should be values drawn from the cart on which you want to determine tax.
- Consume the calculation resultsIf the order has not yet been placed, and you’re just estimating the tax amount prior to confirmation, you might have something like this: Otherwise, if you're recording an order to AvaTax that has been confirmed, and you'd like to charge the card as well, you might do something more like this: