Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Revenue
Platforms and marketplaces
Money management
Developer resources
Overview
About Stripe payments
Upgrade your integration
Payments analytics
Online payments
OverviewFind your use caseManaged Payments
Use Payment Links
Build a checkout page
    Overview
    Quickstarts
    Customize look and feel
    Collect additional information
    Collect taxes
      Use manual tax rates
      Collect tax IDs
    Dynamically update checkout
    Manage your product catalog
    Subscriptions
    Manage payment methods
    Let customers pay in their local currency
    Add discounts, upsells, and optional items
    Set up future payments
    Save payment details during payment
    Manually approve payments on your server
    After the payment
    Elements with Checkout Sessions API beta changelog
    Migrate from legacy Checkout
    Migrate Checkout to use Prices
Build an advanced integration
Build an in-app integration
Payment methods
Add payment methods
Manage payment methods
Faster checkout with Link
Payment interfaces
Payment Links
Checkout
Web Elements
In-app Payments
Payment scenarios
Handle multiple currencies
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Beyond payments
Incorporate your company
Crypto
Financial Connections
Climate
Understand fraud
Radar fraud protection
Manage disputes
Verify identities
HomePaymentsBuild a checkout page

Collect taxes

Learn how to collect taxes with Stripe Tax.

Stripe Tax is a paid product that automatically calculates the tax on your transactions without the need to define the rates and rules. Fees only apply after you’ve added at least one location where you’re registered to calculate and remit tax.

Configure your Checkout Session to collect tax

To start collecting tax:

  1. Pass automatic_tax[enabled]=true.
  2. Specify a tax_code for each line item or set a preset tax code in the Dashboard.
  3. Specify a tax_behavior for each line item or set a default tax behavior in the Dashboard.
Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/checkout/sessions \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d "line_items[0][price_data][currency]"=usd \ -d "line_items[0][price_data][product_data][name]"=T-shirt \ -d "line_items[0][price_data][product_data][tax_code]"=txcd_99999999 \ -d "line_items[0][price_data][unit_amount]"=2000 \ -d "line_items[0][price_data][tax_behavior]"=exclusive \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d ui_mode=custom \ -d return_url={{RETURN_URL}} \ -d "automatic_tax[enabled]"=true

Tax codes

Tax codes associate products with tax rates. Choose the tax code that best fits your product from the list of available tax codes. If a product doesn’t fit any of the specific codes, use one of the codes with “General” in its name.

Tax behavior

The tax behavior determines how tax is presented to the buyer. There are two options for tax behavior:

  • Exclusive: The product price doesn’t include tax. Tax is added as a separate amount.
  • Inclusive: The product price includes any tax amount.

Learn more about tax behavior.

OptionalCollect tax through the Payment Element

You can collect tax address details directly in the Payment Element. Collecting tax address details through the Payment Element is suitable for the following use cases:

  • You don’t require full address collection.
  • You only require address collection for tax collection purposes.

This feature integrates input fields for the country and postal code into each payment method form within the Payment Element. It only collects the minimum required address fields for tax calculation based on Stripe Tax requirements.

There are certain regional considerations where the tax rate using the minimum required address fields might differ from the tax rate at your customer’s full address. We recommend using the Address Element to collect your customer’s full address for tax calculation if these regional considerations apply to your business.

When creating the Checkout Session, use the following parameters with the Checkout Sessions API:

  1. Set billing_address_collection=auto to automatically collect the billing address.
  2. Don’t include the shipping_address_collection parameter. If you provide this parameter, tax address details are collected based on the shipping address instead of the billing address.
Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/checkout/sessions \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d "line_items[0][price_data][currency]"=usd \ -d "line_items[0][price_data][product_data][name]"=T-shirt \ -d "line_items[0][price_data][product_data][tax_code]"=txcd_99999999 \ -d "line_items[0][price_data][unit_amount]"=2000 \ -d "line_items[0][price_data][tax_behavior]"=exclusive \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d ui_mode=custom \ -d return_url={{RETURN_URL}} \ -d "automatic_tax[enabled]"=true \ -d billing_address_collection=auto

When collecting tax address details through the Payment Element, tax calculation behaves as follows for the following scenarios:

  • If fields.billingDetails.address=auto | if_required is passed, the Payment Element collects the minimum required address fields for tax calculation.
  • If fields.billingDetails.address=never is passed, you must collect tax address details through an alternative method because the billing input fields won’t show in the Payment Element.
  • If fields.billingDetails.address.country=never is passed, the customer’s detected country is used for tax calculation.
  • If fields.billingDetails.address.postalCode=never is passed, an error is thrown because the postal code can be required for certain countries.
  • If checkout.updateBillingAddress is called, an error is thrown because the billing address could potentially conflict.

OptionalCheck the response

To see the results of the latest tax calculation, the total_details.amount_tax property in the Checkout Session resource shows the calculated tax amount. Additionally, you can use the Dashboard to view the tax outcome for each payment.

Render tax amount

Use useCheckout to render the tax amount in your checkout form. Understand the difference between inclusive and exclusive tax.

import React from 'react'; import {useCheckout} from '@stripe/react-stripe-js'; const CheckoutForm = () => { const checkoutState = useCheckout(); if (checkoutState.type === 'loading') { return ( <div>Loading...</div> ); } else if (checkoutState.type === 'error') { return ( <div>Error: {checkoutState.error.message}</div> ); } const {checkout} = checkoutState; return ( <div> <h2>Checkout Summary</h2> <pre> {JSON.stringify(checkout.lineItems, null, 2)} </pre> <h3>Totals</h3> <pre> Subtotal: {checkout.total.subtotal.amount} {/* Make sure you are using the appropriate tax amount type (taxInclusive and/or taxExclusive) for your integration */} Tax: {checkout.total.taxExclusive.amount} Total: {checkout.total.total.amount} </pre> </div> ) };
Was this page helpful?
YesNo
  • Need help? Contact Support.
  • Join our early access program.
  • Check out our changelog.
  • Questions? Contact Sales.
  • LLM? Read llms.txt.
  • Powered by Markdoc