Calculating Sales Taxes with Stripe and TaxJar

14 min read

Here at Flatirons Development, we’ve helped many organizations develop or improve their SaaS applications, marketplaces, or e-commerce websites. When it comes to these products, there is only one certainty, much like in everyone’s life: taxes. Another certainty is that with taxes comes complexity. Helping our customers navigate and mitigate tax complexities is a small part of what we do, but a vital one. For that reason, we wanted to help you with the integration of various sales tax collection options we’ve used in our various projects, as well as to help you decide between them for your particular use case. 

Complex and Tedious

Collecting taxes is a very tedious task no matter where you are, especially in the United States. A great number of details must be considered to determine the correct tax amount to charge, and it can be an overwhelming and frustrating process to figure it out on your own. Worse still, these details change constantly, and it is imperative that these changes are tracked and considered at any given time.

One key factor is jurisdiction. A jurisdiction is the taxation authority that imposes the tax. We can consider tax jurisdictions municipalities, states, counties or countries, each with its distinct regulations for taxation and each one identified by a tax jurisdiction code. According to software companies Avalara and TaxJar, there are more than 13,000 tax jurisdictions in the United States alone. 

Jurisdictions are arranged in a hierarchy. For example, a city belongs to a state and a state to a country. The amount of the total tax rate to be collected is the sum of the combined tax rates from each jurisdiction in the hierarchy. For example, if your city has a sales tax rate of 1%, and the state it resides in has a tax rate of 2%, then the total tax rate would be 3%. 

For a real-world example, consider New York: For most personal property, (furniture, electronics, alcohol, etc.) New York City applies a sales tax of 4.5%, and NY State Sales and Use tax is 4%. There is also a Metropolitan Commuter Transportation District surcharge of 0.375%. This combines with a total Sales and Use Tax of 8.875%.


This jurisdictional complexity could be just the tip of the iceberg because not all states in the US calculate taxes in the same way. In the US, there are two different types of states (in terms of taxation): 

  1. Origin-sourced sales tax states: If the seller is based in an origin-based state, they charge the amount of state and local sales tax effective at their business’ location to everyone to who you ship taxable items in that state. In other words, if you are based in Phoenix, Arizona, and sell to someone in Tucson, AZ, the sales tax will be calculated based on the applicable taxes in Phoenix, Arizona. However, there is some variance even within origin-based states. For instance, if you are based in California, any city, county, or state taxes will be based on the origin of the seller, while district sales tax is based on the customer’s location. 
  2. Destination-sourced sales tax states: If the seller is based in a destination-based state, they must calculate the sales tax rate effective where their buyer is located. This means the combination of local sales taxes can be bigger which makes this category a bit trickier.

When you add in interstate sales, there can be another layer of complexity, because sourcing rules work differently as a remote seller. There, it depends on if you are selling to another state where you have nexus. Essentially, nexus means your business footprint in the destination state meets a minimum threshold to be charged state sales tax. The threshold varies, it might be based on the number of transactions (i.e. 200 transactions), or a certain amount of sales (i.e. $100,000).

If you do not meet nexus threshold requirements, you do not need to collect sales tax for sales to those locations.

Product Categories

If you delight in complexity, and jurisdictional concerns are not enough, you’ll be happy to know that there’s still more to consider, because the product category is also important. Selling flowers is not the same as selling shoes. Different markets, and different processes for sourcing, distribution, and selling exist for nearly every product category. Depending on the category, the sales tax rate will also vary. For example, for beauty, barbering, hair restoration, manicures, pedicures, electrolysis, massage, tanning, tattooing, and other similar services, the NY City Sales Tax rate is 4.5% on the service. But for parking, garaging, or storing motor vehicles, the NY City charges a 10.375% tax and an additional 8% surtax in Manhattan

Now that you understand the layers of complexity governing sales tax collection and calculation, you can understand why additional tools to handle sales tax collection might be necessary. In the following sections, we’ll be looking at some of the options available to make this task more manageable, as well as how to set them up.


Stripe, Inc. is an Irish-American financial service and software-as-a-service company with dual headquarters in San Francisco, USA, and Dublin, Ireland.

Stripe has a tool called Stripe Tax that automates the process of calculating the sales tax, VAT, and GST on Stripe transactions. In order to use it, users need to configure their tax settings within the Dashboard and, depending on their integration (no-code integration such as a payment link or low-code integration such as a Checkout session), add one line of code.

Set up:

  1. Confirm the origin address: Where the business is located or if the user sells physical goods, the address where they’re shipping goods from.
  2. Select a default tax category: Stripe uses this to apply the correct tax rate in the case where a product does not explicitly have a tax code. You’ll notice this will be required in every platform and each one has its own format.
  3. Add tax registrations: You have to register with the local tax authority before you can add the tax to your transactions.
  4. Add Stripe Tax to your integration to start collecting taxes: Stripe provides different integrations to facilitate making transactions (e.g. Invoicing, Billing, Checkout). In the picture below, we can see an example of a Checkout session which is a low-code integration. In this case, users would need to add automatic_tax[enabled]=true and the tax rates will be calculated automatically.

Note: The products need to be previously created in the dashboard and one of the attributes for these records is the tax code. 

Here you can also see a complete overview of the benefits of Stripe over PayPal.

Preview of Stripe integration enabling sales tax calculation

For most scenarios, Stripe works very well. However, the requirements to register every product in the Stripe dashboard impose challenges in certain situations. Stripe is not currently explicitly HIPAA compliant, and therefore, should not be used for situations where protected health information might be shared with your payment processor (such as paying for a medical test).


TaxJar is a cloud-based platform that automates sales tax compliance. TaxJar was acquired by Stripe in 2021. Unlike Stripe, TaxJar does not require you to explicitly save any personal data. This makes it a good choice for situations where an extra layer of data protection or HIPAA compliance is necessary.

In order to get the tax rate for one specific transaction we can use the API for developers and make the following request using the auth token we receive after signing up (the following code uses the taxjar-ruby gem).

require "taxjar"
client = "9e0cd62a22f451701f29c3bde214")

order = client.tax_for_order({
  :from_country => 'US',
  :from_zip => '92093',
  :from_state => 'CA',
  :from_city => 'La Jolla',
  :from_street => '9500 Gilman Drive',
  :to_country => 'US',
  :to_zip => '90002',
  :to_state => 'CA',
  :to_city => 'Los Angeles',
  :to_street => '1335 E 103rd St',
  :amount => 15,
  :shipping => 1.5,
  :nexus_addresses => [
      :id => 'Main Location',
      :country => 'US',
      :zip => '92093',
      :state => 'CA',
      :city => 'La Jolla',
      :street => '9500 Gilman Drive',
  :line_items => [
      :id => '1',
      :quantity => 1,
      :product_tax_code => '20010',
      :unit_price => 15,
      :discount => 0


To better understand the code above, let’s look at three important classifications required to calculate the sales tax rates using Tajxar.

  1. Seller information: All the attributes with the prefix from_ (e.g. from_zip, from_state, etc.) refer to the seller’s address or where the order is shipped from.​​ Another set of data that can be used for calculation is the nexus addresses, which refers to states in which the seller meets a minimum threshold of business activity (e.g. having an office, owning a warehouse, storing inventory, enough sales revenue, transactions, etc.) (Source) Either nexus_addresses parameter or from_ parameters are required to perform tax calculations. 
  2. Buyer Information: All the attributes with the prefix to_ (e.g. to_zip, to_state, etc.) refer to the buyer’s address or where the order is shipped to.
  3. Line items or products: This is the data related to the products the user wants to buy such as the quantity of the products, the price of the product, or the category (List here)

Note: Either amount or line_items parameters are required to perform tax calculations.

The response would look something like this:

  16.5,  :shipping => 1.5,  :taxable_amount => 15.0,  :amount_to_collect => 1.35,  :rate => 0.09,  :has_nexus => true,  :freight_taxable => false,  :tax_source => "destination",  :jurisdictions => # 'US',    :state => 'CA',    :county => 'LOS ANGELES',    :city => 'LOS ANGELES'  }>,  :breakdown => # 15.0,    :tax_collectable => 1.35,    :combined_tax_rate => 0.09,    :state_taxable_amount => 15.0,    :state_tax_rate => 0.0625,    :state_tax_collectable => 0.94,    :county_taxable_amount => 15.0,    :county_tax_rate => 0.0025,    :county_tax_collectable => 0.04,    :city_taxable_amount => 0.0,    :city_tax_rate => 0.0,    :city_tax_collectable => 0.0,    :special_district_taxable_amount => 15.0,    :special_tax_rate => 0.025,    :special_district_tax_collectable => 0.38,    :line_items => [      # "1",        :taxable_amount => 15.0,        :tax_collectable => 1.35,        :combined_tax_rate => 0.09,        :state_taxable_amount => 15.0,        :state_sales_tax_rate => 0.065,        :state_amount => 0.94,        :county_taxable_amount => 15.0,        :county_tax_rate => 0.0025,        :county_amount => 0.04,        :city_taxable_amount => 0.0,        :city_tax_rate => 0.0,        :city_amount => 0.0,        :special_district_taxable_amount => 15.0,        :special_tax_rate => 0.025,        :special_district_amount => 0.38      }>    ]  }>}>

In this case, amount_to_collect is our desired value.

Note that no personal data is required from the purchaser or seller. For this reason, among others, it can be considered HIPAA compliant. In fact, they completed a voluntary independent assessment of HIPAA compliance in 2021.


Avalara offers a cloud-based sales tax calculation tool called Avatax. This tool requires data from the transaction such as the origin address (representing the address of the vendor), the destination address (representing the location the product is delivered/purchased), and basic information about the products. Yep, similar to TaxJar.

At this point, we can see a pattern emerging with regard to the basic requirements of a sales tax calculation tool. The system must track the origin (where the order is shipped from), the destination (where the order is shipped to), as well as what is being sold (category of the product). The structure of the payload for Avatax is also similar to the one used with TaxJar.

{  "type": "SalesOrder",  "code": "Chapter-10-Test-1",  "companyCode": "DEVGUIDE",  "date": "2017-06-15",  "customerCode": "ACME",  "commit": "false",  "addresses": {    "shipFrom": { 	"line1": "18300 Von Karman Ave", 	"city": "Irvine", 	"region": "CA", 	"country": "US", 	"postalCode": "92612"    },    "shipTo": { 	"line1": "100 Ravine", 	"city": "Bainbridge Island", 	"region": "WA", 	"country": "US", 	"postalCode": "98110"    }  },  "lines": [    { 	"number": "1", 	"quantity": 10, 	"amount": 100, 	"taxCode": "P0000000", 	"itemCode": "Widget", 	"description": "Test Widget"    }  ]}

AvaTax is a global application and can be used all across America, the UK, and Europe. It goes beyond sales tax to calculate customs and duties, VAT, GST, excise tax, and Beverage Alcohol Tax, among others. Because it is a cloud-based system, you can access it from anywhere and trust that you will get the right information. Avatax may be the best option if you are expanding sales to ship out of the country (or if you are looking to expand operations to the US from elsewhere).

Choosing your Sales Tax Solution

In the end, this blog is not about which tool is unilaterally better. Each has strengths and weaknesses, as pointed out above. They also share key similarities and some features. However, what we hope to make clear is that going it alone in terms of sales tax calculation is not advisable nor scalable and that not many organizations have the time and capital to develop their own solution. Off-the-shelf tools/platforms may not be adequate for your unique needs either. For example, Stripe isn’t HIPAA compliant so you cannot use it if you need to store protected healthcare information in your payment processor.

For custom-built software, adding any of the above toolsets is a better solution than manually managing taxes. At the end of the day, each platform has strengths and weaknesses, as well as use cases in which key features will recommend them (such as HIPAA compliance, or covering more locations), it is up to you to determine which fits your needs best. Flatirons Development strongly recommends that you don’t go it alone. Contact us if you need any advice on integrating a sales tax calculation tool with your solution.

Note: This is not tax advice. Please refer to your own professionals when dealing with taxes.

Fintech Software Development Services

Flatirons delivers cutting-edge fintech solutions, driving innovation in financial technology.

Learn more
More ideas.

What is User Acceptance Testing? A Guide in 2024


Feb 16, 2024

Top SaaS CSV Importer Solutions


Feb 13, 2024

AI in SaaS Businesses: Revolutionizing Tech Solutions


Jan 30, 2024

AI in Transportation Industries: Use Cases and Benefits


Jan 28, 2024

What is Node.js? An Overview in 2024


Jan 23, 2024

In-House vs. Outsourced Software Development: Which Is Right?


Jan 21, 2024