paint-brush
How To Connect Avalara’s AvaTax with Stripe Subscriptions by@jonathanges
1,233 reads
1,233 reads

How To Connect Avalara’s AvaTax with Stripe Subscriptions

by Jonathan GescheitOctober 17th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A simple plug & play solution to using Avalara’s AvaTax for charging sales tax isn’t very well documented. This post is all about laying out the required steps to making it work quickly and easily. For AvaT to integrate with Stripe, you have to give Ava tax 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 to Your Subscription Creation Request.

Company Mentioned

Mention Thumbnail
featured image - How To Connect Avalara’s AvaTax with Stripe Subscriptions
Jonathan Gescheit HackerNoon profile picture

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

If you use  to charge users and plan on using  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

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 , 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.

Only 

Address_PostalCode
 and 
Address_Country
 are mandatory but you can add  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
	}		
  }
);

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

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
});

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. 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.
바카라사이트 바카라사이트 온라인바카라