# 收税 了解如何在 Stripe Checkout 中为一次性付款收税。 # Full hosted page > This is a Full hosted page for when payment-ui is stripe-hosted. View the full page at https://docs.stripe.com/payments/checkout/taxes?payment-ui=stripe-hosted. 使用 Stripe Tax,您可以在使用 Checkout 时计算您的一次性和经常性付款的税额。您可以启用 Stripe Tax 来自动计算您的所有 Checkout 流程中的购物和订阅的税额。 > #### 将纳税义务转移至 Stripe > > 若您销售数字产品,[Managed Payments](https://docs.stripe.com/payments/managed-payments/tax-compliance.md) 可让您将纳税义务转移至 Stripe,由我方直接负责处理全球范围内的销售税、增值税或商品及服务税。作为备案商家解决方案,Managed Payments 还会对所有交易提供欺诈预防、争议管理及客户支持服务。 ## 创建一个 Checkout Session 您可以为一次性购买和经常性购买创建 Checkout Session。 为了计算新客户的税费,Checkout 会验证并使用提供的收货或账单地址。对于现有客户,Checkout 通过验证并使用客户已关联的收货或账单地址来计算税费。如果您为现有客户录入新的账单或收货地址,Checkout 不会自动覆盖之前的账单或收货信息。您必须明确请求更改客户地址。 ### Apple Pay 和 Google Pay 为确保在使用 Stripe Tax 的 Checkout 中提供 Google Pay 作为付款方式,您必须要求收集收货地址,或向现有客户提供已保存的收货地址。只有当客户的浏览器支持 Apple Pay 12 版本或更高版本时,才会显示带有 Stripe Tax 的 Apple Pay。 ## 为新客户计税 如果您在创建 Checkout 会话时不传入现有客户,则 Checkout 会创建一个新的客户并自动保存账单地址和收货地址。Checkout 使用会话过程中输入的收货地址来确定客户的计税地点。如果您不收集收货地址信息,则 Checkout 会使用账单地址。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price]={{PRICE_ID}}" \ -d "line_items[0][quantity]=2" \ -d "automatic_tax[enabled]=true" \ -d mode=payment \ --data-urlencode "success_url=https://example.com/success" ``` ## Optional: 更新您的产品和价格 Stripe Tax 利用*产品* (Products represent what your business sells—whether that's a good or a service)和*价格* (Prices define how much and how often to charge for products. This includes how much the product costs, what currency to use, and the interval if the price is for subscriptions)上储存的信息来计算税额,例如*税务代码* (A tax code is the category of your product for tax purposes)和*税务行为* (Tax behavior determines whether you want to include taxes in the price ("inclusive") or add them on top ("exclusive"))。如果您未明确指定这些配置,Stripe Tax 将使用在[税务设置](https://dashboard.stripe.com/settings/tax)中选择的默认税务代码。 更多信息,请参阅[指定产品税号和纳税行为](https://docs.stripe.com/tax/products-prices-tax-codes-tax-behavior.md)。 ## Optional: 为现有客户计税 要在现有客户的 Checkout 会话中计税,请在创建会话时将 `automatic_tax[enabled]` 参数设置为 `true`。您可以根据客户的现有地址或在结账过程中收集的新地址来计算税额: ### 用客户上的现有地址来计税 如果您已经收集了现有客户的地址,则可以基于这些地址而非结账时收集的地址来计税: > #### 使用 Accounts v2 API 表示客户 > > Accounts v2 API 通常面向 Connect 用户开放,并对其他 Stripe 用户开放公开预览。如果您参与了 Accounts v2 预览,您需要在代码中[指定预览版本](https://docs.stripe.com/api-v2-overview.md#sdk-and-api-versioning)。 > > 如需申请 Accounts v2 预览版的访问权限, > > 在大多数应用场景下,我们建议[将您的客户建模为客户配置的 Account 对象](https://docs.stripe.com/connect/use-accounts-as-customers.md),而不是使用 [Customer](https://docs.stripe.com/api/customers.md) 对象。 #### 账户 v2 如果有,Checkout 会使用客户的 [configuration.customer.shipping.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-configuration-customer-shipping-address) 计算税费。否则,它会使用客户的账单地址 ([identity.individual.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-identity-individual-address) 或 [identity.business_details.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-identity-business_details-address))。您可以通过检查客户保存地址的 [configuration.customer.capabilities.automatic_indirect_tax.status](https://docs.stripe.com/api/v2/core/accounts/retrieve.md#v2_retrieve_accounts-response-configuration-customer-capabilities-automatic_indirect_tax-status) 是否为 `active`,来验证这些地址是否有效。此属性仅在您通过将 [configuration.customer.capabilities.automatic_indirect_tax.requested](https://docs.stripe.com/api/v2/core/accounts/create.md#v2_create_accounts-configuration-customer-capabilities-automatic_indirect_tax-requested) 设置为 true 来请求该功能时才可用。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price]={{PRICE_ID}}" \ -d "line_items[0][quantity]=2" \ -d "automatic_tax[enabled]=true" \ -d "customer_account={{CUSTOMERACCOUNT_ID}}" \ -d mode=payment \ --data-urlencode "success_url=https://example.com/success" ``` #### Customers v1 如果有,Checkout 会使用客户的 [shipping.address ](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) 计算税费。否则,它会使用客户的账单地址 ([address](https://docs.stripe.com/api/customers/object.md#customer_object-address)) 计算税费。您可以通过检查客户保存地址的 [tax.automatic_tax](https://docs.stripe.com/api/customers/object.md#customer_object-tax-automatic_tax) 属性,验证这些地址是否有效。如果 `tax.automatic_tax` 是 `supported` 或 `not_collecting`,则客户保存的地址有效,并且您可以在 Checkout 会话中为该客户启用 Stripe Tax。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price]={{PRICE_ID}}" \ -d "line_items[0][quantity]=2" \ -d "automatic_tax[enabled]=true" \ -d "customer={{CUSTOMER_ID}}" \ -d mode=payment \ --data-urlencode "success_url=https://example.com/success" ``` ### 用结账过程中收集的地址计税 可以通过配置 Checkout 来保存客户的新账单地址或收货地址。这种情况下,Checkout 使用结账过程中输入的地址来计算税额。 #### 账户 v2 如果您[收集收货地址](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection),Checkout 将把在会话时输入的收货地址保存至客户的 [configuration.customer.shipping](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-configuration-customer-shipping) 属性,并用它来计算税费。否则,Checkout 会将会话时输入的账单地址保存至客户的 [identity.individual.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-identity-individual-address) 属性,并用它来计算税费。在这两种情况下,结账时输入的地址都会替换任何现有地址。 如果您通过 Checkout 收集收货地址,请将 `customer_update.shipping` 属性设置为 `auto`。这会自动将来自 Checkout 的收货信息复制到客户的 `Account` 中。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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" ``` 如果您未通过 Checkout 收集收货地址,并且希望 Stripe Tax 使用结账时输入的账单地址,则您必须将账单地址保存至客户。请将 `customer_update.address` 属性设置为 `auto`,以自动将输入的地址复制到客户的 `Account` 中。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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 mode=payment \ --data-urlencode "success_url=https://example.com/success" ``` #### Customers v1 如果您[收集收货地址](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection),Checkout 会将会话时输入的收货地址保存至客户的 [shipping.address](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) 属性,并用它来计算税费。否则,Checkout 会将会话时输入的账单地址保存至客户的 [address](https://docs.stripe.com/api/customers/object.md#customer_object-address) 属性,并用它来计算税费。在这两种情况下,结账时输入的地址都会替换任何现有地址。 如果您通过 Checkout 收集收货地址,请将 `customer_update.shipping` 属性设置为 `auto`。这会自动将来自 Checkout 的收货信息复制给客户。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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" ``` 如果未通过 Checkout 收集收货地址,并且希望用结账时输入的账单地址计算税费,则您必须将账单地址保存至客户。请将 `customer_update.address` 属性设置为 `auto`,以自动将输入的地址复制到 `Customer`。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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 mode=payment \ --data-urlencode "success_url=https://example.com/success" ``` ## Optional: 查看响应 要查看最近的税额计算结果,可以查看 Checkout Session 资源中的 [total_details.amount_tax](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-total_details) 属性,其中会显示计算的税额。此外,您可以用[管理平台](https://dashboard.stripe.com/)来查看计算的每笔付款的税额。 # Full embedded page > This is a Full embedded page for when payment-ui is embedded-page. View the full page at https://docs.stripe.com/payments/checkout/taxes?payment-ui=embedded-page. 使用 Stripe Tax,您可以在使用 Checkout 时计算您的一次性和经常性付款的税额。您可以启用 Stripe Tax 来自动计算您的所有 Checkout 流程中的购物和订阅的税额。 > #### 将纳税义务转移至 Stripe > > 若您销售数字产品,[Managed Payments](https://docs.stripe.com/payments/managed-payments/tax-compliance.md) 可让您将纳税义务转移至 Stripe,由我方直接负责处理全球范围内的销售税、增值税或商品及服务税。作为备案商家解决方案,Managed Payments 还会对所有交易提供欺诈预防、争议管理及客户支持服务。 ## 创建一个 Checkout Session 更新了您的产品和价格后,您即可开始在您的 Checkout 会话中计算税额。您可以为一次性购买和经常性购买创建会话。 为新客户计算税额时,Checkout 会验证并使用提供的收货地址或账单地址。对于现有客户,Checkout 通过验证并使用关联的客户收货地址或账单地址来计税。如果您捕获现有客户的新账单或收货地址,那么 Checkout 不会自动覆盖之前的账单或收货地址信息。必须明确要求客户地址更改。 ### Apple Pay 和 Google Pay 为确保在使用 Stripe Tax 的 Checkout 中提供 Google Pay 作为付款方式,您必须要求收集收货地址,或向现有客户提供已保存的收货地址。只有当客户的浏览器支持 Apple Pay 12 版本或更高版本时,才会显示带有 Stripe Tax 的 Apple Pay。 ## 为新客户计税 如果您在创建 Checkout 会话时不传入现有客户,则 Checkout 会创建一个新的客户并自动保存账单地址和收货地址。Checkout 使用会话过程中输入的收货地址来确定客户的计税地点。如果您不收集收货地址信息,则 Checkout 会使用账单地址。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price]={{PRICE_ID}}" \ -d "line_items[0][quantity]=2" \ -d "automatic_tax[enabled]=true" \ -d mode=payment \ -d ui_mode=embedded_page \ --data-urlencode "return_url=https://example.com/return" ``` ## Optional: 更新您的产品和价格 Stripe Tax 利用*产品* (Products represent what your business sells—whether that's a good or a service)和*价格* (Prices define how much and how often to charge for products. This includes how much the product costs, what currency to use, and the interval if the price is for subscriptions)上储存的信息来计算税额,例如*税务代码* (A tax code is the category of your product for tax purposes)和*税务行为* (Tax behavior determines whether you want to include taxes in the price ("inclusive") or add them on top ("exclusive"))。如果您未明确指定这些配置,Stripe Tax 将使用在[税务设置](https://dashboard.stripe.com/settings/tax)中选择的默认税务代码。 更多信息,请参阅[指定产品税号和纳税行为](https://docs.stripe.com/tax/products-prices-tax-codes-tax-behavior.md)。 ## Optional: 为现有客户计税 要在现有客户的 Checkout 会话上计算税费,请在您创建会话时将 `automatic_tax.enabled` 参数设置为 true。您可以根据客户现有地址或您在结账时收集的新地址来计算税费: > #### 使用 Accounts v2 API 表示客户 > > Accounts v2 API 通常面向 Connect 用户开放,并对其他 Stripe 用户开放公开预览。如果您参与了 Accounts v2 预览,您需要在代码中[指定预览版本](https://docs.stripe.com/api-v2-overview.md#sdk-and-api-versioning)。 > > 如需申请 Accounts v2 预览版的访问权限, > > 在大多数应用场景下,我们建议[将您的客户建模为客户配置的 Account 对象](https://docs.stripe.com/connect/use-accounts-as-customers.md),而不是使用 [Customer](https://docs.stripe.com/api/customers.md) 对象。 ### 用客户上的现有地址来计税 如果您已经收集了现有客户的地址,您可以基于这些地址而非结账时收集的地址来进行税费计算: #### 账户 v2 如果有,Checkout 会使用客户的 [configuration.customer.shipping.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-configuration-customer-shipping-address) 计算税费。否则,它会使用客户的账单地址 ([identity.individual.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-identity-individual-address) 或 [identity.business_details.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-identity-business_details-address))。您可以通过检查客户保存地址的 [configuration.customer.capabilities.automatic_indirect_tax.status](https://docs.stripe.com/api/v2/core/accounts/retrieve.md#v2_retrieve_accounts-response-configuration-customer-capabilities-automatic_indirect_tax-status) 是否为 `active`,来验证这些地址是否有效。此属性仅在您通过将 [configuration.customer.capabilities.automatic_indirect_tax.requested](https://docs.stripe.com/api/v2/core/accounts/create.md#v2_create_accounts-configuration-customer-capabilities-automatic_indirect_tax-requested) 设置为 true 来请求该功能时才可用。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price]={{PRICE_ID}}" \ -d "line_items[0][quantity]=2" \ -d "automatic_tax[enabled]=true" \ -d "customer_account={{CUSTOMERACCOUNT_ID}}" \ -d mode=payment \ -d ui_mode=embedded_page \ --data-urlencode "return_url=https://example.com/return" ``` #### Customers v1 如果有,Checkout 会使用客户的 [shipping.address ](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) 计算税费。否则,它会使用客户的账单地址 ([address](https://docs.stripe.com/api/customers/object.md#customer_object-address)) 计算税费。您可以通过检查客户保存地址的 [tax.automatic_tax](https://docs.stripe.com/api/customers/object.md#customer_object-tax-automatic_tax) 属性,验证这些地址是否有效。如果 `tax.automatic_tax` 是 `supported` 或 `not_collecting`,则客户保存的地址有效,并且您可以在 Checkout 会话中为该客户启用 Stripe Tax。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price]={{PRICE_ID}}" \ -d "line_items[0][quantity]=2" \ -d "automatic_tax[enabled]=true" \ -d "customer={{CUSTOMER_ID}}" \ -d mode=payment \ -d ui_mode=embedded_page \ --data-urlencode "return_url=https://example.com/return" ``` ### 用结账过程中收集的地址计税 可以通过配置 Checkout 来保存客户的新账单地址或收货地址。这种情况下,Checkout 使用结账过程中输入的地址来计算税额。 #### 账户 v2 如果您[收集收货地址](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection),Checkout 将把在会话时输入的收货地址保存至客户的 [configuration.customer.shipping](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-configuration-customer-shipping) 属性,并用它来计算税费。否则,Checkout 会将会话时输入的账单地址保存至客户的 [identity.individual.address](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-identity-individual-address) 属性,并用它来计算税费。在这两种情况下,结账时输入的地址都会替换任何现有地址。 如果您通过 Checkout 收集收货地址,请将 `customer_update.shipping` 属性设置为 `auto`。这会自动将来自 Checkout 的收货信息复制到客户的 `Account` 中。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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" ``` 如果您未通过 Checkout 收集收货地址,并且希望用结账时输入的账单地址计算税费,则您必须将账单地址保存至客户。请将 `customer_update.address` 属性设置为 `auto`,以自动将输入的地址复制到客户的 `Account` 中。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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 mode=payment \ -d ui_mode=embedded_page \ --data-urlencode "return_url=https://example.com/return" ``` #### Customers v1 如果您[收集收货地址](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-shipping_address_collection),Checkout 会将会话时输入的收货地址保存至客户的 [shipping.address](https://docs.stripe.com/api/customers/object.md#customer_object-shipping-address) 属性,并用它来计算税费。否则,Checkout 会将会话时输入的账单地址保存至客户的 [address](https://docs.stripe.com/api/customers/object.md#customer_object-address) 属性,并用它来计算税费。在这两种情况下,结账时输入的地址都会替换任何现有地址。 如果您通过 Checkout 收集收货地址,请将 `customer_update.shipping` 属性设置为 `auto`。这会自动将输入的收货信息从 Checkout 复制到 `Customer`。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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" ``` 如果未通过 Checkout 收集收货地址,并且希望用结账时输入的账单地址计算税费,则您必须将账单地址保存至客户。请将 `customer_update.address` 属性设置为 `auto`,以自动将输入的地址复制到 `Customer`。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -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 mode=payment \ -d ui_mode=embedded_page \ --data-urlencode "return_url=https://example.com/return" ``` ## Optional: 查看响应 要查看最近的税额计算结果,可以查看 Checkout Session 资源中的 [total_details.amount_tax](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-total_details) 属性,其中会显示计算的税额。此外,您可以用[管理平台](https://dashboard.stripe.com/)来查看计算的每笔付款的税额。