/stripe-guides

How to use Stripe Tax for automatic sales tax?

Learn how to set up and use Stripe Tax for automatic sales tax calculation, configure tax settings, handle exemptions, and manage tax reports for compliance.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free consultation

How to use Stripe Tax for automatic sales tax?

How to Use Stripe Tax for Automatic Sales Tax

 

Step 1: Set Up a Stripe Account

 

First, you need to have a Stripe account. If you don't have one yet, visit the Stripe website and sign up. Once you've created your account, navigate to the Dashboard.

 

Step 2: Enable Stripe Tax

 

To activate Stripe Tax:

  • Go to the Stripe Dashboard
  • Navigate to "Settings"
  • Select "Tax" from the menu
  • Click "Set up Stripe Tax"
  • Follow the prompts to complete the registration process

You'll need to provide information about your business, including your business address and tax registration numbers for the regions where you operate.

 

Step 3: Configure Tax Settings

 

After enabling Stripe Tax, configure your tax settings:

  • Choose the countries where you want to collect tax
  • Set up tax registration numbers for each jurisdiction
  • Configure product tax codes for your offerings
  • Set up tax exemption settings if applicable

These settings determine where and how Stripe will calculate taxes for your transactions.

 

Step 4: Implement Stripe Tax in Your Checkout Flow

 

Now you need to implement Stripe Tax in your checkout flow. Here's how to do it with Stripe Checkout:


const stripe = require('stripe')('sk_test_your_secret_key');

// Create a checkout session with automatic tax calculation
const session = await stripe.checkout.sessions.create({
  line\_items: [
    {
      price: 'price\_1234',
      quantity: 1,
    },
  ],
  mode: 'payment',
  automatic\_tax: {
    enabled: true,
  },
  customer\_email: '[email protected]',
  billing_address_collection: 'required',
  shipping_address_collection: {
    allowed\_countries: ['US', 'CA'],
  },
  success\_url: 'https://example.com/success',
  cancel\_url: 'https://example.com/cancel',
});

The key parameter here is automatic_tax: { enabled: true }, which enables Stripe Tax for this session. Note that you need to collect either billing or shipping addresses to calculate taxes properly.

 

Step 5: Implement Stripe Tax with the Payment Element

 

If you're using Stripe's Payment Element for a custom checkout flow:


// Server-side code
const stripe = require('stripe')('sk_test_your_secret_key');

const paymentIntent = await stripe.paymentIntents.create({
  amount: 1000,
  currency: 'usd',
  automatic\_tax: {
    enabled: true,
  },
  customer: 'cus\_123456',
  customer\_details: {
    address: {
      line1: '123 Main St',
      city: 'San Francisco',
      state: 'CA',
      postal\_code: '94111',
      country: 'US',
    },
    email: '[email protected]',
  },
  metadata: {
    tax\_exempt: 'none', // or 'exempt' if customer is tax exempt
  },
});

// Client-side code
const {clientSecret} = await fetch('/create-payment-intent', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    items: [{id: 'product-id'}],
    customerDetails: {
      address: {
        line1: '123 Main St',
        city: 'San Francisco',
        state: 'CA',
        postal\_code: '94111',
        country: 'US',
      },
    },
  }),
}).then(r => r.json());

const elements = stripe.elements({
  clientSecret,
});

const paymentElement = elements.create('payment');
paymentElement.mount('#payment-element');

 

Step 6: Handle Tax Calculation for Subscriptions

 

For subscription products, enable automatic tax calculation like this:


// Create a subscription with automatic tax
const subscription = await stripe.subscriptions.create({
  customer: 'cus\_123456',
  items: [
    {
      price: 'price\_1234',
    },
  ],
  automatic\_tax: {
    enabled: true,
  },
  payment_behavior: 'default_incomplete',
  payment\_settings: {
    save_default_payment_method: 'on_subscription',
  },
  expand: ['latest_invoice.payment_intent'],
});

 

Step 7: Define Product Tax Codes

 

Assign appropriate tax codes to your products to ensure correct tax rates:


// Create a product with a specific tax code
const product = await stripe.products.create({
  name: 'T-shirt',
  description: 'Comfortable cotton t-shirt',
  tax_code: 'txcd_10000000', // General physical goods
});

// Create a price for the product
const price = await stripe.prices.create({
  unit\_amount: 2000,
  currency: 'usd',
  product: product.id,
});

Common tax codes include:

  • `txcd_10000000` - General physical goods
  • `txcd_20000000` - General services
  • `txcd_30000000` - Digital goods
  • `txcd_35000000` - SaaS and subscription services

 

Step 8: Handle Tax Exemptions

 

To handle tax-exempt customers:


// Update a customer to mark them as tax exempt
await stripe.customers.update(
  'cus\_123456',
  {
    tax\_exempt: 'exempt', // Options: 'none', 'exempt', 'reverse'
    tax_id_data: [
      {
        type: 'eu\_vat',
        value: 'DE123456789',
      },
    ],
  }
);

 

Step 9: Test Tax Calculations

 

Before going live, test your tax calculations:

  • Use Stripe's test mode
  • Test transactions with different addresses to verify tax calculations
  • Verify that the correct tax rates are applied based on customer location
  • Check that tax exemptions work correctly

You can use Stripe's test clock feature to simulate subscriptions and recurring billing:


// Create a test clock
const clock = await stripe.testHelpers.testClocks.create({
  frozen\_time: Math.floor(Date.now() / 1000),
});

// Create a customer on the test clock
const customer = await stripe.customers.create({
  test\_clock: clock.id,
  email: '[email protected]',
  address: {
    line1: '123 Main St',
    city: 'San Francisco',
    state: 'CA',
    postal\_code: '94111',
    country: 'US',
  },
});

// Create a subscription with automatic tax on the test clock
const subscription = await stripe.subscriptions.create({
  customer: customer.id,
  items: [{ price: 'price\_1234' }],
  automatic\_tax: { enabled: true },
});

// Advance the test clock to simulate time passing
await stripe.testHelpers.testClocks.advance(
  clock.id,
  { frozen\_time: Math.floor(Date.now() / 1000) + (30 _ 24 _ 60 \* 60) }
);

 

Step 10: Monitor and Manage Tax Reports

 

After implementing Stripe Tax, regularly monitor your tax reports:

  • Access tax reports from the Stripe Dashboard under "Reports" > "Tax"
  • Review collected taxes by jurisdiction
  • Export tax reports for filing purposes
  • Set up automated report delivery to your email

You can also retrieve tax reports programmatically:


const reports = await stripe.reporting.reportRuns.create({
  report\_type: 'tax.summary',
  parameters: {
    interval\_start: Math.floor(new Date('2023-01-01').getTime() / 1000),
    interval\_end: Math.floor(new Date('2023-01-31').getTime() / 1000),
  },
});

 

Step 11: Stay Compliant with Tax Regulations

 

Although Stripe Tax automates calculations, you're still responsible for tax compliance:

  • Register for tax collection in required jurisdictions
  • File tax returns on time
  • Keep records of all transactions and tax collected
  • Stay informed about changing tax regulations

Stripe Tax helps with calculations but does not file taxes for you. Consider consulting with a tax professional to ensure full compliance with all applicable tax laws.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022