# Automatically collect tax with the Checkout page

Learn how to automatically calculate taxes in Checkout using the Stripe-hosted page or full embedded page.

This guide shows you how to calculate and verify tax for new and existing customers through the Stripe-hosted payment page or Embedded payment page. If you haven’t integrated with Stripe Checkout, start with the [Accept a Payment guide](https://docs.stripe.com/checkout/quickstart.md) first.

### Interested in automatic tax set up for Checkout?

Request to join the preview for no code automatic tax calculation. Available only for one-time payments processed through Stripe Checkout.

```bash
curl https://docs.stripe.com/preview/register \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Referer: https://docs.stripe.com/tax/checkout/page" \
  -d '{"email": "EMAIL", "preview": "tax_default_on_checkout_preview"}'
```
[Watch on YouTube](https://www.youtube.com/watch?v=fMk7y-C6JuM)
## Add tax registrations [Dashboard] [Server-side]

Stripe Tax only collects tax in jurisdictions where you have an active registration. Create a [registration](https://docs.stripe.com/api/tax/registrations/create.md) for each country or state where you’re required to collect tax. The [country_options](https://docs.stripe.com/api/tax/registrations/create.md#tax_registration_create-country_options) structure varies by country.

```curl
curl https://api.stripe.com/v1/tax/registrations \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d country={{COUNTRY_CODE}} \
  -d "country_options[us][state]={{STATE}}" \
  -d "country_options[us][type]=state_sales_tax" \
  -d active_from=now
```

Alternatively, add registrations in the Dashboard. Go to the **Tax** > [Registrations](https://dashboard.stripe.com/tax/registrations). You only need to add a registration once per jurisdiction.

## Create a Checkout Session [Server-side]

You can create Checkout Sessions for one-time and recurring purchases.

A customer’s tax rates come from their location, which Checkout assesses from the customer’s address. The address that Checkout uses to calculate taxes depends on whether it’s a new or existing customer, and whether you collect a shipping address in the Checkout Session.

|  | New Customer | Existing Customer |
| --- | --- | --- |
| **Collect a billing address only** | Checkout calculates taxes based on the billing address the customer provides in the Checkout Session. | If the customer has a previously saved shipping address, Checkout calculates taxes based on that address. Otherwise, Checkout calculates taxes based on the billing address the customer provided in the Checkout Session (by specifying [customer_update[address]=auto](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer_update-address)) or the customer’s previously saved billing address (the default behavior). |
| **Collect a shipping address** | Checkout calculates taxes based on the shipping address the customer provided in the Checkout Session. | Checkout calculates taxes based on the shipping address the customer provided in the Checkout Session. If the customer has a previously saved shipping address, the Checkout page prefills the address. The customer can update the shipping address in the Checkout Session, and Checkout calculates taxes based on the new address. |

> #### Google Pay in Checkout
> 
> To make sure Google Pay is offered as a payment method while using Stripe Tax in Checkout, you must either collect a shipping address or provide an existing customer with a saved shipping address.

### Use automatic tax with any payment method 

Setting `automatic_tax.enabled` to `true` applies automatic tax to the entire Checkout Session. You don’t need to enable automatic tax separately for cards, stablecoins, or other eligible payment methods. The selected payment method doesn’t change the inputs that Stripe Tax uses: your Tax settings and registrations, the [product tax code and price tax behavior](https://docs.stripe.com/tax/products-prices-tax-codes-tax-behavior.md), the Checkout Session’s taxable amount, and the customer location that Checkout resolves using the address hierarchy above.

Payment methods provide different location information. Checkout reuses an existing customer address or collects a shipping or billing address according to the hierarchy above. If Checkout needs additional location information to calculate tax, it collects the required billing details.

For example, when a customer [pays with stablecoins](https://docs.stripe.com/payments/accept-stablecoin-payments.md?payment-ui=checkout), Checkout calculates tax using the Checkout Session’s amount and presentment currency before authorizing payment. The stablecoin token, wallet, and network that the customer selects—and the subsequent settlement to your Stripe balance—don’t trigger another Stripe Tax calculation or require crypto-specific Stripe Tax configuration. The tax calculation still depends on your registrations, the customer’s location, the product classification, and the rules that apply in the relevant jurisdiction.

### Calculate tax for new customers 

Set `customer_creation=always` in the Checkout Session to create a customer-configured [Account](https://docs.stripe.com/accounts-v2/use-accounts-as-customers.md) or [Customer](https://docs.stripe.com/api/customers.md) with their billing and shipping addresses. Checkout calculates taxes based on the shipping address (if provided) or the billing address if no shipping address has been provided.

#### Stripe-hosted page

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "line_items[0][price]={{PRICE_ID}}" \
  -d "line_items[0][quantity]=2" \
  -d "automatic_tax[enabled]=true" \
  -d customer_creation=always \
  -d mode=payment \
  --data-urlencode "success_url=https://example.com/success"
```

#### Full embedded page

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "line_items[0][price]={{PRICE_ID}}" \
  -d "line_items[0][quantity]=2" \
  -d "automatic_tax[enabled]=true" \
  -d customer_creation=always \
  -d mode=payment \
  -d ui_mode=embedded_page \
  --data-urlencode "return_url=https://example.com/return"
```

### Calculate tax for existing customers 

#### Accounts v2

To calculate tax on Checkout Sessions for existing customer-configured [Accounts](https://docs.stripe.com/accounts-v2/use-accounts-as-customers.md), set `automatic_tax.enabled` to true and `customer_account` to the `Account` ID. Checkout uses the following address prioritization to calculate taxes:

1. If specified, Checkout uses the [collected shipping address](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection) to calculate taxes. If you collect the shipping address, you must also set `customer_update.shipping` to `auto` to add the collected shipping address to the `Account`, or update the `Account`’s existing shipping address.

   #### Stripe-hosted page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer_account={{CUSTOMERACCOUNT_ID}}" \
     -d "customer_update[shipping]=auto" \
     -d "shipping_address_collection[allowed_countries][0]=US" \
     -d mode=payment \
     --data-urlencode "success_url=https://example.com/success"
   ```

   #### Full embedded page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer_account={{CUSTOMERACCOUNT_ID}}" \
     -d "customer_update[shipping]=auto" \
     -d "shipping_address_collection[allowed_countries][0]=US" \
     -d mode=payment \
     -d ui_mode=embedded_page \
     --data-urlencode "return_url=https://example.com/return"
   ```

2. If you don’t collect the shipping address, Checkout uses the `Account`’s [existing shipping address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-configuration-customer-shipping-address) to calculate taxes, if available.

3. If the shipping address isn’t available, Checkout uses the billing address to calculate taxes. Set `billing_address_collection` to `required` to always collect a billing address, or `auto` (default) to collect it when needed. If Checkout collects the billing address, set `customer_update.address` to `auto` to calculate taxes using the collected billing address, or to `never` to use the `Account`’s existing address to calculate taxes.

   #### Stripe-hosted page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer_account={{CUSTOMERACCOUNT_ID}}" \
     -d "customer_update[address]=auto" \
     -d billing_address_collection=required \
     -d mode=payment \
     --data-urlencode "success_url=https://example.com/success"
   ```

   #### Full embedded page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer_account={{CUSTOMERACCOUNT_ID}}" \
     -d "customer_update[address]=auto" \
     -d billing_address_collection=required \
     -d mode=payment \
     -d ui_mode=embedded_page \
     --data-urlencode "return_url=https://example.com/return"
   ```

4. Otherwise, Checkout uses addresses from the `Account`, following the [address hierarchy](https://docs.stripe.com/tax/customer-locations.md#address-hierarchy).

#### Customer v1

To calculate tax on Checkout Sessions for existing customers, set `automatic_tax.enabled` to true and specify the `Customer` ID. Checkout uses the following address prioritization to calculate taxes:

1. If specified, Checkout uses the [collected shipping address](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection) to calculate taxes. If you collect the shipping address, you must also set `customer_update.shipping` to `auto` to add the collected shipping address to the `Customer` or update the `Customer`’s existing shipping address.

   #### Stripe-hosted page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer={{CUSTOMER_ID}}" \
     -d "customer_update[shipping]=auto" \
     -d "shipping_address_collection[allowed_countries][0]=US" \
     -d mode=payment \
     --data-urlencode "success_url=https://example.com/success"
   ```

   #### Full embedded page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer={{CUSTOMER_ID}}" \
     -d "customer_update[shipping]=auto" \
     -d "shipping_address_collection[allowed_countries][0]=US" \
     -d mode=payment \
     -d ui_mode=embedded_page \
     --data-urlencode "return_url=https://example.com/return"
   ```

2. If you don’t collect the shipping address, Checkout uses the Customer’s [existing shipping address](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) to calculate taxes, if available.

3. If the shipping address isn’t available, Checkout uses the billing address to calculate taxes. Set `billing_address_collection` to `required` to always collect a billing address, or `auto` (default) to collect when needed. If Checkout collects the billing address, set `customer_update.address` to `auto` to calculate taxes using the collected billing address, or to `never` to use the Customer’s existing address to calculate taxes.

   #### Stripe-hosted page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer={{CUSTOMER_ID}}" \
     -d "customer_update[address]=auto" \
     -d billing_address_collection=required \
     -d mode=payment \
     --data-urlencode "success_url=https://example.com/success"
   ```

   #### Full embedded page

   ```curl
   curl https://api.stripe.com/v1/checkout/sessions \
     -u "<<YOUR_SECRET_KEY>>:" \
     -d "line_items[0][price]={{PRICE_ID}}" \
     -d "line_items[0][quantity]=2" \
     -d "automatic_tax[enabled]=true" \
     -d "customer={{CUSTOMER_ID}}" \
     -d "customer_update[address]=auto" \
     -d billing_address_collection=required \
     -d mode=payment \
     -d ui_mode=embedded_page \
     --data-urlencode "return_url=https://example.com/return"
   ```

4. Otherwise, Checkout uses addresses from the customer, following the [address hierarchy](https://docs.stripe.com/tax/customer-locations.md#address-hierarchy).

## Check the response [Server-side]

To inspect the results of the latest tax calculation, you can read the tax amount calculated by Checkout from the [total_details.amount_tax](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-total_details) on the Checkout Session resource. Additionally, the tax outcome for each payment is available when [viewing a payment](https://dashboard.stripe.com/test/payments) in the Dashboard.

## Optional: Update your products and prices

Stripe Tax uses information stored on your products and prices to calculate tax, including tax codes and tax behavior. If you don’t explicitly configure these, Stripe Tax uses the defaults from your [Tax Settings](https://dashboard.stripe.com/settings/tax).

For detailed setup instructions, see [Specify product tax codes and tax behavior](https://docs.stripe.com/tax/products-prices-tax-codes-tax-behavior.md).

## Optional: Specify tax codes with inline products [Server-side]

When creating a Checkout Session with [line_items.price_data.product_data](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-line_items-price_data-product_data), you can specify a tax code directly in the request whenever you create new products instead of using existing product IDs.

#### Stripe-hosted page

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "line_items[0][price_data][currency]=usd" \
  -d "line_items[0][price_data][unit_amount]=2000" \
  -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][quantity]=1" \
  -d "automatic_tax[enabled]=true" \
  -d mode=payment \
  --data-urlencode "success_url=https://example.com/success"
```

#### Full embedded page

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "line_items[0][price_data][currency]=usd" \
  -d "line_items[0][price_data][unit_amount]=2000" \
  -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][quantity]=1" \
  -d "automatic_tax[enabled]=true" \
  -d mode=payment \
  -d ui_mode=embedded_page \
  --data-urlencode "return_url=https://example.com/return"
```

Replace `txcd_99999999` with the appropriate [tax code](https://docs.stripe.com/tax/tax-codes.md) for your product. The tax code determines how the product is categorized for tax purposes. If you don’t specify a tax code, Stripe Tax uses the default tax code from your [Tax Settings](https://dashboard.stripe.com/settings/tax).

## See also

- [Test your tax integration](https://docs.stripe.com/tax/testing.md)
- [Determine customer locations](https://docs.stripe.com/tax/customer-locations.md)
- [Reporting and filing](https://docs.stripe.com/tax/reports.md)
