How To Connect Avalara’s AvaTax with Stripe Subscriptions by@jonathanges

How To Connect Avalara’s AvaTax with Stripe Subscriptions

Jonathan Gescheit HackerNoon profile picture

Jonathan Gescheit

R&D Team Lead at Wibbitz, Frontend Developer. Loves music and sports.

It’s supposed to be easy. Eventually, it is.

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.

First Step: Ask Stripe to Allow Your Account to Use The pay_immediately flag

Contact Stripe’s support and ask them to enable the usage of the

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.

Second Step: Update Address Details in The Customer’s Metadata

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.


 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(
  { metadata: {
	  'Address_PostalCode': '10001', // Valid Postal Code
	  'Address_Country': 'US' // ISO-3166-1 alpha-2 Country Code

Third Step: Add pay_immediately = false to Your Subscription Creation Request

When you create the subscription, add the attribute 

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

Fourth Step: Wait for Webhook Events

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.


Signup or Login to Join the Discussion


Related Stories