Collect taxes
Learn how to use Stripe Tax to calculate and collect taxes in your custom integration with Elements.
Add tax registrations Dashboard Server-side
Stripe Tax only collects tax in jurisdictions where you have an active registration. Create a registration for each country or state where you’re required to collect tax. The country_options structure varies by country.
Command Line
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
Alternatively, add registrations in the Dashboard. Go to the Tax > Registrations. You only need to add a registration once per jurisdiction.
Configure your Checkout Session to collect tax
To start collecting tax:
- Pass automatic_tax[enabled]=true when creating a Checkout Session.
- Specify a tax_code for each line item, or set a preset tax code in the Dashboard .
- Specify a tax_behavior for each line item, or set a default tax behavior in the Dashboard .
This code enables automatic tax calculation using Stripe Tax, a tax code, and a tax behavior. Stripe Tax then uses the tax code and tax behavior to automatically calculate taxes.
Command Line
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
Tax codes
The tax codes associate products with tax rates. Choose the appropriate tax code for your product from the list of tax codes. If a product doesn’t match with any of the tax codes, you can use one of the General codes.
Tax behavior
The tax behavior determines how to present tax to the customer:
- Exclusive : The product price doesn’t include tax, which is added as a separate amount.
- Inclusive : The product price includes any tax amount.
Optional Collect tax address details through the Payment Element
Optional Check the response
Render the tax amount
Use the useCheckoutElements hook to display the tax amount in your payment form.
import React from 'react';
import {useCheckoutElements} from '@stripe/react-stripe-js';
const CheckoutForm = () => {
const checkoutState = useCheckoutElements();
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 use the appropriate tax amount type (taxInclusive and/or taxExclusive) for your integration */}
Tax: {checkout.total.taxExclusive.amount}
Total: {checkout.total.total.amount}
</pre>
</div>
)
};
Collect customer tax IDs
Set up tax ID collection to collect VAT and other business tax IDs during checkout. After enabling collection on your Checkout Session, render the Tax ID Element in your payment form.
Render the Tax ID Element Client-side Public preview
Use Stripe’s Tax ID Element to collect tax IDs.
App.jsx
Real-time tax ID validation Preview
In addition to the asynchronous validation described above, you can enable synchronous, real-time tax ID verification directly in the Tax ID Element. When you enable it, Stripe verifies tax IDs against government databases as your customer types and displays the result inline before they submit the payment. Stripe currently supports real-time verification for Australian Business Numbers (ABNs), European Value Added Tax (EU VAT), and United Kingdom Value Added Tax (GB VAT) numbers. If a government database is unavailable, Stripe falls back to synchronous format validation and performs full verification asynchronously. This feature is in public preview and requires the custom_checkout_tax_id_verification_1 beta.
const taxIdElement = checkout.createTaxIdElement({
...
verification: {
taxId: {
mode: 'if_supported',
},
},
});
When you enable verification, the change event includes the verification.taxId.status field. Its value can be pending, verified, unverified, or unavailable. The element’s complete status reflects the verification result. See Create a Tax ID Element and Tax ID Element on Change for details.
