If you use Stripe to charge users and plan on using Avalara’s AvaTax for charging sales tax, you’re probably looking for a simple plug & play solution. It very much is this type of solution, but it isn’t very well documented.
This post is all about laying out the required steps to making it work quickly and easily.
Examples are written in node.js but can easily be converted to any language Stripe’s API supports.
Contact Stripe’s support and ask them to enable the usage of the
pay_immediately
flag for you for the purpose of integrating AvaTax.For AvaTax to integrate with Stripe, you have to give AvaTax to a chance to catch new invoices and add the sales tax to the invoice. You do this by sending the attribute
pay_immediately = false
upon subscription creation. This flag is not well documented anywhere and is disabled by default. Avalara do mention it in their documentation, but it’s easy to miss.
Add address details that AvaTax will use to calculate the tax for future invoices. This can happen at any time prior to creating the subscription.
Only
Address_PostalCode
and Address_Country
are mandatory but you can add more details to make the tax calculation more accurate.const stripe = require('stripe')(STRIPE_KEY);
const customer = await stripe.customers.update(
CUSTOMER_ID,
{ metadata: {
'Address_PostalCode': '10001', // Valid Postal Code
'Address_Country': 'US' // ISO-3166-1 alpha-2 Country Code
}
}
);
When you create the subscription, add the attribute
pay_immediately
with the value false.const stripe = require('stripe')(STRIPE_KEY);
const subscription = await stripe.subscriptions.create({
customer: CUSTOMER_ID,
items: [
{price: PRICE_ID},
],
pay_immediately: false
});
Your invoice will not be charged immediately (as you requested), and AvaTax will pick it up. This could take a couple of seconds.
Avalara’s webhooks will allow you to know what happened with your invoice under their care.
That’s it. It’s fairly easy and straightforward, but it’s rather hard to find good documentation for it.