Getting started with Stripe Tax
Published: 2021-12-13 11:43:05

![Stripe Tax](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9te0fnqemunnzhi4pipp.png)

Calculating and collecting taxes is a complex task, and that complexity only increases as you grow your business and start selling to different markets that have complicated regulatory tax rules. As [Kelly Moriarty recently explained](https://stripe.com/blog/building-stripe-tax), in the UK, a gingerbread man that’s wearing chocolate pants is taxed differently to one that isn’t.

That’s why we built and launched Stripe Tax. Stripe has abstracted away all of that complexity in to 3 simple configuration steps. In this article we’ll walk through those steps and show you how you can enable automatic tax calculation and collection for the countries where you have tax obligations.

## Dashboard configuration

In order to get started with Stripe Tax, there are 3 simple dashboard configurations that you need to complete in the [Stripe Tax settings section](https://dashboard.stripe.com/test/settings/tax). It’s important to note that you won’t be charged for using Stripe Tax until you enable it for your transactions by setting `automatic_tax[enabled] = true` in Invoicing, Billing or Checkout or enabling tax calculation when creating a Payment Link.

### 1. Add your origin address

This is the address where your business is located or where your goods ship from.

![Origin address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gmje1pzy2utxsrbyz0u5.gif)

### 2. Add a default product tax code

This is the tax code of the kind of goods and services that you provide. There are a wide range of codes from subscriptions to hats. If you aren’t sure about which code to choose, consult with your tax advisor. Tax codes can also be applied on a per-product basis, but if a tax code is not set on a product, the default will be applied. In this case, I’m selling “Downloadable games”.

![Default tax code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sq75kdtb6mh83qflz6k6.gif)

### 3. Create tax registrations

A registration is declaration for where you are registered to collect tax. Stripe Tax automatically surfaces potential registrations based on the transaction volume that you have processed in certain countries where you may have tax obligations. If you’re unsure as to where you have tax obligations, you can again consult with your tax advisor. Here, I’ve added VAT OSS in Ireland, which allows tax calculation and collection in all European countries.

![Registrations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/42g9fp5m8ovmiarahyk4.gif)

Once you have completed these 3 steps, the final action is to enable tax calculation and collection when creating transactions. You will only then be charged once you have enabled that in Checkout, Invoicing, Billing or Payment Links.

## Enabling tax calculation and collection

In this example, we’ll show how to enable tax calculation for a Checkout Session. In this particular scenario, we specify that the tax amount is *inclusive* when creating an ad-hoc price. You can also specify this when creating prices through the dashboard. That means that if a customer makes a purchase for 10 euros and the tax amount of 1 euro 87 cents is calculated (which we’ll see in the final screen), the amount the user pays is still 10 euros. If the tax behavior is *exclusive*, the final amount would be 11.87 euros. To enable automatic tax calculation and collection we simply specify `automatic_tax[enabled] = true` when creating the Checkout Session.

```ruby
    require 'stripe'
    Stripe.api_key = '{{SECRET_KEY}}'
    
    Stripe::Checkout::Session.create({
      automatic_tax: {
        enabled: true
      },
      success_url: 'https://example.com/success',
      cancel_url: 'https://example.com/cancel',
      line_items: [
        {
          price_data: {
            unit_amount: 1000,
            currency: 'eur',
            product_data: {
              name: 'Foobar'
            },
            tax_behavior: 'inclusive',
          },
          quantity: 1,
        }
      ],
      mode: 'payment',
    });
```

When we redirect the customer to the hosted Checkout page, we can see that the tax amount was automatically calculated to the amount of 1 euro 87 cents.

![Tax calculation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3h0ecoqj64kyxk8g2c26.png)

## Conclusion

So now you are all set to automatically calculate and collect tax on your transactions on Stripe! To learn more, read the docs on [Stripe Tax](https://stripe.com/docs/tax), and watch the accompanying video tutorials.

{% youtube 3psLlebNl5w %}

{% youtube pSPrIxWfFKY %}

### About the author

![Matthew Ling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8rpgkqr91ivs8sxr73g.png) 

Matthew Ling ([@mattling_dev](@mattling_dev)) is a Developer Advocate at Stripe. Matt loves to tinker with new technology, adores Ruby and coffee and also moonlighted as a pro music photographer. His photo site is at [matthewling.com](https://matthewling.com) and developer site is at [mattling.dev](https://mattling.dev).


### Stay connected

In addition, you can stay up to date with Stripe in a few ways:

📣 Follow us on [Twitter](https://twitter.com/StripeDev)
💬 Join the official [Discord server](https://stripe.com/go/developer-chat)
📺 Subscribe to our [Youtube channel](https://www.youtube.com/StripeDevelopers)
📧 Sign up for the [Dev Digest](https://go.stripe.global/dev-digest)