# スタンドアロン Tax API Tax Calculations および Transactions API を直接使用して、配送、内税価格などを処理できます。 スタンドアロン Tax API を使用すると、税金の計算、トランザクションの記録、差戻しの処理を直接行えます。[PaymentIntents](https://docs.stripe.com/tax/payment-intent.md) との併用や、[Stripe 外](https://docs.stripe.com/tax/off-stripe.md)での決済処理時に使用してください。Tax Calculations および Transactions API を使用する際に利用できる機能は次のとおりです。 ## Optional: 配送料金の税金を計算する [サーバー側] 配送料金の税金を計算するには、`shipping_cost` パラメーターを使用します。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer_details[address][line1]=920 5th Ave" \ -d "customer_details[address][city]=Seattle" \ -d "customer_details[address][state]=WA" \ -d "customer_details[address][postal_code]=98104" \ -d "customer_details[address][country]=US" \ -d "customer_details[address_source]=shipping" \ -d "shipping_cost[amount]=500" \ -d "shipping_cost[tax_code]=txcd_92010001" ``` 既存の [ShippingRate](https://docs.stripe.com/api/shipping_rates/object.md) の ID を渡して、その `amount`、`課税する tax_code`、`課税する tax_behavior` を使用します。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer_details[address][line1]=920 5th Ave" \ -d "customer_details[address][city]=Seattle" \ -d "customer_details[address][state]=WA" \ -d "customer_details[address][postal_code]=98104" \ -d "customer_details[address][country]=US" \ -d "customer_details[address_source]=shipping" \ -d "shipping_cost[shipping_rate]=shr_1Mlh8YI6rIcR421eUr9SJzAD" ``` ## Optional: IP アドレスを使用して税金を見積もる [サーバー側] 顧客の [IP アドレス](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-customer_details-ip_address) を指定すると、Stripe はその地理的な位置を特定し、その場所を顧客の所在地として使用します。これにより、顧客が郵便番号を入力する前に税金の見積もりを表示できます。 > IP アドレスの場所は顧客の実際の場所から離れている可能性があるため、徴収する *最終的な* 税額を決定するのに IP アドレスを使用することはお勧めしません。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer_details[ip_address]=127.0.0.1" ``` ## Optional: 顧客の納税者番号を収集 [サーバー側] 国外へのサービスの提供など、顧客に [リバースチャージ](https://docs.stripe.com/tax/zero-tax.md#reverse-charges) に基づく税金の必要が生じる場合があります。税金を回収せず、代わりに「差戻し請求で支払われる税金」という文言を指定して請求書を発行する必要があります。これにより、購入に関連する納税が顧客の責任であることを顧客に伝えることができます。 顧客の[納税者番号](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-customer_details-tax_ids)を指定して、リバースチャージが適用される状況を自動的に判別するには、以下のようにします。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer_details[address][country]=IE" \ -d "customer_details[address_source]=billing" \ -d "customer_details[tax_ids][0][type]=eu_vat" \ -d "customer_details[tax_ids][0][value]=DE123456789" ``` 無効な形式の納税者番号を指定すると、計算で `tax_id_invalid` エラーコードが返されます。 ```json { "error": { "code": "tax_id_invalid", "doc_url": "https://docs.stripe.com/error-codes#tax-id-invalid", "message": "Invalid value for eu_vat.", "param": "customer_details[tax_ids][0][value]", "type": "invalid_request_error" } } ``` Tax API では、納税者番号を政府のデータベースで自動的に検証しません。税金の計算前に納税者番号を検証するには、[customer tax ID validation](https://docs.stripe.com/billing/customer/tax-ids.md#validation) を使用する必要があります。 ## Optional: 内税価格 [サーバー側] デフォルトでは、指定したライン項目と配送料の金額に加算して税金が計算されます。価格に含まれる税金を計算するには、[line item](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-line_items-tax_behavior) または [shipping cost](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-shipping_cost-tax_behavior) の `tax_behavior` を `inclusive` に設定します。 以下の例では、顧客は常に 100 EUR を決済します。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=eur \ -d "line_items[0][amount]=10000" \ -d "line_items[0][reference]=L1" \ -d "line_items[0][tax_behavior]=inclusive" \ -d "line_items[0][tax_code]=txcd_10103000" \ -d "customer_details[address][country]=IE" \ -d "customer_details[address_source]=billing" ``` レスポンスでは税込み価格が返されます。 ```json { ... "amount_total": 10000, ... "tax_amount_exclusive": 0,"tax_amount_inclusive": 1870, "tax_breakdown": [ { "amount": 1870, "inclusive": true, "tax_rate_details": { "country": "IE", "percentage_decimal": "23.0", "state": null, "tax_type": "vat" }, "taxability_reason": "standard_rated", "taxable_amount": 8130 } ], ... } ``` ## Optional: 既存の Product オブジェクトを使用する [サーバー側] 各ライン項目に [Product](https://docs.stripe.com/api/products/object.md) オブジェクトを指定できます。商品に [tax_code](https://docs.stripe.com/api/products/object.md#product_object-tax_code) がある場合、まだ入力されていない場合はライン項目の `tax_code` として使用されます。`tax_behavior` や `price` など、他の商品の値は税金計算時に使用されません。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "line_items[0][product]={{PRODUCT_ID}}" \ -d "customer_details[address][country]=IE" \ -d "customer_details[address_source]=billing" ``` ## Optional: 既存の Account または Customer を使用する [サーバー側] 税金計算では、顧客データの利用可能状況に応じて、関連する [Customer](https://docs.stripe.com/api/customers/object.md) の住所と税務 ID が自動的に使用されます。 - 顧客の配送先住所が計算の `customer_details.address` に入力されます。 - それ以外の場合は、顧客の住所が計算の `customer_details.address` に入力されます。 - 顧客の IP アドレスが計算の `customer_details.ip_address` に入力されます。 - 顧客に非課税が設定されている場合、計算の `customer_details.taxability_override` に入力されます。 - 顧客の税務 ID が計算の `customer_details.tax_ids` に入力されます。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer={{CUSTOMER_ID}}" ``` ## Optional: 顧客の課税対象を上書きする [サーバー側] 顧客が非課税である場合など、特定のケースでは税金を徴収する必要はありません。[taxability_override](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-customer_details-taxability_override) パラメーターを使用して、Stripe Tax に税金免除を指定できます。 顧客の課税対象の上書きを計算に指定するには、以下のようにします。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer_details[address][line1]=920 5th Ave" \ -d "customer_details[address][city]=Seattle" \ -d "customer_details[address][state]=WA" \ -d "customer_details[address][postal_code]=98104" \ -d "customer_details[address][country]=US" \ -d "customer_details[address_source]=billing" \ -d "customer_details[taxability_override]=customer_exempt" ``` ### リバースチャージ 欧州連合などの一部の地域は、顧客がビジネスとして購入する場合に課税対象となる「リバースチャージ」スキームを実装しています。Stripe Tax が正確な税金処理を適用できるように、顧客から [Tax IDs](https://docs.stripe.com/tax/standalone-tax-api.md#tax-ids) を収集することをお勧めします。顧客の納税者番号を収集できない場合や、リバースチャージスキームの適用を別途決定している場合があります。そのような場合は、`taxability_override` を使用して、Stripe Tax でリバースチャージスキームを強制的に適用できます。 顧客の課税対象の上書きを計算に指定するには、以下のようにします。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=eur \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer_details[address][country]=IE" \ -d "customer_details[address_source]=billing" \ -d "customer_details[taxability_override]=reverse_charge" ``` ## Optional: 出荷元住所を指定する [サーバー側] 主たるビジネス拠点以外の場所から商品を配送する場合、配送元住所を登録して税金計算に使用できます。 発送元の所在地を指定するには、`ship_from_details` パラメータを使用します。この例では、ユーザーはフロリダ州に拠点を置き、顧客はイリノイ州スプリングフィールドにおり、商品はイリノイ州ネイパービルから発送されています。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "line_items[0][tax_behavior]=exclusive" \ -d "line_items[0][tax_code]=txcd_99999999" \ -d "customer_details[address][city]=Springfield" \ -d "customer_details[address][state]=IL" \ -d "customer_details[address][postal_code]=62704" \ -d "customer_details[address][country]=US" \ -d "customer_details[address_source]=billing" \ -d "ship_from_details[address][city]=Naperville" \ -d "ship_from_details[address][state]=IL" \ -d "ship_from_details[address][postal_code]=60540" \ -d "ship_from_details[address][country]=US" ``` このレスポンスでは、配送先 (イリノイ州スプリングフィールド) または売り手のビジネス拠点ではなく、注文の配送元 (イリノイ州ネイパービル) に基づいて計算された税金が返されます。 ```json { ... "amount_total": 1078, ... "tax_amount_exclusive": 78, ... "tax_breakdown": [ { "amount": 78, "inclusive": true,"tax_rate_details": { "country": "US", "percentage_decimal": "7.75", "state": "IL", "tax_type": "sales_tax" }, "taxability_reason": "standard_rated", "taxable_amount": 1000 } ], ... } ``` これらのシナリオにおける税金の計算方法については、[Stripe Tax のドキュメント ](https://docs.stripe.com/tax/calculating.md) をご覧ください。 ## Optional: 小売業配送手数料の計算 [サーバー側] Stripe Tax は、ミネソタ州とコロラド州の小売業配送手数料の計算をサポートしています。 サポートされている州で `state_retail_delivery_fee` タイプの税務登録を追加すると、小売業の配送手数料が税金計算で計算されます。 ```curl curl https://api.stripe.com/v1/tax/registrations \ -u "<>:" \ -d country=US \ -d "country_options[us][state]=CO" \ -d "country_options[us][type]=state_retail_delivery_fee" \ -d active_from=now ``` 小売業の配送手数料を計算するには、衣料品と履物を表す `txcd_30011000` などの [物品商品税コード](https://docs.stripe.com/tax/tax-codes.md?type=physical) を使用して税金計算 API を呼び出します。 すべての物品が小売業の配送手数料の計算をトリガーするわけではありません。税金が適用されるタイミングについては、州のドキュメントをご覧ください。 - [小売配送手数料 — コロラド州](https://docs.stripe.com/tax/supported-countries/united-states/collect-tax.md?tax-jurisdiction-united-states=colorado#other-taxes) - [小売配送手数料 — ミネソタ州](https://docs.stripe.com/tax/supported-countries/united-states/collect-tax.md?tax-jurisdiction-united-states=minnesota#other-taxes) ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "line_items[0][tax_behavior]=exclusive" \ -d "line_items[0][tax_code]=txcd_30011000" \ -d "shipping_cost[amount]=400" \ -d "customer_details[address][line1]=1437 Bannock St Room 451" \ -d "customer_details[address][city]=Springfield" \ -d "customer_details[address][state]=CO" \ -d "customer_details[address][postal_code]=80202" \ -d "customer_details[address][country]=US" \ -d "customer_details[address_source]=shipping" ``` レスポンスは、コロラド州の小売業配送手数料で計算された税金を返します。これは `tax_breakdown` オブジェクトの追加エントリーであり、`tax_breakdown.tax_rate_details.rate_type` は `flat_amount` に設定されています。 ```json { ... "amount_total": 2165, ... "tax_amount_exclusive": 165, ... "tax_breakdown": [ { "amount": 88, "inclusive": false, "tax_rate_details": { "percentage_decimal": "8.81", "rate_type": "percentage", "tax_type": "sales_tax", ... }, "taxability_reason": "standard_rated", "taxable_amount": 1000 }, ... { "amount": 29, "inclusive": false,"tax_rate_details": { "flat_amount": { "amount": 29, "currency": "usd" }, "percentage_decimal": "0.0", "rate_type": "flat_amount", "tax_type": "retail_delivery_fee", ... }, "taxability_reason": "standard_rated", "taxable_amount": 1000 } ], ... } ``` ## Optional: ライン項目の詳細な税金の内訳 [サーバー側] 最上位の [tax_breakdown](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-tax_breakdown) は常に返され、Checkout 時または領収書に税金のリストを表示するのに適したシンプルな内訳が表示されます。 [taxability_reason](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown-taxability_reason) を使用して、導入の構築時に税金が適用されない理由を把握できます。たとえば、`not_collecting` では、税金を徴収する国または州で税金が徴収されません。アカウント設定に [tax registrations](https://docs.stripe.com/tax/set-up.md#add-registrations) を追加すると、Stripe に税金を徴収する場所が示されます。ワシントン州の登録を追加した場合、結果に表示される課税対象の理由は `standard_rated` になり、これは商品が標準税率で課税されることを示します。 ライン項目の [tax_breakdown](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown) 属性を展開すると、地方税や各税金の理由を説明する属性など、詳細な内訳が表示されます。 - [課税する](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown-tax_rate_details) `rate_details` の tax_type フィールドは、課税する税金の種類を示す上位レベルであり、レポートや取引のエクスポートで返されるタイプとは必ずしも一致しない場合があります。たとえば、アメリカ売上税とアメリカ使用税を区別しません。 - Checkout フローの [tax_rate_details](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown-tax_rate_details) の `display_name` フィールドを使用して、すべての税金を表示します。税金は、顧客の場所と商品の税金情報に基づいてローカライズされます。例えば、[txcd_10103001: Software as a Service (SaaS) for Business Use](https://docs.stripe.com/tax/tax-codes.md?tax_code=txcd_10103001) のように、顧客がドイツに所在して、商品が仕向地で課税されるため、ドイツに VAT が適用される場合、`Umsatzsteuer (USt)`と表示されます。これは、VAT のドイツ語表記です。[txcd_20030000: General - Services](https://docs.stripe.com/tax/tax-codes.md?tax_code=txcd_20030000) のように、本社の住所がフランスに設定され、商品が起点で課税されるため、フランスに VAT が適用される場合、`Taxe sur la valeur ajoutée (TVA)` と表示されます。これは、VAT のフランス語表記です。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "customer_details[address][line1]=920 5th Ave" \ -d "customer_details[address][city]=Seattle" \ -d "customer_details[address][state]=WA" \ -d "customer_details[address][postal_code]=98104" \ -d "customer_details[address][country]=US" \ -d "customer_details[address_source]=shipping" \ -d "expand[0]=line_items.data.tax_breakdown" ``` ```json { ... "tax_breakdown": [ { "amount": 103, "inclusive": false, "tax_rate_details": { "country": "US", "percentage_decimal": "10.25", "state": "WA", "tax_type": "sales_tax" },"taxability_reason": "standard_rated", "taxable_amount": 1000 } ], "line_items": { "object": "list", "data": [ { "id": "tax_li_O84jA8hvV7ZyAa", "object": "tax.calculation_line_item", "amount": 1000, "amount_tax": 103, "product": null, "quantity": 1, "reference": "L1", "tax_behavior": "exclusive", "tax_breakdown": [ { "amount": 65, "jurisdiction": { "country": "US", "display_name": "Washington", "level": "state", "state": "WA" }, "sourcing": "destination", "tax_rate_details": { "display_name": "Retail Sales and Use Tax", "percentage_decimal": "6.5", "tax_type": "sales_tax" },"taxability_reason": "standard_rated", "taxable_amount": 1000 }, { "amount": 0, "jurisdiction": { "country": "US", "display_name": "KING", "level": "county", "state": "WA" }, "sourcing": "destination", "tax_rate_details": null,"taxability_reason": "not_subject_to_tax", "taxable_amount": 0 }, { "amount": 22, "jurisdiction": { "country": "US", "display_name": "SEATTLE", "level": "city", "state": "WA" }, "sourcing": "destination", "tax_rate_details": { "display_name": "Local Sales and Use Tax", "percentage_decimal": "2.2", "tax_type": "sales_tax" },"taxability_reason": "standard_rated", "taxable_amount": 1000 }, { "amount": 14, "jurisdiction": { "country": "US", "display_name": "REGIONAL TRANSIT AUTHORITY", "level": "district", "state": "WA" }, "sourcing": "destination", "tax_rate_details": { "display_name": "Local Sales and Use Tax", "percentage_decimal": "1.4", "tax_type": "sales_tax" },"taxability_reason": "standard_rated", "taxable_amount": 1000 }, { "amount": 2, "jurisdiction": { "country": "US", "display_name": "SEATTLE TRANSPORTATION BENEFIT DISTRICT", "level": "district", "state": "WA" }, "sourcing": "destination", "tax_rate_details": { "display_name": "Local Sales and Use Tax", "percentage_decimal": "0.15", "tax_type": "sales_tax" },"taxability_reason": "standard_rated", "taxable_amount": 1000 } ], "tax_code": "txcd_10000000" } ], "has_more": false, "total_count": 1, "url": "/v1/tax/calculations/taxcalc_1NLoZvBUZ691iUZ4z4cTW6tQ/line_items" }, ... } ``` ## Optional: 一般的なエラーのトラブルシューティング [サーバー側] 税務インテグレーションのエラーをトラブルシューティングするには、以下のステップに従います。 ### 無効な課税するコードのエラーを解決する `Invalid tax code` エラーが表示された場合は、[Product tax codes](https://docs.stripe.com/tax/tax-codes.md) を参照して、利用可能な税コードのリストを確認してください。次に、以下の手順に従って問題を解決します。 1. **税コードを確認する**: [利用可能な税コードのリスト](https://docs.stripe.com/tax/tax-codes.md) から、有効な税コードを使用していることを確認してください。よくある間違いは次のとおりです。 - 課税するコードとして空の文字列または `null` を使用する - 税コードのスペルミス - 存在しない課税するコードを使用する 1. **コードを更新**: `TaxCalculation` を作成する際には、必ず有効な課税コードを渡してください。以下に例を示します。 ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]=1000" \ -d "line_items[0][reference]=L1" \ -d "line_items[0][tax_code]=txcd_10000000" \ -d "customer_details[address][line1]=354 Oyster Point Blvd" \ -d "customer_details[address][city]=South San Francisco" \ -d "customer_details[address][state]=CA" \ -d "customer_details[address][postal_code]=94080" \ -d "customer_details[address][country]=US" \ -d "customer_details[address_source]=shipping" ``` 1. **デフォルトの税コードを使用**: Stripe Tax は、商品または税金計算リクエストに特定の税コードが指定されていない場合、計算にデフォルトの税コードを使用します。税金設定でデフォルト値を表示および更新できます。 API を使用して、デフォルトの税コードを更新します。 ```curl curl https://api.stripe.com/v1/tax/settings \ -u "<>:" \ -d "defaults[tax_code]=txcd_10000000" ``` 1. **商品カタログのレビュー**: Stripe 商品カタログの商品に関連付けられた税コードを使用する場合は、税コードが商品に正しく割り当てられていることを確認してください。 1. **データの不整合の確認**: 税コードがデータベースまたはフロントエンドから、Stripe への API コールを行うサーバー側のコードに正しく渡されることを確認します。 課税する税額を正確に計算するには、商品またはサービスに適用される最も具体的な税コードを使用します。課税するコードが不明な場合は、[課税する税コードのドキュメント](https://docs.stripe.com/tax/tax-codes.md) をご覧ください。 問題が続く場合は、[課税する API ドキュメント](https://docs.stripe.com/api/tax/settings.md) をレビューしてください。 ## See also - [PaymentIntents を使用した Stripe Tax](https://docs.stripe.com/tax/payment-intent.md) - [Stripe 外部での決済](https://docs.stripe.com/tax/off-stripe.md) - [税計算 API](https://docs.stripe.com/api/tax/calculations/create.md) - [レポートと申告](https://docs.stripe.com/tax/reports.md)