Collect taxes in Checkout
Learn how to collect taxes for one-time payments in Stripe Checkout.
Use Tax Rate objects to collect taxes (sales, VAT, GST, and others) for one-time payments in Stripe Checkout. There are two ways to collect taxes in Checkout:
- Use fixed tax rates when you know the exact tax rate to charge your customer before they start the checkout process (e.g., you only sell to customers in the UK and always charge 20% VAT).
- With the Prices API, you can use dynamic tax rates when you require more information from your customer (e.g., their billing or shipping address) before determining the tax rate to charge. With dynamic tax rates, you create tax rates for different regions (e.g., a 20% VAT tax rate for customers in the UK and a 7.25% sales tax rate for customers in California, US) and Stripe attempts to match your customer’s location to one of those tax rates.
Create tax rates
First, create tax rates for regions you need to collect taxes for. If you’re working with a small number of tax rates, it’s often simpler to use the Dashboard to create and manage them. After creating tax rates, you can pass them as either fixed or dynamic tax rates to the Checkout Session.
Create tax rates with the API
The following example demonstrates how you can create a tax rate with the API.
curl https://api.stripe.com/v1/tax_rates \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d display_name="Sales Tax" \ -d inclusive=false \ -d percentage="7.25" \ -d country=US \ -d state=CA \ -d jurisdiction="US - CA" \ -d description="CA Sales Tax"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' tax_rate = Stripe::TaxRate.create({ display_name: 'Sales Tax', inclusive: false, percentage: 7.25, country: 'US', state: 'CA', jurisdiction: 'US - CA', description: 'CA Sales Tax', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' tax_rate = stripe.TaxRate.create( display_name='Sales Tax', inclusive=False, percentage=7.25, country='US', state='CA', jurisdiction='US - CA', description='CA Sales Tax', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $tax_rate = \Stripe\TaxRate::create([ 'display_name' => 'Sales Tax', 'inclusive' => false, 'percentage' => 7.25, 'country' => 'US', 'state' => 'CA', 'jurisdiction' => 'US - CA', 'description' => 'CA Sales Tax', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; TaxRateCreateParams params = TaxRateCreateParams.builder() .setDisplayName("Sales Tax") .setInclusive(false) .setPercentage(new BigDecimal("7.25")) .setCountry("US") .setState("CA") .setJurisdiction("US - CA") .setDescription("CA Sales Tax") .build(); TaxRate taxRate = TaxRate.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const taxRates = await stripe.taxRates.create({ display_name: 'Sales Tax', inclusive: false, percentage: 7.25, country: 'US', state: 'CA', jurisdiction: 'US - CA', description: 'CA Sales Tax', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.TaxRateParams{ DisplayName: stripe.String("Sales Tax"), Inclusive: stripe.Bool(false), Percentage: stripe.Float64(7.25), Country: stripe.String("US"), State: stripe.String("CA"), Jurisdiction: stripe.String("US - CA"), Description: stripe.String("CA Sales Tax"), } tr, _ := taxrate.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new TaxRateOptions { DisplayName = "Sales Tax", Inclusive = false, Percentage = 7.25m, Country = "US", State = "CA", Jurisdiction = "US - CA", Description = "CA Sales Tax", }; var service = new TaxRateService(); var taxRate = service.Create(options);
Required properties:
- The
display_name
is a short-name that describes the specific type of tax, such asSales
,VAT
, orGST
. - The
inclusive
property determines whether the taxpercentage
is either added to, or included in, the overall amount. - The
percentage
is a number (up to 4 decimal places) that represents the tax percentage to be collected.
Optional properties:
- The optional
country
property is a valid two-letter ISO country code. Some countries (e.g., United States) require an additional two-letterstate
property. Use these properties to apply dynamic tax rates based on your customer’s billing or shipping address in Checkout Sessions. - The optional
jurisdiction
property represents the tax jurisdiction of the tax rate and can be used to differentiate between tax rates of the same percentage. In the Dashboard, jurisdiction appears as the tax rate’s Region label. - You can also store additional details in the
description
. This property is not exposed to your customers.
Fixed tax rates
After creating a tax rate, pass its ID to line_item.tax_rates when you create a Checkout Session.
curl https://api.stripe.com/v1/checkout/sessions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "payment_method_types[]"=card \ -d "line_items[][price]"="{{PRICE_ID}}" \ -d "line_items[][quantity]"=1 \ -d "line_items[][tax_rates][]"="{{TAX_RATE_ID}}" \ -d mode=payment \ -d success_url="https://example.com/success" \ -d cancel_url="https://example.com/cancel"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' session = Stripe::Checkout::Session.create({ payment_method_types: ['card'], line_items: [{ price: '{{PRICE_ID}}', quantity: 1, tax_rates: ['{{TAX_RATE_ID}}'], }], mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' session = stripe.checkout.Session.create( payment_method_types=['card'], line_items=[{ 'price': '{{PRICE_ID}}', 'quantity': 1, 'tax_rates': ['{{TAX_RATE_ID}}'], }], mode='payment', success_url='https://example.com/success', cancel_url='https://example.com/cancel', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $session = \Stripe\Checkout\Session::create([ 'payment_method_types' => ['card'], 'line_items' => [[ 'price' => '{{PRICE_ID}}', 'quantity' => 1, 'tax_rates' => ['{{TAX_RATE_ID}}'], ]], 'mode' => 'payment', 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SessionCreateParams params = SessionCreateParams.builder() .addPaymentMethodType(SessionCreateParams.PaymentMethodType.CARD) .setMode(SessionCreateParams.Mode.PAYMENT) .setSuccessUrl("https://example.com/success") .setCancelUrl("https://example.com/cancel") .addLineItem( SessionCreateParams.LineItem.builder() .setPrice("{{PRICE_ID}}") .setQuantity(1L) .addTaxRate("{{TAX_RATE_ID}}") .build()) .build(); Session session = Session.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const session = await stripe.checkout.sessions.create({ payment_method_types: ['card'], line_items: [{ price: '{{PRICE_ID}}', quantity: 1, tax_rates: ['{{TAX_RATE_ID}}'], }], mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.CheckoutSessionParams{ PaymentMethodTypes: stripe.StringSlice([]string{ "card", }), LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("{{PRICE_ID}}"), Quantity: stripe.Int64(1), TaxRates: stripe.StringSlice([]string{ "{{TAX_RATE_ID}}", }), }, }, Mode: stripe.String("payment"), SuccessURL: stripe.String("https://example.com/success"), CancelURL: stripe.String("https://example.com/cancel"), } s, _ := session.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SessionCreateOptions { PaymentMethodTypes = new List<string> { "card", }, LineItems = new List<SessionLineItemOptions> { new SessionLineItemOptions { Price = "{{PRICE_ID}}", Quantity = 1, TaxRates: new List<string> { "{{TAX_RATE_ID}}", }, }, }, Mode = "payment", SuccessUrl = "https://example.com/success", CancelUrl = "https://example.com/cancel", }; var service = new SessionService(); Session session = service.Create(options);
Dynamic tax rates
Pass the array of tax rates to line_items.dynamic_tax_rates. Each tax rate must have a supported country, and for the U.S., a state
.
This list is used to match tax rate(s) to your customer’s shipping address or billing address. The shipping address has precedence over the billing address for determining the tax rate to charge.
Billing address collection is automatically enabled when using dynamic tax rates. If you’re not collecting a shipping address, your customer’s billing address is used to determine the tax rate. If you haven’t passed a tax rate that matches your customer’s shipping or billing address, no tax rate is applied.
curl https://api.stripe.com/v1/checkout/sessions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "payment_method_types[]"=card \ -d "line_items[][price]"="{{PRICE_ID}}" \ -d "line_items[][quantity]"=1 \ -d "line_items[][dynamic_tax_rates][]"="{{FIRST_TAX_RATE_ID}}" \ -d "line_items[][dynamic_tax_rates][]"="{{SECOND_TAX_RATE_ID}}" \ -d mode=payment \ -d success_url="https://example.com/success" \ -d cancel_url="https://example.com/cancel"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' session = Stripe::Checkout::Session.create( payment_method_types: ['card'], line_items: [{ price: '{{PRICE_ID}}', quantity: 1, dynamic_tax_rates: [ '{{FIRST_TAX_RATE_ID}}', '{{SECOND_TAX_RATE_ID}}', # additional tax rates ], }], mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', )
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' session = stripe.checkout.Session.create( payment_method_types=['card'], line_items=[{ 'price': '{{PRICE_ID}}', 'quantity': 1, 'dynamic_tax_rates': [ '{{FIRST_TAX_RATE_ID}}', '{{SECOND_TAX_RATE_ID}}', # additional tax rates ], }], mode='payment', success_url='https://example.com/success', cancel_url='https://example.com/cancel', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $session = \Stripe\Checkout\Session::create([ 'payment_method_types' => ['card'], 'line_items' => [[ 'price' => '{{PRICE_ID}}', 'quantity' => 1, 'dynamic_tax_rates' => [ '{{FIRST_TAX_RATE_ID}}', '{{SECOND_TAX_RATE_ID}}', // additional tax rates ], ]], 'mode' => 'payment', 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Map<String, Object> params = new HashMap<String, Object>(); ArrayList<String> paymentMethodTypes = new ArrayList<>(); paymentMethodTypes.add("card"); params.put("payment_method_types", paymentMethodTypes); ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>(); HashMap<String, Object> lineItem = new HashMap<String, Object>(); lineItem.put("price", "{{PRICE_ID}}"); lineItem.put("quantity", 1); ArrayList<String> taxRates = new ArrayList<>(); taxRates.add("{{FIRST_TAX_RATE_ID}}"); taxRates.add("{{SECOND_TAX_RATE_ID}}"); // additional tax rates lineItem.put("dynamic_tax_rates", taxRates); lineItems.add(lineItem); params.put("line_items", lineItems); params.put("mode", "payment"); params.put("success_url", "https://example.com/success"); params.put("cancel_url", "https://example.com/cancel"); Session session = Session.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const session = await stripe.checkout.sessions.create({ payment_method_types: ['card'], line_items: [{ price: '{{PRICE_ID}}', quantity: 1, dynamic_tax_rates: [ '{{FIRST_TAX_RATE_ID}}', '{{SECOND_TAX_RATE_ID}}', // additional tax rates ], }], mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.CheckoutSessionParams{ PaymentMethodTypes: stripe.StringSlice([]string{ "card", }), LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("{{PRICE_ID}}"), Quantity: stripe.Int64(1), DynamicTaxRates: stripe.StringSlice([]string{ "{{FIRST_TAX_RATE_ID}}", "{{SECOND_TAX_RATE_ID}}", // additional tax rates }), }, }, Mode: stripe.String("payment"), SuccessURL: stripe.String("https://example.com/success"), CancelURL: stripe.String("https://example.com/cancel"), } session, err := session.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SessionCreateOptions { PaymentMethodTypes = new List<string> { "card", }, LineItems = new List<SessionLineItemOptions> { new SessionLineItemOptions { Price = "{{PRICE_ID}}", Quantity = 1, DynamicTaxRates = new List<string> { "{{FIRST_TAX_RATE_ID}}", "{{SECOND_TAX_RATE_ID}}", // additional tax rates }, }, }, Mode = "payment", SuccessUrl = "https://example.com/success", CancelUrl = "https://example.com/cancel", }; var service = new SessionService(); Session session = service.Create(options);
Tax reporting and remittance
Any business collecting taxes ultimately needs to remit tax to the appropriate government. You can use Stripe’s data exports to populate the periodic reports that you are required to make to taxation authorities.
Data exports
From the Dashboard’s Tax Rates list, you can export data files required for tax reporting calculations.
When using Checkout in payment mode, use the following two tax reporting exports:
- Checkout payment mode line item tax export — Includes details down to the line-item level, including per-line-item tax rates, inclusive/exclusive, amounts, etc. This is a lower-level export.
- Checkout payment mode totals export — Shows the aggregate tax collected on the Checkout Session as a whole, including adjustments for any refunds.
For remittance reporting, use the Checkout payment mode line item tax export to sum all amounts paid for all tax rates used. To factor in any refunds you will also need to pivot against the Checkout payment mode totals export.