--- title: Automatically collect tax on Checkout sessions subtitle: Learn how to automatically calculate taxes in Checkout. route: /tax/checkout --- # Automatically collect tax on Checkout sessions Learn how to automatically calculate taxes in Checkout. Stripe Tax automatically calculates the taxes on all purchases and *subscriptions* accumulated during a Checkout session. If you haven’t integrated with Checkout, you must complete the integration using the [Accept a Payment guide](https://docs.stripe.com/checkout/quickstart.md). ## Get started with a video demo This short video shows to how to enable automatic tax collection when using hosted integrations like Stripe Checkout. ## Create a Checkout Session 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 the customer is new or existing, and whether you collect shipping addresses during the Checkout Session: | | New Customer | Existing Customer | | ---------------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Collect a billing address only** | Checkout calculates taxes based on the customer’s billing address entered into the Checkout Session | If the customer has a previously saved shipping address, Checkout calculates taxes based on that address. Otherwise, you can calculate taxes based on billing address entered during Checkout (by specifying [customer_update[address]=auto](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer_update-address)) or the billing address saved to the customer (the default behavior). | | **Collect a shipping address** | Checkout calculates taxes based on the customer’s shipping address entered into the Checkout Session | Checkout calculates taxes based on the customer’s shipping address entered into the Checkout Session. _Existing addresses on the customer won’t apply in this case._ | If you wish to ensure that Google Pay is offered as a payment method while using Stripe Tax in Checkout, you must require collecting a shipping address. Apple Pay with Stripe Tax displays only when the customer’s browser supports Apple Pay version 12. ## Calculating tax for new customers If you don’t pass in an existing customer when creating a Checkout session, Checkout creates a new customer and automatically saves billing address and shipping information. For tax collection purposes, Checkout uses billing and shipping addresses to determine the customer’s location. Checkout uses the shipping address entered during the session to determine the customer’s location for calculating tax. If you don’t collect shipping information, Checkout uses the billing address. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Mode = "payment", SuccessUrl = "https://example.com/success", CancelUrl = "https://example.com/cancel", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), SuccessURL: stripe.String("https://example.com/success"), CancelURL: stripe.String("https://example.com/cancel"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setMode(SessionCreateParams.Mode.PAYMENT) .setSuccessUrl("https://example.com/success") .setCancelUrl("https://example.com/cancel") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, mode="payment", success_url="https://example.com/success", cancel_url="https://example.com/cancel", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'mode' => 'payment', 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }) ``` ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Mode = "payment", UiMode = "embedded", ReturnUrl = "https://example.com/return", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), UIMode: stripe.String(string(stripe.CheckoutSessionUIModeEmbedded)), ReturnURL: stripe.String("https://example.com/return"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setMode(SessionCreateParams.Mode.PAYMENT) .setUiMode(SessionCreateParams.UiMode.EMBEDDED) .setReturnUrl("https://example.com/return") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, mode="payment", ui_mode="embedded", return_url="https://example.com/return", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'mode' => 'payment', 'ui_mode' => 'embedded', 'return_url' => 'https://example.com/return', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }) ``` ## Calculate tax for existing customers To calculate tax on Checkout sessions created for existing customers, you can set the `automatic_tax[enabled]` parameter to `true` when creating the session. You can either base tax calculations on the customer’s existing addresses or new addresses collected during the session: ### Use the existing addresses on the customer for taxes If you’ve already collected the addresses of existing customers, you can base tax calculations on those addresses rather than the addresses collected during checkout: * **The customer address that Checkout uses for taxes**: If available, Checkout uses the customer’s saved [shipping address](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) to calculate taxes. Otherwise, Checkout uses the customer’s saved [billing address](https://docs.stripe.com/api/customers/object.md#customer_object-address) to calculate taxes. * **Customer address requirements**: When using existing addresses for taxes, the customer must either have a valid [shipping address](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) or [billing address](https://docs.stripe.com/api/customers/object.md#customer_object-address) saved. You can see whether or not a customer’s saved addresses are valid by checking the customer’s [customer.tax.automatic_tax](https://docs.stripe.com/api/customers/object.md#customer_object-tax-automatic_tax) property. If the property is `supported` or `not_collecting`, it means the customer’s saved addresses are valid, and you can enable Stripe Tax on Checkout sessions for that customer. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Customer = "<>", Mode = "payment", SuccessUrl = "https://example.com/success", CancelUrl = "https://example.com/cancel", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Customer: stripe.String("<>"), Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), SuccessURL: stripe.String("https://example.com/success"), CancelURL: stripe.String("https://example.com/cancel"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setCustomer("<>") .setMode(SessionCreateParams.Mode.PAYMENT) .setSuccessUrl("https://example.com/success") .setCancelUrl("https://example.com/cancel") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, customer: '<>', mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, customer="<>", mode="payment", success_url="https://example.com/success", cancel_url="https://example.com/cancel", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'customer' => '<>', 'mode' => 'payment', 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, customer: '<>', mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }) ``` ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Customer = "<>", Mode = "payment", UiMode = "embedded", ReturnUrl = "https://example.com/return", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Customer: stripe.String("<>"), Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), UIMode: stripe.String(string(stripe.CheckoutSessionUIModeEmbedded)), ReturnURL: stripe.String("https://example.com/return"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setCustomer("<>") .setMode(SessionCreateParams.Mode.PAYMENT) .setUiMode(SessionCreateParams.UiMode.EMBEDDED) .setReturnUrl("https://example.com/return") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, customer: '<>', mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, customer="<>", mode="payment", ui_mode="embedded", return_url="https://example.com/return", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'customer' => '<>', 'mode' => 'payment', 'ui_mode' => 'embedded', 'return_url' => 'https://example.com/return', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, customer: '<>', mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }) ``` ### Use the addresses collected during Checkout for taxes You can configure Checkout to save new billing or shipping addresses to a customer. In this case, Checkout calculates tax using the address entered during checkout. * **The address that Checkout uses for taxes**: If you [collect shipping addresses](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection), Checkout uses the shipping address entered during the session to calculate taxes. Otherwise, Checkout uses the billing address entered during the session to calculate taxes. * **Where Checkout saves the addresses collected during checkout**: If you [collect shipping addresses](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection), Checkout saves the shipping address entered during the session to the customer’s [customer.shipping.address](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) property. Otherwise, Checkout saves the billing address entered during the session to the customer’s [customer.address](https://docs.stripe.com/api/customers/object.md#customer_object-address) property. In both cases, the address used for taxes overrides any existing addresses. If you collect shipping addresses with Checkout, set the `customer_update[shipping]` property to `auto` so that you copy the shipping information from Checkout to the customer. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Customer = "<>", CustomerUpdate = new Stripe.Checkout.SessionCustomerUpdateOptions { Shipping = "auto" }, ShippingAddressCollection = new Stripe.Checkout.SessionShippingAddressCollectionOptions { AllowedCountries = new List { "US" }, }, Mode = "payment", SuccessUrl = "https://example.com/success", CancelUrl = "https://example.com/cancel", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Customer: stripe.String("<>"), CustomerUpdate: &stripe.CheckoutSessionCustomerUpdateParams{Shipping: stripe.String("auto")}, ShippingAddressCollection: &stripe.CheckoutSessionShippingAddressCollectionParams{ AllowedCountries: []*string{stripe.String("US")}, }, Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), SuccessURL: stripe.String("https://example.com/success"), CancelURL: stripe.String("https://example.com/cancel"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setCustomer("<>") .setCustomerUpdate( SessionCreateParams.CustomerUpdate.builder() .setShipping(SessionCreateParams.CustomerUpdate.Shipping.AUTO) .build() ) .setShippingAddressCollection( SessionCreateParams.ShippingAddressCollection.builder() .addAllowedCountry(SessionCreateParams.ShippingAddressCollection.AllowedCountry.US) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setSuccessUrl("https://example.com/success") .setCancelUrl("https://example.com/cancel") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, customer: '<>', customer_update: { shipping: 'auto', }, shipping_address_collection: { allowed_countries: ['US'], }, mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, customer="<>", customer_update={"shipping": "auto"}, shipping_address_collection={"allowed_countries": ["US"]}, mode="payment", success_url="https://example.com/success", cancel_url="https://example.com/cancel", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'customer' => '<>', 'customer_update' => ['shipping' => 'auto'], 'shipping_address_collection' => ['allowed_countries' => ['US']], 'mode' => 'payment', 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, customer: '<>', customer_update: {shipping: 'auto'}, shipping_address_collection: {allowed_countries: ['US']}, mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }) ``` ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Customer = "<>", CustomerUpdate = new Stripe.Checkout.SessionCustomerUpdateOptions { Shipping = "auto" }, ShippingAddressCollection = new Stripe.Checkout.SessionShippingAddressCollectionOptions { AllowedCountries = new List { "US" }, }, Mode = "payment", UiMode = "embedded", ReturnUrl = "https://example.com/return", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Customer: stripe.String("<>"), CustomerUpdate: &stripe.CheckoutSessionCustomerUpdateParams{Shipping: stripe.String("auto")}, ShippingAddressCollection: &stripe.CheckoutSessionShippingAddressCollectionParams{ AllowedCountries: []*string{stripe.String("US")}, }, Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), UIMode: stripe.String(string(stripe.CheckoutSessionUIModeEmbedded)), ReturnURL: stripe.String("https://example.com/return"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setCustomer("<>") .setCustomerUpdate( SessionCreateParams.CustomerUpdate.builder() .setShipping(SessionCreateParams.CustomerUpdate.Shipping.AUTO) .build() ) .setShippingAddressCollection( SessionCreateParams.ShippingAddressCollection.builder() .addAllowedCountry(SessionCreateParams.ShippingAddressCollection.AllowedCountry.US) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setUiMode(SessionCreateParams.UiMode.EMBEDDED) .setReturnUrl("https://example.com/return") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, customer: '<>', customer_update: { shipping: 'auto', }, shipping_address_collection: { allowed_countries: ['US'], }, mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, customer="<>", customer_update={"shipping": "auto"}, shipping_address_collection={"allowed_countries": ["US"]}, mode="payment", ui_mode="embedded", return_url="https://example.com/return", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'customer' => '<>', 'customer_update' => ['shipping' => 'auto'], 'shipping_address_collection' => ['allowed_countries' => ['US']], 'mode' => 'payment', 'ui_mode' => 'embedded', 'return_url' => 'https://example.com/return', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, customer: '<>', customer_update: {shipping: 'auto'}, shipping_address_collection: {allowed_countries: ['US']}, mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }) ``` If you don’t collect shipping addresses with Checkout, and you want to use billing addresses entered during checkout for taxes, you must save the billing address to the customer. Set the `customer_update[address]` property to `auto` so that you copy the newly-entered address onto the provided customer. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Customer = "<>", CustomerUpdate = new Stripe.Checkout.SessionCustomerUpdateOptions { Address = "auto" }, Mode = "payment", SuccessUrl = "https://example.com/success", CancelUrl = "https://example.com/cancel", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Customer: stripe.String("<>"), CustomerUpdate: &stripe.CheckoutSessionCustomerUpdateParams{Address: stripe.String("auto")}, Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), SuccessURL: stripe.String("https://example.com/success"), CancelURL: stripe.String("https://example.com/cancel"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setCustomer("<>") .setCustomerUpdate( SessionCreateParams.CustomerUpdate.builder() .setAddress(SessionCreateParams.CustomerUpdate.Address.AUTO) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setSuccessUrl("https://example.com/success") .setCancelUrl("https://example.com/cancel") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, customer: '<>', customer_update: { address: 'auto', }, mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, customer="<>", customer_update={"address": "auto"}, mode="payment", success_url="https://example.com/success", cancel_url="https://example.com/cancel", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'customer' => '<>', 'customer_update' => ['address' => 'auto'], 'mode' => 'payment', 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, customer: '<>', customer_update: {address: 'auto'}, mode: 'payment', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', }) ``` ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "<>", Quantity = 2 }, }, AutomaticTax = new Stripe.Checkout.SessionAutomaticTaxOptions { Enabled = true }, Customer = "<>", CustomerUpdate = new Stripe.Checkout.SessionCustomerUpdateOptions { Address = "auto" }, Mode = "payment", UiMode = "embedded", ReturnUrl = "https://example.com/return", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("<>"), Quantity: stripe.Int64(2), }, }, AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, Customer: stripe.String("<>"), CustomerUpdate: &stripe.CheckoutSessionCustomerUpdateParams{Address: stripe.String("auto")}, Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), UIMode: stripe.String(string(stripe.CheckoutSessionUIModeEmbedded)), ReturnURL: stripe.String("https://example.com/return"), }; result, err := session.New(params); ``` ```java Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder().setPrice("<>").setQuantity(2L).build() ) .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) .setCustomer("<>") .setCustomerUpdate( SessionCreateParams.CustomerUpdate.builder() .setAddress(SessionCreateParams.CustomerUpdate.Address.AUTO) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setUiMode(SessionCreateParams.UiMode.EMBEDDED) .setReturnUrl("https://example.com/return") .build(); Session session = Session.create(params); ``` ```node const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: { enabled: true, }, customer: '<>', customer_update: { address: 'auto', }, mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }); ``` ```python import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "<>", "quantity": 2}], automatic_tax={"enabled": True}, customer="<>", customer_update={"address": "auto"}, mode="payment", ui_mode="embedded", return_url="https://example.com/return", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '<>', 'quantity' => 2, ], ], 'automatic_tax' => ['enabled' => true], 'customer' => '<>', 'customer_update' => ['address' => 'auto'], 'mode' => 'payment', 'ui_mode' => 'embedded', 'return_url' => 'https://example.com/return', ]); ``` ```ruby Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '<>', quantity: 2, }, ], automatic_tax: {enabled: true}, customer: '<>', customer_update: {address: 'auto'}, mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/return', }) ``` ## Check the response 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. ## Update your products and prices Stripe Tax uses information stored on *products* and *prices* to calculate tax, such as *tax code* and *tax behavior*. If you don’t explicitly specify these configurations, Stripe Tax will use the default tax code selected in [Tax Settings](https://dashboard.stripe.com/settings/tax). For more information, see [Specify product tax codes and tax behaviour](https://docs.stripe.com/tax/products-prices-tax-codes-tax-behavior.md). ## See Also * [Determining customer locations](https://docs.stripe.com/tax/customer-locations.md) * [Checkout and tax IDs](https://docs.stripe.com/tax/checkout/tax-ids.md) * [Reporting and filing](https://docs.stripe.com/tax/reports.md) * [Use Stripe Tax with Connect](https://docs.stripe.com/tax/connect.md) * [Calculate tax in your custom checkout flow](https://docs.stripe.com/tax/custom.md)