# Steuern einziehen Verwenden Sie Stripe Tax APIs, um Steuerberechnungen in Ihrer benutzerdefinierten Integration zu implementieren. Mit den Stripe Tax APIs können Sie Steuern in nutzerdefinierten Zahlungsabläufen berechnen. Nachdem Ihr Kunde/Ihre Kundin die Zahlung abgeschlossen hat, zeichnen Sie die Transaktion auf, damit sie im Stripe Tax-Bericht angezeigt wird. In den Beispielen in diesem Leitfaden werden Stripe-APIs für Zahlungen verwendet. Sie können jedoch die Tax API mit jedem beliebigen Zahlungsdienstleister oder mehreren Zahlungsdienstleistern verwenden. Für die meisten Integrationen empfehlen wir die Verwendung der [Checkout Sessions API mit Stripe Tax](https://docs.stripe.com/payments/advanced/tax.md). Alternativ können Sie Stripe Tax mit [Payment Links](https://docs.stripe.com/payment-links.md), [Checkout](https://docs.stripe.com/checkout/quickstart.md), [Billing](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md) und [Invoicing](https://docs.stripe.com/invoicing/no-code-guide.md) ohne Code oder mit Low-Code integrieren. Mit den Stripe Tax APIs können Sie Steuern in nutzerdefinierten Zahlungsabläufen berechnen. Nachdem Ihr Kunde/Ihre Kundin die Zahlung abgeschlossen hat, zeichnen Sie die Transaktion auf, damit sie im Stripe Tax-Bericht angezeigt wird. In den Beispielen in diesem Leitfaden werden Stripe-APIs für Zahlungen verwendet. Sie können jedoch die Tax API mit jedem beliebigen Zahlungsdienstleister oder mehreren Zahlungsdienstleistern verwenden. Wenn Ihr benutzerdefinierter Zahlungsablauf die [Payment Intents API](https://docs.stripe.com/api/payment_intents.md) verwendet, lesen Sie den Abschnitt [Steuern in Ihren benutzerdefinierten Zahlungsabläufen berechnen](https://docs.stripe.com/tax/payment-intent.md). Diese Integration befindet sich in der [öffentlichen Vorschau](https://docs.stripe.com/release-phases.md) und bietet Unterstützung für Belege und das Dashboard. Alternativ können Sie Stripe Tax mit [Payment Links](https://docs.stripe.com/tax/payment-links.md), [Checkout](https://docs.stripe.com/tax/checkout.md), [Billing](https://docs.stripe.com/tax/subscriptions.md) und [Invoicing](https://docs.stripe.com/tax/invoicing.md) ohne Code oder mit Low-Code integrieren. Ein Diagramm, das eine allgemeine Übersicht über die Integration der Tax API bietet (See full diagram at https://docs.stripe.com/tax/custom) ## Jetzt starten Dieses kurze Video zeigt eine Integration der Stripe Tax API, die die Payment Intents API und das Payment Element verwendet. [Watch on YouTube](https://www.youtube.com/watch?v=OfHJiC9Iek0) ## Registrierungen hinzufügen Stripe Tax berechnet Steuern nur in Ländern, in denen Sie für den Einzug von Steuern registriert sind. Sie müssen [Ihre Registrierungen im Dashboard hinzufügen](https://docs.stripe.com/tax/registering.md#add-a-registration). ## Optional: Kundenadresse erfassen [Clientseitig] Die von Ihnen erhobene Steuer hängt in der Regel vom Standort Ihrer Kundin oder Ihres Kunden ab. Um die Steuer möglichst genau zu berechnen, erfassen Sie die vollständige Adresse Ihrer Kundin oder Ihres Kunden. Bevor Sie eine Adresse erfassen, können Sie Ihrer Kundin oder Ihrem Kunden eine Schätzung auf der Grundlage der jeweiligen [IP-Adresse](https://docs.stripe.com/tax/custom.md#ip-address) anzeigen. > Die folgenden Beispiele verwenden ein einfaches benutzerdefiniertes Adressformular, aber Sie können auch das [Adresselement](https://docs.stripe.com/elements/address-element.md) verwenden, um Kundenadressen mit Autovervollständigungs- und Lokalisierungsfunktionen zu erfassen. Das folgende Formular erfasst eine vollständige Postanschrift: ```html
``` Sie können die Adresse wie folgt an Ihren Server-Endpoint übergeben: ```js const address = { line1: document.getElementById('address_line1').value, city: document.getElementById('address_city').value, state: document.getElementById('address_state').value, postal_code: document.getElementById('address_postal_code').value, country: document.getElementById('address_country').value, }; var response = fetch('/preview-cart', { method: 'POST', body: JSON.stringify({address: address}), headers: {'Content-Type': 'application/json'}, }).then(function(response) { return response.json(); }).then(function(responseJson) { // Handle errors, or display calculated tax to your customer. }); ``` Die für die Steuerberechnung erforderlichen Adressdaten [variieren je nach Land der Kundin oder des Kunden](https://docs.stripe.com/tax/customer-locations.md#supported-formats): - **Vereinigte Staaten**: Wir benötigen mindestens die Postleitzahl Ihrer Kundinnen und Kunden. Für eine möglichst genaue Steuerberechnung empfehlen wir die Angabe einer vollständigen Adresse. - **Kanada**: Wir benötigen die Postleitzahl oder die Provinz Ihrer Kundin oder Ihres Kunden. - **Andere Länder**: Wir benötigen nur den Ländercode Ihrer Kundin oder Ihres Kunden. ## Steuer berechnen [Serverseitig] Sie entscheiden, wann und wie oft Sie [Steuern berechnen](https://docs.stripe.com/api/tax/calculations/create.md). Zum Beispiel können Sie Folgendes tun: - Zeigen Sie eine Steuerschätzung [basierend auf der IP-Adresse Ihrer Kundin oder Ihres Kunden](https://docs.stripe.com/tax/custom.md#ip-address) an, wenn Ihre Kundin oder Ihr Kunde den Bezahlvorgang beginnt. - Neuberechnung der Steuer, wenn Ihr/e Kunde/Kundin seine/ihre Rechnungs- oder Lieferadresse eingibt - Berechnen Sie den endgültigen Steuerbetrag, der zu erheben ist, wenn Ihr/e Kunde/Kundin die Eingabe seiner/ihrer Adresse abgeschlossen hat. Stripe [erhebt eine Gebühr](https://stripe.com/tax/pricing) pro API-Aufruf zur Steuerberechnung. Sie können die API-Aufrufe zur Steuerberechnung drosseln, um Ihre Kosten zu verwalten. Die folgenden Beispiele zeigen, wie Steuern in verschiedenen Szenarien berechnet werden. Stripe Tax berechnet nur Steuern in Zuständigkeitsbereichen, in denen Sie für den Steuereinzug registriert sind. Sie müssen dazu im Dashboard [Ihre Registrierungen hinzufügen](https://docs.stripe.com/tax/registering.md#add-a-registration). #### Beispiel - Vereinigte Staaten: Steuerausschließlichkeitsposten In diesem Beispiel wird die Steuer für eine US-Versandadresse berechnet. Der Posten hat einen Preis von 10 USD und verwendet den [voreingestellten Steuercode](https://docs.stripe.com/tax/set-up.md#preset-tax-code) Ihres Kontos. ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": { "address": { "line1": "920 5th Ave", "city": "Seattle", "state": "WA", "postal_code": "98104", "country": "US", }, "address_source": "shipping", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => [ 'address' => [ 'line1' => '920 5th Ave', 'city' => 'Seattle', 'state' => 'WA', 'postal_code' => '98104', 'country' => 'US', ], 'address_source' => 'shipping', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("920 5th Ave") .setCity("Seattle") .setState("WA") .setPostalCode("98104") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("920 5th Ave"), City: stripe.String("Seattle"), State: stripe.String("WA"), PostalCode: stripe.String("98104"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "920 5th Ave", City = "Seattle", State = "WA", PostalCode = "98104", Country = "US", }, AddressSource = "shipping", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` #### Beispiel - Vereinigte Staaten: mehrere Posten mit Versand Dieses Beispiel enthält mehrere Posten ohne Steuern sowie Versandkosten in Höhe von 5 USD. ```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_99999999 \ -d "line_items[1][amount]"=5000 \ -d "line_items[1][reference]"=L2 \ -d "line_items[1][tax_code]"=txcd_99999999 \ -d "line_items[2][amount]"=9999 \ -d "line_items[2][reference]"=L3 \ -d "line_items[2][tax_code]"=txcd_99999999 \ -d "shipping_cost[amount]"=500 \ -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 ``` ```cli stripe tax calculations create \ --currency=usd \ -d "line_items[0][amount]"=1000 \ -d "line_items[0][reference]"=L1 \ -d "line_items[0][tax_code]"=txcd_99999999 \ -d "line_items[1][amount]"=5000 \ -d "line_items[1][reference]"=L2 \ -d "line_items[1][tax_code]"=txcd_99999999 \ -d "line_items[2][amount]"=9999 \ -d "line_items[2][reference]"=L3 \ -d "line_items[2][tax_code]"=txcd_99999999 \ -d "shipping_cost[amount]"=500 \ -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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_code: 'txcd_99999999', }, { amount: 5000, reference: 'L2', tax_code: 'txcd_99999999', }, { amount: 9999, reference: 'L3', tax_code: 'txcd_99999999', }, ], shipping_cost: {amount: 500}, customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [ {"amount": 1000, "reference": "L1", "tax_code": "txcd_99999999"}, {"amount": 5000, "reference": "L2", "tax_code": "txcd_99999999"}, {"amount": 9999, "reference": "L3", "tax_code": "txcd_99999999"}, ], "shipping_cost": {"amount": 500}, "customer_details": { "address": { "line1": "920 5th Ave", "city": "Seattle", "state": "WA", "postal_code": "98104", "country": "US", }, "address_source": "shipping", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', 'tax_code' => 'txcd_99999999', ], [ 'amount' => 5000, 'reference' => 'L2', 'tax_code' => 'txcd_99999999', ], [ 'amount' => 9999, 'reference' => 'L3', 'tax_code' => 'txcd_99999999', ], ], 'shipping_cost' => ['amount' => 500], 'customer_details' => [ 'address' => [ 'line1' => '920 5th Ave', 'city' => 'Seattle', 'state' => 'WA', 'postal_code' => '98104', 'country' => 'US', ], 'address_source' => 'shipping', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .setTaxCode("txcd_99999999") .build() ) .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(5000L) .setReference("L2") .setTaxCode("txcd_99999999") .build() ) .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(9999L) .setReference("L3") .setTaxCode("txcd_99999999") .build() ) .setShippingCost( CalculationCreateParams.ShippingCost.builder().setAmount(500L).build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("920 5th Ave") .setCity("Seattle") .setState("WA") .setPostalCode("98104") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_code: 'txcd_99999999', }, { amount: 5000, reference: 'L2', tax_code: 'txcd_99999999', }, { amount: 9999, reference: 'L3', tax_code: 'txcd_99999999', }, ], shipping_cost: { amount: 500, }, customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), TaxCode: stripe.String("txcd_99999999"), }, &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(5000), Reference: stripe.String("L2"), TaxCode: stripe.String("txcd_99999999"), }, &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(9999), Reference: stripe.String("L3"), TaxCode: stripe.String("txcd_99999999"), }, }, ShippingCost: &stripe.TaxCalculationCreateShippingCostParams{Amount: stripe.Int64(500)}, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("920 5th Ave"), City: stripe.String("Seattle"), State: stripe.String("WA"), PostalCode: stripe.String("98104"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1", TaxCode = "txcd_99999999", }, new Stripe.Tax.CalculationLineItemOptions { Amount = 5000, Reference = "L2", TaxCode = "txcd_99999999", }, new Stripe.Tax.CalculationLineItemOptions { Amount = 9999, Reference = "L3", TaxCode = "txcd_99999999", }, }, ShippingCost = new Stripe.Tax.CalculationShippingCostOptions { Amount = 500 }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "920 5th Ave", City = "Seattle", State = "WA", PostalCode = "98104", Country = "US", }, AddressSource = "shipping", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` #### Beispiel - Vereinigte Staaten: Posten mit Menge In New York unterliegen Kleidungsstücke nicht der Verkaufssteuer, wenn jeder Artikel weniger als 110 USD kostet. In diesem Beispiel gibt es ein Kleidungsstück mit einem Gesamtpreis von 150 USD und einer Menge von 3. Das bedeutet, dass jedes Kleidungsstück 50 USD kostet und von der Umsatzsteuer befreit ist. ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=usd \ -d "line_items[0][amount]"=15000 \ -d "line_items[0][quantity]"=3 \ -d "line_items[0][reference]"=Clothing \ -d "line_items[0][tax_code]"=txcd_30011000 \ -d "shipping_cost[amount]"=500 \ -d "customer_details[address][state]"=NY \ -d "customer_details[address][postal_code]"=10001 \ -d "customer_details[address][country]"=US \ -d "customer_details[address_source]"=shipping ``` ```cli stripe tax calculations create \ --currency=usd \ -d "line_items[0][amount]"=15000 \ -d "line_items[0][quantity]"=3 \ -d "line_items[0][reference]"=Clothing \ -d "line_items[0][tax_code]"=txcd_30011000 \ -d "shipping_cost[amount]"=500 \ -d "customer_details[address][state]"=NY \ -d "customer_details[address][postal_code]"=10001 \ -d "customer_details[address][country]"=US \ -d "customer_details[address_source]"=shipping ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 15000, quantity: 3, reference: 'Clothing', tax_code: 'txcd_30011000', }, ], shipping_cost: {amount: 500}, customer_details: { address: { state: 'NY', postal_code: '10001', country: 'US', }, address_source: 'shipping', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [ { "amount": 15000, "quantity": 3, "reference": "Clothing", "tax_code": "txcd_30011000", }, ], "shipping_cost": {"amount": 500}, "customer_details": { "address": {"state": "NY", "postal_code": "10001", "country": "US"}, "address_source": "shipping", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 15000, 'quantity' => 3, 'reference' => 'Clothing', 'tax_code' => 'txcd_30011000', ], ], 'shipping_cost' => ['amount' => 500], 'customer_details' => [ 'address' => [ 'state' => 'NY', 'postal_code' => '10001', 'country' => 'US', ], 'address_source' => 'shipping', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(15000L) .setQuantity(3L) .setReference("Clothing") .setTaxCode("txcd_30011000") .build() ) .setShippingCost( CalculationCreateParams.ShippingCost.builder().setAmount(500L).build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setState("NY") .setPostalCode("10001") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 15000, quantity: 3, reference: 'Clothing', tax_code: 'txcd_30011000', }, ], shipping_cost: { amount: 500, }, customer_details: { address: { state: 'NY', postal_code: '10001', country: 'US', }, address_source: 'shipping', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(15000), Quantity: stripe.Int64(3), Reference: stripe.String("Clothing"), TaxCode: stripe.String("txcd_30011000"), }, }, ShippingCost: &stripe.TaxCalculationCreateShippingCostParams{Amount: stripe.Int64(500)}, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ State: stripe.String("NY"), PostalCode: stripe.String("10001"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 15000, Quantity = 3, Reference = "Clothing", TaxCode = "txcd_30011000", }, }, ShippingCost = new Stripe.Tax.CalculationShippingCostOptions { Amount = 500 }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { State = "NY", PostalCode = "10001", Country = "US", }, AddressSource = "shipping", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` #### Beispiel - Europa: Posten inklusive Steuern In diesem Beispiel wird die Steuer für eine Rechnungsadresse in Irland berechnet, wo die Steuer normalerweise in den Preisen für Nicht-Geschäftskundinnen und -kunden enthalten ist. Der Posten hat einen Preis von 29,99 EUR und verwendet das Steuerkennzeichen `txcd_10302000` (ebook). ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=eur \ -d "line_items[0][amount]"=2999 \ -d "line_items[0][reference]"=L1 \ -d "line_items[0][tax_behavior]"=inclusive \ -d "line_items[0][tax_code]"=txcd_10302000 \ -d "customer_details[address][country]"=IE \ -d "customer_details[address_source]"=billing ``` ```cli stripe tax calculations create \ --currency=eur \ -d "line_items[0][amount]"=2999 \ -d "line_items[0][reference]"=L1 \ -d "line_items[0][tax_behavior]"=inclusive \ -d "line_items[0][tax_code]"=txcd_10302000 \ -d "customer_details[address][country]"=IE \ -d "customer_details[address_source]"=billing ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 2999, reference: 'L1', tax_behavior: 'inclusive', tax_code: 'txcd_10302000', }, ], customer_details: { address: {country: 'IE'}, address_source: 'billing', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "eur", "line_items": [ { "amount": 2999, "reference": "L1", "tax_behavior": "inclusive", "tax_code": "txcd_10302000", }, ], "customer_details": {"address": {"country": "IE"}, "address_source": "billing"}, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'eur', 'line_items' => [ [ 'amount' => 2999, 'reference' => 'L1', 'tax_behavior' => 'inclusive', 'tax_code' => 'txcd_10302000', ], ], 'customer_details' => [ 'address' => ['country' => 'IE'], 'address_source' => 'billing', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("eur") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(2999L) .setReference("L1") .setTaxBehavior(CalculationCreateParams.LineItem.TaxBehavior.INCLUSIVE) .setTaxCode("txcd_10302000") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setCountry("IE") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 2999, reference: 'L1', tax_behavior: 'inclusive', tax_code: 'txcd_10302000', }, ], customer_details: { address: { country: 'IE', }, address_source: 'billing', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyEUR), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(2999), Reference: stripe.String("L1"), TaxBehavior: stripe.String("inclusive"), TaxCode: stripe.String("txcd_10302000"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{Country: stripe.String("IE")}, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "eur", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 2999, Reference = "L1", TaxBehavior = "inclusive", TaxCode = "txcd_10302000", }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Country = "IE" }, AddressSource = "billing", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` #### Beispiel - Europa: mehrere Posten mit Versand In diesem Beispiel wird die Steuer für eine Versandadresse in Irland berechnet, wo die Steuer in der Regel in den Preisen für Nicht-Geschäftskundinnen und -kunden enthalten ist. Der zu versendende Artikel hat einen Preis von 59,99 EUR und die Versandkosten betragen 5 EUR. Da beide Beträge inklusive Steuern sind, zahlt die Kundin oder der Kunde immer 64,99 EUR. ```curl curl https://api.stripe.com/v1/tax/calculations \ -u "<>:" \ -d currency=eur \ -d "line_items[0][amount]"=5999 \ -d "line_items[0][reference]"=L1 \ -d "line_items[0][tax_behavior]"=inclusive \ -d "line_items[0][tax_code]"=txcd_99999999 \ -d "shipping_cost[amount]"=500 \ -d "shipping_cost[tax_behavior]"=inclusive \ -d "customer_details[address][line1]"="123 Some House" \ -d "customer_details[address][city]"=Dublin \ -d "customer_details[address][country]"=IE \ -d "customer_details[address_source]"=shipping ``` ```cli stripe tax calculations create \ --currency=eur \ -d "line_items[0][amount]"=5999 \ -d "line_items[0][reference]"=L1 \ -d "line_items[0][tax_behavior]"=inclusive \ -d "line_items[0][tax_code]"=txcd_99999999 \ -d "shipping_cost[amount]"=500 \ -d "shipping_cost[tax_behavior]"=inclusive \ -d "customer_details[address][line1]"="123 Some House" \ -d "customer_details[address][city]"=Dublin \ -d "customer_details[address][country]"=IE \ -d "customer_details[address_source]"=shipping ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 5999, reference: 'L1', tax_behavior: 'inclusive', tax_code: 'txcd_99999999', }, ], shipping_cost: { amount: 500, tax_behavior: 'inclusive', }, customer_details: { address: { line1: '123 Some House', city: 'Dublin', country: 'IE', }, address_source: 'shipping', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "eur", "line_items": [ { "amount": 5999, "reference": "L1", "tax_behavior": "inclusive", "tax_code": "txcd_99999999", }, ], "shipping_cost": {"amount": 500, "tax_behavior": "inclusive"}, "customer_details": { "address": {"line1": "123 Some House", "city": "Dublin", "country": "IE"}, "address_source": "shipping", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'eur', 'line_items' => [ [ 'amount' => 5999, 'reference' => 'L1', 'tax_behavior' => 'inclusive', 'tax_code' => 'txcd_99999999', ], ], 'shipping_cost' => [ 'amount' => 500, 'tax_behavior' => 'inclusive', ], 'customer_details' => [ 'address' => [ 'line1' => '123 Some House', 'city' => 'Dublin', 'country' => 'IE', ], 'address_source' => 'shipping', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("eur") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(5999L) .setReference("L1") .setTaxBehavior(CalculationCreateParams.LineItem.TaxBehavior.INCLUSIVE) .setTaxCode("txcd_99999999") .build() ) .setShippingCost( CalculationCreateParams.ShippingCost.builder() .setAmount(500L) .setTaxBehavior(CalculationCreateParams.ShippingCost.TaxBehavior.INCLUSIVE) .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("123 Some House") .setCity("Dublin") .setCountry("IE") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 5999, reference: 'L1', tax_behavior: 'inclusive', tax_code: 'txcd_99999999', }, ], shipping_cost: { amount: 500, tax_behavior: 'inclusive', }, customer_details: { address: { line1: '123 Some House', city: 'Dublin', country: 'IE', }, address_source: 'shipping', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyEUR), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(5999), Reference: stripe.String("L1"), TaxBehavior: stripe.String("inclusive"), TaxCode: stripe.String("txcd_99999999"), }, }, ShippingCost: &stripe.TaxCalculationCreateShippingCostParams{ Amount: stripe.Int64(500), TaxBehavior: stripe.String(stripe.TaxCalculationShippingCostTaxBehaviorInclusive), }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("123 Some House"), City: stripe.String("Dublin"), Country: stripe.String("IE"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "eur", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 5999, Reference = "L1", TaxBehavior = "inclusive", TaxCode = "txcd_99999999", }, }, ShippingCost = new Stripe.Tax.CalculationShippingCostOptions { Amount = 500, TaxBehavior = "inclusive", }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "123 Some House", City = "Dublin", Country = "IE", }, AddressSource = "shipping", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` #### Beispiel - Absenderadresse Mit dieser Beta-Funktion werden Steuern auf Grundlage der Absenderadresse erhoben, wenn Sie in bestimmten Bundesstaaten (z. B. Illinois) eine Absenderadresse angeben und die Sendung physische Waren enthält. Enthält die Sendung sowohl physische Waren als auch Dienstleistungen, werden die Steuern für beides auf Basis der Absenderadresse berechnet. In diesem Beispiel wird die Steuer auf der Grundlage des Versandorts in Naperville, Illinois, berechnet, anstatt des Unternehmensstandorts (außerhalb von Illinois) und der Lieferadresse in Springfield, Illinois. ```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 "shipping_cost[amount]"=500 \ -d "shipping_cost[tax_behavior]"=exclusive \ -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 ``` ```cli stripe tax calculations create \ --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 "shipping_cost[amount]"=500 \ -d "shipping_cost[tax_behavior]"=exclusive \ -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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_behavior: 'exclusive', tax_code: 'txcd_99999999', }, ], shipping_cost: { amount: 500, tax_behavior: 'exclusive', }, customer_details: { address: { city: 'Springfield', state: 'IL', postal_code: '62704', country: 'US', }, address_source: 'billing', }, ship_from_details: { address: { city: 'Naperville', state: 'IL', postal_code: '60540', country: 'US', }, }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [ { "amount": 1000, "reference": "L1", "tax_behavior": "exclusive", "tax_code": "txcd_99999999", }, ], "shipping_cost": {"amount": 500, "tax_behavior": "exclusive"}, "customer_details": { "address": { "city": "Springfield", "state": "IL", "postal_code": "62704", "country": "US", }, "address_source": "billing", }, "ship_from_details": { "address": { "city": "Naperville", "state": "IL", "postal_code": "60540", "country": "US", }, }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', 'tax_behavior' => 'exclusive', 'tax_code' => 'txcd_99999999', ], ], 'shipping_cost' => [ 'amount' => 500, 'tax_behavior' => 'exclusive', ], 'customer_details' => [ 'address' => [ 'city' => 'Springfield', 'state' => 'IL', 'postal_code' => '62704', 'country' => 'US', ], 'address_source' => 'billing', ], 'ship_from_details' => [ 'address' => [ 'city' => 'Naperville', 'state' => 'IL', 'postal_code' => '60540', 'country' => 'US', ], ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .setTaxBehavior(CalculationCreateParams.LineItem.TaxBehavior.EXCLUSIVE) .setTaxCode("txcd_99999999") .build() ) .setShippingCost( CalculationCreateParams.ShippingCost.builder() .setAmount(500L) .setTaxBehavior(CalculationCreateParams.ShippingCost.TaxBehavior.EXCLUSIVE) .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setCity("Springfield") .setState("IL") .setPostalCode("62704") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .build() ) .setShipFromDetails( CalculationCreateParams.ShipFromDetails.builder() .setAddress( CalculationCreateParams.ShipFromDetails.Address.builder() .setCity("Naperville") .setState("IL") .setPostalCode("60540") .setCountry("US") .build() ) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_behavior: 'exclusive', tax_code: 'txcd_99999999', }, ], shipping_cost: { amount: 500, tax_behavior: 'exclusive', }, customer_details: { address: { city: 'Springfield', state: 'IL', postal_code: '62704', country: 'US', }, address_source: 'billing', }, ship_from_details: { address: { city: 'Naperville', state: 'IL', postal_code: '60540', country: 'US', }, }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), TaxBehavior: stripe.String("exclusive"), TaxCode: stripe.String("txcd_99999999"), }, }, ShippingCost: &stripe.TaxCalculationCreateShippingCostParams{ Amount: stripe.Int64(500), TaxBehavior: stripe.String(stripe.TaxCalculationShippingCostTaxBehaviorExclusive), }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ City: stripe.String("Springfield"), State: stripe.String("IL"), PostalCode: stripe.String("62704"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), }, ShipFromDetails: &stripe.TaxCalculationCreateShipFromDetailsParams{ Address: &stripe.AddressParams{ City: stripe.String("Naperville"), State: stripe.String("IL"), PostalCode: stripe.String("60540"), Country: stripe.String("US"), }, }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1", TaxBehavior = "exclusive", TaxCode = "txcd_99999999", }, }, ShippingCost = new Stripe.Tax.CalculationShippingCostOptions { Amount = 500, TaxBehavior = "exclusive", }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { City = "Springfield", State = "IL", PostalCode = "62704", Country = "US", }, AddressSource = "billing", }, }; options.AddExtraParam("ship_from_details[address][city]", "Naperville"); options.AddExtraParam("ship_from_details[address][state]", "IL"); options.AddExtraParam("ship_from_details[address][postal_code]", "60540"); options.AddExtraParam("ship_from_details[address][country]", "US"); var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` Die [Berechnungsantwort](https://docs.stripe.com/api/tax/calculations/object.md) enthält Beträge, die Sie Ihren Kundinnen und Kunden anzeigen und zur Zahlung verwenden können: | Attribut | Beschreibung | | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [amount_total](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-amount_total) | Die Gesamtsumme nach Berechnung der Steuer. Verwenden Sie diesen Wert, um den PaymentIntent-[Betrag](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-amount) festzulegen, der Ihrer Kundin oder Ihrem Kunden in Rechnung gestellt werden soll. | | [tax_amount_exclusive](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-tax_amount_exclusive) | Der Steuerbetrag, der zu den Beträgen Ihrer Posten und den Versandkosten hinzukommt. Dieser Steuerbetrag erhöht den `amount_total`. Verwenden Sie dies, um Ihrem Kunden/Ihrer Kundin den Steuerbetrag anzuzeigen, der zur Zwischensumme der Transaktion hinzugefügt wurde. | | [tax_amount_inclusive](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-tax_amount_inclusive) | Der Steuerbetrag, der in den Beträgen Ihrer Posten und den Versandkosten enthalten ist (wenn Sie Preise ohne Steuer verwenden). Dieser Steuerbetrag erhöht nicht den `amount_total`. Verwenden Sie dies, um Ihren Kundinnen und Kunden die in der Gesamtsumme enthaltene Steuer anzuzeigen. | | [tax_breakdown](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-tax_breakdown) | Eine Liste der Steuerbeträge, aufgeschlüsselt nach nationalen und bundesstaatlichen Steuersätzen. Damit können Sie Ihrer Kundschaft zeigen, welche Steuern Sie erheben. | ### Fehler bei Kundenstandorten behandeln Die Berechnung gibt den Fehlercode `customer_tax_location_invalid` zurück, wenn die Adresse Ihres Kunden/Ihrer Kundin ungültig oder nicht präzise genug ist, um die Steuer zu berechnen: ```json { "error": { "doc_url": "https://docs.stripe.com/error-codes#customer-tax-location-invalid","code": "customer_tax_location_invalid", "message": "We could not determine the customer's tax location based on the provided customer address.", "param": "customer_details[address]", "type": "invalid_request_error" } } ``` Wenn Sie diesen Fehler erhalten, bitten Sie Ihre Kundin oder Ihren Kunden, die eingegebene Adresse zu überprüfen und mögliche Tippfehler zu korrigieren. ### Berechnung mit einem anderen Abwickler verwenden Wenn Sie Transaktionen außerhalb von Stripe abwickeln, können Sie die folgenden Schritte überspringen und die Berechnung auf Ihre extern verarbeiteten Transaktionen anwenden. ## Steuertransaktion erstellen [Serverseitig] Bei der Erstellung einer Steuertransaktion wird die von Ihrer Kundin oder Ihrem Kunden erhobene Steuer aufgezeichnet, sodass Sie später [Exporte herunterladen und Berichte erstellen](https://docs.stripe.com/tax/reports.md), um Ihre Steuererklärung zu unterstützen. Sie können eine [Transaktion](https://docs.stripe.com/api/tax/transactions/create_from_calculation.md) aus einer Berechnung bis zum Zeitstempel [expires_at](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-expires_at), 90 Tage nach ihrer Einrichtung, erstellen. Verwendungsversuche nach diesem Zeitpunkt führen zu einem Fehler. > Die Transaktion gilt an dem Tag als wirksam, an dem `create_from_calculation` aufgerufen wird, und die Steuerbeträge werden nicht neu berechnet. Wenn Sie eine Steuertransaktion erstellen, müssen Sie eine eindeutige `reference` für die Steuertransaktion und jeden Posten angeben. Die Referenzen erscheinen in den Steuerexporten, um Ihnen zu helfen, die erhobene Steuer mit den Bestellungen in Ihrem System abzugleichen. Eine Steuertransaktion mit der Referenz `pi_123456789`, den Postenreferenzen `L1` und `L2` sowie den Versandkosten sieht in den Steuerexporten beispielsweise so aus: | ID | line_item_id | Typ | Währung | transaction_date | | ------------ | ------------ | ------ | ------- | ------------------- | | pi_123456789 | L1 | extern | usd | 2023-02-23 17:01:16 | | pi_123456789 | L2 | extern | usd | 2023-02-23 17:01:16 | | pi_123456789 | Versand | extern | usd | 2023-02-23 17:01:16 | Wenn Ihre Kundin oder Ihr Kunde zahlt, verwenden Sie die Berechnungs-ID, um die erhobene Steuer zu erfassen. Das können Sie auf zwei Arten tun: - Wenn Ihr Server über einen Endpunkt verfügt, an dem Ihre Kundin oder Ihr Kunde die Bestellung aufgibt, können Sie die Steuertransaktion erstellen, nachdem die Bestellung erfolgreich abgeschickt wurde. - Warten Sie auf das Webhook-Ereignis [payment_intent.succeeded](https://docs.stripe.com/api/events/types.md#event_types-payment_intent.succeeded). Rufen Sie die Berechnungs-ID aus den PaymentIntent-`metadata` ab. Im folgenden Beispiel wird eine Transaktion erstellt und die PaymentIntent-ID als eindeutige Referenz verwendet: ```curl curl https://api.stripe.com/v1/tax/transactions/create_from_calculation \ -u "<>:" \ -d calculation={{TAX_CALCULATION}} \ -d reference="{{PAYMENTINTENT_ID}}" \ -d "expand[]"=line_items ``` ```cli stripe tax transactions create_from_calculation \ --calculation={{TAX_CALCULATION}} \ --reference="{{PAYMENTINTENT_ID}}" \ -d "expand[0]"=line_items ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") transaction = client.v1.tax.transactions.create_from_calculation({ calculation: '{{TAX_CALCULATION}}', reference: '{{PAYMENTINTENT_ID}}', expand: ['line_items'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. transaction = client.v1.tax.transactions.create_from_calculation({ "calculation": "{{TAX_CALCULATION}}", "reference": "{{PAYMENTINTENT_ID}}", "expand": ["line_items"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $transaction = $stripe->tax->transactions->createFromCalculation([ 'calculation' => '{{TAX_CALCULATION}}', 'reference' => '{{PAYMENTINTENT_ID}}', 'expand' => ['line_items'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); TransactionCreateFromCalculationParams params = TransactionCreateFromCalculationParams.builder() .setCalculation("{{TAX_CALCULATION}}") .setReference("{{PAYMENTINTENT_ID}}") .addExpand("line_items") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Transaction transaction = client.v1().tax().transactions().createFromCalculation(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const transaction = await stripe.tax.transactions.createFromCalculation({ calculation: '{{TAX_CALCULATION}}', reference: '{{PAYMENTINTENT_ID}}', expand: ['line_items'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxTransactionCreateFromCalculationParams{ Calculation: stripe.String("{{TAX_CALCULATION}}"), Reference: stripe.String("{{PAYMENTINTENT_ID}}"), } params.AddExpand("line_items") result, err := sc.V1TaxTransactions.CreateFromCalculation(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.TransactionCreateFromCalculationOptions { Calculation = "{{TAX_CALCULATION}}", Reference = "{{PAYMENTINTENT_ID}}", Expand = new List { "line_items" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Transactions; Stripe.Tax.Transaction transaction = service.CreateFromCalculation(options); ``` Speichern Sie die [Steuertransaktions-ID](https://docs.stripe.com/api/tax/transactions/object.md#tax_transaction_object-id), um Rückerstattungen später zu dokumentieren. Sie können die Transaktions-ID in Ihrer Datenbank oder in den Metadaten des PaymentIntent speichern: ```curl curl https://api.stripe.com/v1/payment_intents/{{PAYMENTINTENT_ID}} \ -u "<>:" \ -d "metadata[tax_transaction]"={{TAX_TRANSACTION}} ``` ```cli stripe payment_intents update {{PAYMENTINTENT_ID}} \ -d "metadata[tax_transaction]"={{TAX_TRANSACTION}} ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") payment_intent = client.v1.payment_intents.update( '{{PAYMENTINTENT_ID}}', {metadata: {tax_transaction: '{{TAX_TRANSACTION}}'}}, ) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. payment_intent = client.v1.payment_intents.update( "{{PAYMENTINTENT_ID}}", {"metadata": {"tax_transaction": "{{TAX_TRANSACTION}}"}}, ) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $paymentIntent = $stripe->paymentIntents->update( '{{PAYMENTINTENT_ID}}', ['metadata' => ['tax_transaction' => '{{TAX_TRANSACTION}}']] ); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); PaymentIntentUpdateParams params = PaymentIntentUpdateParams.builder() .putMetadata("tax_transaction", "{{TAX_TRANSACTION}}") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. PaymentIntent paymentIntent = client.v1().paymentIntents().update("{{PAYMENTINTENT_ID}}", params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const paymentIntent = await stripe.paymentIntents.update( '{{PAYMENTINTENT_ID}}', { metadata: { tax_transaction: '{{TAX_TRANSACTION}}', }, } ); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.PaymentIntentUpdateParams{} params.AddMetadata("tax_transaction", "{{TAX_TRANSACTION}}") result, err := sc.V1PaymentIntents.Update( context.TODO(), "{{PAYMENTINTENT_ID}}", params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new PaymentIntentUpdateOptions { Metadata = new Dictionary { { "tax_transaction", "{{TAX_TRANSACTION}}" }, }, }; var client = new StripeClient("<>"); var service = client.V1.PaymentIntents; PaymentIntent paymentIntent = service.Update("{{PAYMENTINTENT_ID}}", options); ``` ## Rückerstattungen aufzeichnen [Serverseitig] Nachdem Sie eine Steuertransaktion erstellt haben, um einen Verkauf an eine Kundin oder einen Kunden zu erfassen, müssen Sie möglicherweise Erstattungen erfassen. Diese werden ebenfalls als Steuertransaktionen mit `type=reversal` dargestellt. Stornotransaktionen gleichen eine frühere Transaktion aus, indem sie Beträge mit entgegengesetztem Vorzeichen enthalten. Eine Transaktion, bei der beispielsweise ein Verkauf für 50 USD verbucht wurde, kann später eine vollständige Stornierung von -50 USD aufweisen. Wenn Sie eine Rückerstattung ausstellen (mit Stripe oder außerhalb von Stripe), müssen Sie eine Steuerumkehr-Transaktion mit einer eindeutigen `reference` erstellen. Gängige Strategien umfassen: - Hängen Sie ein Suffix an die ursprüngliche Referenz an. Wenn die ursprüngliche Transaktion beispielsweise die Referenz `pi_123456789` hat, erstellen Sie die Stornierung mit der Referenz `pi_123456789-refund`. - Verwenden Sie die ID der [Stripe-Rückerstattung](https://docs.stripe.com/api/refunds/object.md) oder eine Rückerstattungs-ID aus Ihrem System. Zum Beispiel `re_3MoslRBUZ691iUZ41bsYVkOg` oder `myRefund_456`. Wählen Sie die Vorgehensweise, die zum Abgleichen Ihrer Kundenbestellungen mit Ihren [Steuerexporten](https://docs.stripe.com/tax/reports.md) am besten geeignet ist. ### Vollständige Rückerstattung eines Verkaufs Wenn Sie einen Verkauf in Ihrem System vollständig zurückerstatten, erstellen Sie eine Rückerstattung mit `mode=full`. Im folgenden Beispiel ist `tax_1MEFAAI6rIcR421eB1YOzACZ` die Steuertransaktion, die den Verkauf an Ihre Kundin oder Ihren Kunden erfasst: ```curl curl https://api.stripe.com/v1/tax/transactions/create_reversal \ -u "<>:" \ -d mode=full \ -d original_transaction=tax_1MEFAAI6rIcR421eB1YOzACZ \ -d reference=pi_123456789-cancel \ -d "expand[]"=line_items ``` ```cli stripe tax transactions create_reversal \ --mode=full \ --original-transaction=tax_1MEFAAI6rIcR421eB1YOzACZ \ --reference=pi_123456789-cancel \ -d "expand[0]"=line_items ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") transaction = client.v1.tax.transactions.create_reversal({ mode: 'full', original_transaction: 'tax_1MEFAAI6rIcR421eB1YOzACZ', reference: 'pi_123456789-cancel', expand: ['line_items'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. transaction = client.v1.tax.transactions.create_reversal({ "mode": "full", "original_transaction": "tax_1MEFAAI6rIcR421eB1YOzACZ", "reference": "pi_123456789-cancel", "expand": ["line_items"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $transaction = $stripe->tax->transactions->createReversal([ 'mode' => 'full', 'original_transaction' => 'tax_1MEFAAI6rIcR421eB1YOzACZ', 'reference' => 'pi_123456789-cancel', 'expand' => ['line_items'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); TransactionCreateReversalParams params = TransactionCreateReversalParams.builder() .setMode(TransactionCreateReversalParams.Mode.FULL) .setOriginalTransaction("tax_1MEFAAI6rIcR421eB1YOzACZ") .setReference("pi_123456789-cancel") .addExpand("line_items") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Transaction transaction = client.v1().tax().transactions().createReversal(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const transaction = await stripe.tax.transactions.createReversal({ mode: 'full', original_transaction: 'tax_1MEFAAI6rIcR421eB1YOzACZ', reference: 'pi_123456789-cancel', expand: ['line_items'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxTransactionCreateReversalParams{ Mode: stripe.String("full"), OriginalTransaction: stripe.String("tax_1MEFAAI6rIcR421eB1YOzACZ"), Reference: stripe.String("pi_123456789-cancel"), } params.AddExpand("line_items") result, err := sc.V1TaxTransactions.CreateReversal(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.TransactionCreateReversalOptions { Mode = "full", OriginalTransaction = "tax_1MEFAAI6rIcR421eB1YOzACZ", Reference = "pi_123456789-cancel", Expand = new List { "line_items" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Transactions; Stripe.Tax.Transaction transaction = service.CreateReversal(options); ``` Dadurch wird die erstellte vollständige Stornotransaktion zurückgegeben: ```json { "id": "tax_1MEFtXI6rIcR421e0KTGXvCK", "object": "tax.transaction", "created": 1670866467, "currency": "eur", "customer": null, "customer_details": { "address": { "city": null, "country": "IE", "line1": null, "line2": null, "postal_code": null, "state": null }, "address_source": "billing", "ip_address": null, "tax_ids": [], "taxability_override": "none" }, "line_items": { "object": "list", "data": [ { "id": "tax_li_MyCIgTuP9F9mEU", "object": "tax.transaction_line_item", "amount": -4999, "amount_tax": -1150, "livemode": false, "metadata": { }, "quantity": 1, "reference": "L1", "reversal": { "original_line_item": "tax_li_MyBXPByrSUwm6r" }, "tax_behavior": "exclusive", "tax_code": "txcd_10000000", "type": "reversal" }, { "id": "tax_li_MyCIUNXExXmJKU", "object": "tax.transaction_line_item", "amount": -1090, "amount_tax": -90, "livemode": false, "metadata": { }, "quantity": 1, "reference": "L2", "reversal": { "original_line_item": "tax_li_MyBX3Wu3qd2mXj" }, "tax_behavior": "exclusive", "tax_code": "txcd_10000000", "type": "reversal" } ], "has_more": false, "total_count": 2, "url": "/v1/tax/transactions/tax_1MEFtXI6rIcR421e0KTGXvCK/line_items" }, "livemode": false, "metadata": { }, "reference": "pi_123456789-cancel", "reversal": { "original_transaction": "tax_1MEFAAI6rIcR421eB1YOzACZ" }, "shipping_cost": null, "tax_date": 1670863654, "type": "reversal" } ``` Das vollständige Stornieren einer Transaktion hat keine Auswirkungen auf vorherige Teilstornierungen. Vergewissern Sie sich beim Erfassen einer vollständigen Stornierung, dass Sie alle vorherigen Teilstornierungen für dieselbe Transaktion [vollständig stornieren](https://docs.stripe.com/tax/custom.md#reversals-void-refund), um doppelte Erstattungen zu vermeiden. ### Teilweise Rückerstattung eines Verkaufs Nach dem [Ausstellen einer Rückerstattung](https://docs.stripe.com/api/refunds/create.md) an Ihre Kundin oder Ihren Kunden, erstellen Sie eine Storno-Steuertransaktion mit `mode=partial`. Damit können Sie eine Teilerstattung erfassen, indem Sie die erstatteten Beträge der einzelnen Posten angeben. Sie können bis zu 30 Teilrückbuchungen für jeden Verkauf erstellen. Wenn Sie mehr als den von Ihnen erhobenen Steuerbetrag stornieren, wird ein Fehler zurückgegeben. Im folgenden Beispiel wird nur eine Rückerstattung des ersten Postens der ursprünglichen Transaktion aufgezeichnet: ```curl curl https://api.stripe.com/v1/tax/transactions/create_reversal \ -u "<>:" \ -d mode=partial \ -d original_transaction=tax_1MEFAAI6rIcR421eB1YOzACZ \ -d reference=pi_123456789-refund_1 \ -d "line_items[0][original_line_item]"=tax_li_MyBXPByrSUwm6r \ -d "line_items[0][reference]"=L1 \ -d "line_items[0][amount]"=-4999 \ -d "line_items[0][amount_tax]"=-1150 \ -d "metadata[refund]"="{{REFUND_ID}}" \ --data-urlencode "metadata[refund_reason]"="Refunded line 1 of pi_123456789 (customer was unhappy)" \ -d "expand[0]"=line_items ``` ```cli stripe tax transactions create_reversal \ --mode=partial \ --original-transaction=tax_1MEFAAI6rIcR421eB1YOzACZ \ --reference=pi_123456789-refund_1 \ -d "line_items[0][original_line_item]"=tax_li_MyBXPByrSUwm6r \ -d "line_items[0][reference]"=L1 \ -d "line_items[0][amount]"=-4999 \ -d "line_items[0][amount_tax]"=-1150 \ -d "metadata[refund]"="{{REFUND_ID}}" \ -d "metadata[refund_reason]"="Refunded line 1 of pi_123456789 (customer was unhappy)" \ -d "expand[0]"=line_items ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") transaction = client.v1.tax.transactions.create_reversal({ mode: 'partial', original_transaction: 'tax_1MEFAAI6rIcR421eB1YOzACZ', reference: 'pi_123456789-refund_1', line_items: [ { original_line_item: 'tax_li_MyBXPByrSUwm6r', reference: 'L1', amount: -4999, amount_tax: -1150, }, ], metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded line 1 of pi_123456789 (customer was unhappy)', }, expand: ['line_items'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. transaction = client.v1.tax.transactions.create_reversal({ "mode": "partial", "original_transaction": "tax_1MEFAAI6rIcR421eB1YOzACZ", "reference": "pi_123456789-refund_1", "line_items": [ { "original_line_item": "tax_li_MyBXPByrSUwm6r", "reference": "L1", "amount": -4999, "amount_tax": -1150, }, ], "metadata": { "refund": "{{REFUND_ID}}", "refund_reason": "Refunded line 1 of pi_123456789 (customer was unhappy)", }, "expand": ["line_items"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $transaction = $stripe->tax->transactions->createReversal([ 'mode' => 'partial', 'original_transaction' => 'tax_1MEFAAI6rIcR421eB1YOzACZ', 'reference' => 'pi_123456789-refund_1', 'line_items' => [ [ 'original_line_item' => 'tax_li_MyBXPByrSUwm6r', 'reference' => 'L1', 'amount' => -4999, 'amount_tax' => -1150, ], ], 'metadata' => [ 'refund' => '{{REFUND_ID}}', 'refund_reason' => 'Refunded line 1 of pi_123456789 (customer was unhappy)', ], 'expand' => ['line_items'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); TransactionCreateReversalParams params = TransactionCreateReversalParams.builder() .setMode(TransactionCreateReversalParams.Mode.PARTIAL) .setOriginalTransaction("tax_1MEFAAI6rIcR421eB1YOzACZ") .setReference("pi_123456789-refund_1") .addLineItem( TransactionCreateReversalParams.LineItem.builder() .setOriginalLineItem("tax_li_MyBXPByrSUwm6r") .setReference("L1") .setAmount(-4999L) .setAmountTax(-1150L) .build() ) .putMetadata("refund", "{{REFUND_ID}}") .putMetadata( "refund_reason", "Refunded line 1 of pi_123456789 (customer was unhappy)" ) .addExpand("line_items") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Transaction transaction = client.v1().tax().transactions().createReversal(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const transaction = await stripe.tax.transactions.createReversal({ mode: 'partial', original_transaction: 'tax_1MEFAAI6rIcR421eB1YOzACZ', reference: 'pi_123456789-refund_1', line_items: [ { original_line_item: 'tax_li_MyBXPByrSUwm6r', reference: 'L1', amount: -4999, amount_tax: -1150, }, ], metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded line 1 of pi_123456789 (customer was unhappy)', }, expand: ['line_items'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxTransactionCreateReversalParams{ Mode: stripe.String("partial"), OriginalTransaction: stripe.String("tax_1MEFAAI6rIcR421eB1YOzACZ"), Reference: stripe.String("pi_123456789-refund_1"), LineItems: []*stripe.TaxTransactionCreateReversalLineItemParams{ &stripe.TaxTransactionCreateReversalLineItemParams{ OriginalLineItem: stripe.String("tax_li_MyBXPByrSUwm6r"), Reference: stripe.String("L1"), Amount: stripe.Int64(-4999), AmountTax: stripe.Int64(-1150), }, }, } params.AddMetadata("refund", "{{REFUND_ID}}") params.AddMetadata( "refund_reason", "Refunded line 1 of pi_123456789 (customer was unhappy)") params.AddExpand("line_items") result, err := sc.V1TaxTransactions.CreateReversal(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.TransactionCreateReversalOptions { Mode = "partial", OriginalTransaction = "tax_1MEFAAI6rIcR421eB1YOzACZ", Reference = "pi_123456789-refund_1", LineItems = new List { new Stripe.Tax.TransactionLineItemOptions { OriginalLineItem = "tax_li_MyBXPByrSUwm6r", Reference = "L1", Amount = -4999, AmountTax = -1150, }, }, Metadata = new Dictionary { { "refund", "{{REFUND_ID}}" }, { "refund_reason", "Refunded line 1 of pi_123456789 (customer was unhappy)" }, }, Expand = new List { "line_items" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Transactions; Stripe.Tax.Transaction transaction = service.CreateReversal(options); ``` Dadurch wird die erstellte Teilstornotransaktion zurückgegeben: ```json { "id": "tax_1MEFACI6rIcR421eHrjXCSmD", "object": "tax.transaction", "created": 1670863656, "currency": "eur", ... "line_items": { "object": "list", "data": [ { "id": "tax_li_MyBXC98AhtaR37", "object": "tax.transaction_line_item", "amount": -4999, "amount_tax": -1150, "livemode": false, "metadata": { }, "quantity": 1, "reference": "L1", "reversal": { "original_line_item": "tax_li_MyBXPByrSUwm6r" }, "tax_behavior": "exclusive", "tax_code": "txcd_10000000", "type": "reversal" } ], "has_more": false, "total_count": 1, "url": "/v1/tax/transactions/tax_1MEFACI6rIcR421eHrjXCSmD/line_items" }, "livemode": false, "metadata": { "refund": "{{REFUND_ID}}", "description": "Refunding pi_123456789 (customer was unhappy)" }, "reference": "pi_123456789-refund_1", "reversal": { "original_transaction": "tax_1MEFAAI6rIcR421eB1YOzACZ" }, "shipping_cost": null, "tax_date": 1670863654, "type": "reversal" } ``` Für jeden stornierten Posten müssen Sie den stornierten `amount` und `amount_tax` angeben. Der `amount` ist inklusive Steuern, wenn die ursprüngliche Berechnung des Postens inklusive Steuern war. Wie `amount` und `amount_tax` ermittelt werden, hängt von Ihrer Situation ab: - Wenn Ihre Transaktionen immer nur einen einzigen Posten enthalten, verwenden Sie stattdessen [vollständige Stornierungen](https://docs.stripe.com/tax/custom.md#reversals-full). - Wenn Sie immer ganze Posten erstatten, verwenden Sie die ursprünglichen Transaktionsposten `amount` und `amount_tax`, jedoch mit negativen Vorzeichen. - Wenn Sie Teile von Einzelposten zurückerstatten, müssen Sie die zurückerstatteten Beträge berechnen. Zum Beispiel: Bei einer Verkaufs­transaktion mit `amount=5000` und `amount_tax=500` erstellen Sie nach der Rückerstattung der Hälfte des Postens eine Teilrückbuchung mit Posten `amount=-2500` und `amount_tax=-250`. #### Steuerberichte mit teilweisen Rückerstattungen Wenn Sie einen Steuerbetrag so zurückerstatten, dass die gesamte Steuer nicht mehr proportional zur Zwischensumme ist, kann das Ihre Steuerberichterstattung unzuverlässig machen. Die steuerpflichtigen und nicht steuerpflichtigen Beträge werden nicht automatisch angepasst und der Grund für die Stornierung der Steuer (z. B. Produkt ausgenommen, Kunde/Kundin ausgenommen oder Umkehrung der Steuerschuld) wird nicht widergespiegelt. Wir empfehlen, keine Steuerbeträge für Teilposten zurückzuerstatten. Stornieren Sie stattdessen die Transaktion und erstellen Sie eine neue mit entsprechenden Eingaben für eine genaue Steuerberechnung. ### Teilweise Rückerstattung eines Verkaufs durch einen Pauschalbetrag Alternativ können Sie einen Storno mit `mode=partial` erstellen. Hierfür geben Sie für den Betrag (inkl. Steuer) einen pauschalen Rückerstattungsbetrag an. Der Betrag wird anteilsmäßig auf die einzelnen Posten und die Versandkosten aufgeteilt, wobei auf den zu erstattenden Betrag eines jeden Artikels geachtet wird. Die Transaktion im folgenden Beispiel besteht aus zwei Posten: einem Posten im Wert von 10 USD und einem Posten im Wert von 20 USD, beide werden mit 10 % besteuert. Der Gesamtbetrag der Transaktion beträgt 33,00 USD. Es wird eine Pauschalrückerstattung über 16,50 USD erfasst: ```curl curl https://api.stripe.com/v1/tax/transactions/create_reversal \ -u "<>:" \ -d mode=partial \ -d original_transaction=tax_1NVcKqBUZ691iUZ4xMZtcGYt \ -d reference=pi_234567890-refund_1 \ -d flat_amount=-1650 \ -d "metadata[refund]"="{{REFUND_ID}}" \ --data-urlencode "metadata[refund_reason]"="Refunded $16.50 of pi_234567890 (customer was unhappy)" \ -d "expand[]"=line_items ``` ```cli stripe tax transactions create_reversal \ --mode=partial \ --original-transaction=tax_1NVcKqBUZ691iUZ4xMZtcGYt \ --reference=pi_234567890-refund_1 \ --flat-amount=-1650 \ -d "metadata[refund]"="{{REFUND_ID}}" \ -d "metadata[refund_reason]"="Refunded $16.50 of pi_234567890 (customer was unhappy)" \ -d "expand[0]"=line_items ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") transaction = client.v1.tax.transactions.create_reversal({ mode: 'partial', original_transaction: 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', reference: 'pi_234567890-refund_1', flat_amount: -1650, metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded $16.50 of pi_234567890 (customer was unhappy)', }, expand: ['line_items'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. transaction = client.v1.tax.transactions.create_reversal({ "mode": "partial", "original_transaction": "tax_1NVcKqBUZ691iUZ4xMZtcGYt", "reference": "pi_234567890-refund_1", "flat_amount": -1650, "metadata": { "refund": "{{REFUND_ID}}", "refund_reason": "Refunded $16.50 of pi_234567890 (customer was unhappy)", }, "expand": ["line_items"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $transaction = $stripe->tax->transactions->createReversal([ 'mode' => 'partial', 'original_transaction' => 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', 'reference' => 'pi_234567890-refund_1', 'flat_amount' => -1650, 'metadata' => [ 'refund' => '{{REFUND_ID}}', 'refund_reason' => 'Refunded $16.50 of pi_234567890 (customer was unhappy)', ], 'expand' => ['line_items'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); TransactionCreateReversalParams params = TransactionCreateReversalParams.builder() .setMode(TransactionCreateReversalParams.Mode.PARTIAL) .setOriginalTransaction("tax_1NVcKqBUZ691iUZ4xMZtcGYt") .setReference("pi_234567890-refund_1") .setFlatAmount(-1650L) .putMetadata("refund", "{{REFUND_ID}}") .putMetadata( "refund_reason", "Refunded $16.50 of pi_234567890 (customer was unhappy)" ) .addExpand("line_items") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Transaction transaction = client.v1().tax().transactions().createReversal(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const transaction = await stripe.tax.transactions.createReversal({ mode: 'partial', original_transaction: 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', reference: 'pi_234567890-refund_1', flat_amount: -1650, metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded $16.50 of pi_234567890 (customer was unhappy)', }, expand: ['line_items'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxTransactionCreateReversalParams{ Mode: stripe.String("partial"), OriginalTransaction: stripe.String("tax_1NVcKqBUZ691iUZ4xMZtcGYt"), Reference: stripe.String("pi_234567890-refund_1"), FlatAmount: stripe.Int64(-1650), } params.AddMetadata("refund", "{{REFUND_ID}}") params.AddMetadata( "refund_reason", "Refunded $16.50 of pi_234567890 (customer was unhappy)") params.AddExpand("line_items") result, err := sc.V1TaxTransactions.CreateReversal(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.TransactionCreateReversalOptions { Mode = "partial", OriginalTransaction = "tax_1NVcKqBUZ691iUZ4xMZtcGYt", Reference = "pi_234567890-refund_1", FlatAmount = -1650, Metadata = new Dictionary { { "refund", "{{REFUND_ID}}" }, { "refund_reason", "Refunded $16.50 of pi_234567890 (customer was unhappy)" }, }, Expand = new List { "line_items" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Transactions; Stripe.Tax.Transaction transaction = service.CreateReversal(options); ``` Dadurch wird die erstellte Teilstornotransaktion zurückgegeben: ```json { "id": "tax_1NVcQYBUZ691iUZ4SBPukGa6", "object": "tax.transaction", "created": 1689780994, "currency": "usd", ... "line_items": { "object": "list", "data": [ { "id": "tax_li_OICqymcWjlbevq", "object": "tax.transaction_line_item", "amount": -500, "amount_tax": -50, "livemode": false, "metadata": {}, "product": null, "quantity": 1, "reference": "refund_li_1", "reversal": { "original_line_item": "tax_li_OICmRXkFuWr8Df" }, "tax_behavior": "exclusive", "tax_code": "txcd_10103000", "type": "reversal" }, { "id": "tax_li_OICq2H1qHjwyzX", "object": "tax.transaction_line_item", "amount": -1000, "amount_tax": -100, "livemode": false, "metadata": {}, "product": null, "quantity": 1, "reference": "refund_li_2", "reversal": { "original_line_item": "tax_li_OICmxhnSJxF7rY" }, "tax_behavior": "exclusive", "tax_code": "txcd_10103000", "type": "reversal" } ], "has_more": false, "total_count": 2, "url": "/v1/tax/transactions/tax_1NVcQYBUZ691iUZ4SBPukGa6/line_items" }, "livemode": false, "metadata": { "refund": "{{REFUND_ID}}", "description": "Refunding pi_234567890 (customer was unhappy)" }, "reference": "pi_234567890-refund_1", "reversal": { "original_transaction": "tax_1NVcKqBUZ691iUZ4xMZtcGYt" }, "shipping_cost": null, "tax_date": 1670863654, "type": "reversal" } ``` Rückerstattungsbeträge und Steuern werden wie folgt pro Posten und Versandkosten der ursprünglichen Transaktion berechnet: 1. Zunächst berechnen wir das gesamte verbleibende Guthaben der Transaktion, das zurückerstattet werden kann. Da für diese Transaktion keine weiteren Stornos verzeichnet wurden, beträgt der Gesamtbetrag 33,00 USD. 1. Als Nächstes berechnen wir den zu erstattenden Gesamtbetrag pro Posten. Diesen Betrag ermitteln wir anhand des Anteils des verfügbaren Gesamtbetrags des zu erstattenden Postens und des verbleibenden Gesamtbetrags der Transaktion. Das kann z. B. so aussehen: Der Posten in Höhe von 10 USD, für den eine Rückerstattung von 11,00 USD verbleibt, entspricht 33,33 % des verbleibenden Gesamtbetrags der Transaktion. Der zurückzuerstattende Gesamtbetrag beträgt demnach `-16.50 USD * 33,33 % = -5.50 USD`. 1. Abschließend wird der zu erstattende Gesamtbetrag auf `amount` und `amount_tax` aufgeteilt. Auch das geschieht anteilsmäßig, abhängig davon, welcher Steuerbetrag für den Posten im Vergleich zum insgesamt zu erstattenden Betrag zurückerstattet werden kann. Für einen beispielhaften Posten in Höhe von 10 USD entspricht die Steuer (1,00 USD) 9,09 % des verbleibenden zu erstattenden Gesamtbetrags (11,00 USD). Der `amount_tax` ist also `-5.50 USD * 9.09% = -0.50 USD`. Der Pauschalbetrag wird entsprechend dem für die Transaktion *noch zu erstattenden* Betrag aufgeteilt, nicht entsprechend dem ursprünglich erfassten Betrag. Anstatt beispielsweise eine Erstattung in Höhe von pauschal 16,50 USD zu erfassen, erfassen Sie zunächst eine Teilstornierung für den Gesamtbetrag des Postens im Wert von 10 USD: ```curl curl https://api.stripe.com/v1/tax/transactions/create_reversal \ -u "<>:" \ -d mode=partial \ -d original_transaction=tax_1NVcKqBUZ691iUZ4xMZtcGYt \ -d reference=pi_234567890-refund_1 \ -d "line_items[0][original_line_item]"=tax_li_OICmRXkFuWr8Df \ -d "line_items[0][reference]"=partial_refund_l1 \ -d "line_items[0][amount]"=-1000 \ -d "line_items[0][amount_tax]"=-100 \ -d "metadata[refund]"="{{REFUND_ID}}" \ --data-urlencode "metadata[refund_reason]"="Refunded line 1 of pi_234567890 (customer was unhappy)" \ -d "expand[0]"=line_items ``` ```cli stripe tax transactions create_reversal \ --mode=partial \ --original-transaction=tax_1NVcKqBUZ691iUZ4xMZtcGYt \ --reference=pi_234567890-refund_1 \ -d "line_items[0][original_line_item]"=tax_li_OICmRXkFuWr8Df \ -d "line_items[0][reference]"=partial_refund_l1 \ -d "line_items[0][amount]"=-1000 \ -d "line_items[0][amount_tax]"=-100 \ -d "metadata[refund]"="{{REFUND_ID}}" \ -d "metadata[refund_reason]"="Refunded line 1 of pi_234567890 (customer was unhappy)" \ -d "expand[0]"=line_items ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") transaction = client.v1.tax.transactions.create_reversal({ mode: 'partial', original_transaction: 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', reference: 'pi_234567890-refund_1', line_items: [ { original_line_item: 'tax_li_OICmRXkFuWr8Df', reference: 'partial_refund_l1', amount: -1000, amount_tax: -100, }, ], metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded line 1 of pi_234567890 (customer was unhappy)', }, expand: ['line_items'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. transaction = client.v1.tax.transactions.create_reversal({ "mode": "partial", "original_transaction": "tax_1NVcKqBUZ691iUZ4xMZtcGYt", "reference": "pi_234567890-refund_1", "line_items": [ { "original_line_item": "tax_li_OICmRXkFuWr8Df", "reference": "partial_refund_l1", "amount": -1000, "amount_tax": -100, }, ], "metadata": { "refund": "{{REFUND_ID}}", "refund_reason": "Refunded line 1 of pi_234567890 (customer was unhappy)", }, "expand": ["line_items"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $transaction = $stripe->tax->transactions->createReversal([ 'mode' => 'partial', 'original_transaction' => 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', 'reference' => 'pi_234567890-refund_1', 'line_items' => [ [ 'original_line_item' => 'tax_li_OICmRXkFuWr8Df', 'reference' => 'partial_refund_l1', 'amount' => -1000, 'amount_tax' => -100, ], ], 'metadata' => [ 'refund' => '{{REFUND_ID}}', 'refund_reason' => 'Refunded line 1 of pi_234567890 (customer was unhappy)', ], 'expand' => ['line_items'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); TransactionCreateReversalParams params = TransactionCreateReversalParams.builder() .setMode(TransactionCreateReversalParams.Mode.PARTIAL) .setOriginalTransaction("tax_1NVcKqBUZ691iUZ4xMZtcGYt") .setReference("pi_234567890-refund_1") .addLineItem( TransactionCreateReversalParams.LineItem.builder() .setOriginalLineItem("tax_li_OICmRXkFuWr8Df") .setReference("partial_refund_l1") .setAmount(-1000L) .setAmountTax(-100L) .build() ) .putMetadata("refund", "{{REFUND_ID}}") .putMetadata( "refund_reason", "Refunded line 1 of pi_234567890 (customer was unhappy)" ) .addExpand("line_items") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Transaction transaction = client.v1().tax().transactions().createReversal(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const transaction = await stripe.tax.transactions.createReversal({ mode: 'partial', original_transaction: 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', reference: 'pi_234567890-refund_1', line_items: [ { original_line_item: 'tax_li_OICmRXkFuWr8Df', reference: 'partial_refund_l1', amount: -1000, amount_tax: -100, }, ], metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded line 1 of pi_234567890 (customer was unhappy)', }, expand: ['line_items'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxTransactionCreateReversalParams{ Mode: stripe.String("partial"), OriginalTransaction: stripe.String("tax_1NVcKqBUZ691iUZ4xMZtcGYt"), Reference: stripe.String("pi_234567890-refund_1"), LineItems: []*stripe.TaxTransactionCreateReversalLineItemParams{ &stripe.TaxTransactionCreateReversalLineItemParams{ OriginalLineItem: stripe.String("tax_li_OICmRXkFuWr8Df"), Reference: stripe.String("partial_refund_l1"), Amount: stripe.Int64(-1000), AmountTax: stripe.Int64(-100), }, }, } params.AddMetadata("refund", "{{REFUND_ID}}") params.AddMetadata( "refund_reason", "Refunded line 1 of pi_234567890 (customer was unhappy)") params.AddExpand("line_items") result, err := sc.V1TaxTransactions.CreateReversal(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.TransactionCreateReversalOptions { Mode = "partial", OriginalTransaction = "tax_1NVcKqBUZ691iUZ4xMZtcGYt", Reference = "pi_234567890-refund_1", LineItems = new List { new Stripe.Tax.TransactionLineItemOptions { OriginalLineItem = "tax_li_OICmRXkFuWr8Df", Reference = "partial_refund_l1", Amount = -1000, AmountTax = -100, }, }, Metadata = new Dictionary { { "refund", "{{REFUND_ID}}" }, { "refund_reason", "Refunded line 1 of pi_234567890 (customer was unhappy)" }, }, Expand = new List { "line_items" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Transactions; Stripe.Tax.Transaction transaction = service.CreateReversal(options); ``` Anschließend erfassen Sie einen pauschalen Stornobetrag über 16,50 USD: ```curl curl https://api.stripe.com/v1/tax/transactions/create_reversal \ -u "<>:" \ -d mode=partial \ -d original_transaction=tax_1NVcKqBUZ691iUZ4xMZtcGYt \ -d reference=pi_234567890-refund_2 \ -d flat_amount=-1650 \ -d "metadata[refund]"="{{REFUND_ID}}" \ --data-urlencode "metadata[refund_reason]"="Refunded $16.50 of pi_234567890 (customer was still unhappy)" \ -d "expand[]"=line_items ``` ```cli stripe tax transactions create_reversal \ --mode=partial \ --original-transaction=tax_1NVcKqBUZ691iUZ4xMZtcGYt \ --reference=pi_234567890-refund_2 \ --flat-amount=-1650 \ -d "metadata[refund]"="{{REFUND_ID}}" \ -d "metadata[refund_reason]"="Refunded $16.50 of pi_234567890 (customer was still unhappy)" \ -d "expand[0]"=line_items ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") transaction = client.v1.tax.transactions.create_reversal({ mode: 'partial', original_transaction: 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', reference: 'pi_234567890-refund_2', flat_amount: -1650, metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded $16.50 of pi_234567890 (customer was still unhappy)', }, expand: ['line_items'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. transaction = client.v1.tax.transactions.create_reversal({ "mode": "partial", "original_transaction": "tax_1NVcKqBUZ691iUZ4xMZtcGYt", "reference": "pi_234567890-refund_2", "flat_amount": -1650, "metadata": { "refund": "{{REFUND_ID}}", "refund_reason": "Refunded $16.50 of pi_234567890 (customer was still unhappy)", }, "expand": ["line_items"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $transaction = $stripe->tax->transactions->createReversal([ 'mode' => 'partial', 'original_transaction' => 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', 'reference' => 'pi_234567890-refund_2', 'flat_amount' => -1650, 'metadata' => [ 'refund' => '{{REFUND_ID}}', 'refund_reason' => 'Refunded $16.50 of pi_234567890 (customer was still unhappy)', ], 'expand' => ['line_items'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); TransactionCreateReversalParams params = TransactionCreateReversalParams.builder() .setMode(TransactionCreateReversalParams.Mode.PARTIAL) .setOriginalTransaction("tax_1NVcKqBUZ691iUZ4xMZtcGYt") .setReference("pi_234567890-refund_2") .setFlatAmount(-1650L) .putMetadata("refund", "{{REFUND_ID}}") .putMetadata( "refund_reason", "Refunded $16.50 of pi_234567890 (customer was still unhappy)" ) .addExpand("line_items") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Transaction transaction = client.v1().tax().transactions().createReversal(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const transaction = await stripe.tax.transactions.createReversal({ mode: 'partial', original_transaction: 'tax_1NVcKqBUZ691iUZ4xMZtcGYt', reference: 'pi_234567890-refund_2', flat_amount: -1650, metadata: { refund: '{{REFUND_ID}}', refund_reason: 'Refunded $16.50 of pi_234567890 (customer was still unhappy)', }, expand: ['line_items'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxTransactionCreateReversalParams{ Mode: stripe.String("partial"), OriginalTransaction: stripe.String("tax_1NVcKqBUZ691iUZ4xMZtcGYt"), Reference: stripe.String("pi_234567890-refund_2"), FlatAmount: stripe.Int64(-1650), } params.AddMetadata("refund", "{{REFUND_ID}}") params.AddMetadata( "refund_reason", "Refunded $16.50 of pi_234567890 (customer was still unhappy)") params.AddExpand("line_items") result, err := sc.V1TaxTransactions.CreateReversal(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.TransactionCreateReversalOptions { Mode = "partial", OriginalTransaction = "tax_1NVcKqBUZ691iUZ4xMZtcGYt", Reference = "pi_234567890-refund_2", FlatAmount = -1650, Metadata = new Dictionary { { "refund", "{{REFUND_ID}}" }, { "refund_reason", "Refunded $16.50 of pi_234567890 (customer was still unhappy)" }, }, Expand = new List { "line_items" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Transactions; Stripe.Tax.Transaction transaction = service.CreateReversal(options); ``` Das gibt die teilweise Stornotransaktion zurück: ```json { "id": "tax_1NVxFIBUZ691iUZ4saOIloxB", "object": "tax.transaction", "created": 1689861020, "currency": "usd", ... "line_items": { "object": "list", "data": [ { "id": "tax_li_OIYM8xd8BzrATd", "object": "tax.transaction_line_item", "amount": 0, "amount_tax": 0, "livemode": false, "metadata": {}, "product": null, "quantity": 1, "reference": "refund_li_1", "reversal": { "original_line_item": "tax_li_OICmRXkFuWr8Df" }, "tax_behavior": "exclusive", "tax_code": "txcd_10103000", "type": "reversal" }, { "id": "tax_li_OIYMNBH6s8oQj9", "object": "tax.transaction_line_item", "amount": -1500, "amount_tax": -150, "livemode": false, "metadata": {}, "product": null, "quantity": 1, "reference": "refund_li_2", "reversal": { "original_line_item": "tax_li_OICmxhnSJxF7rY" }, "tax_behavior": "exclusive", "tax_code": "txcd_10103000", "type": "reversal" } ], "has_more": false, "total_count": 2, "url": "/v1/tax/transactions/tax_1NVxFIBUZ691iUZ4saOIloxB/line_items" }, "livemode": false, "metadata": {}, "reference": "pi_234567890-refund_2", "reversal": { "original_transaction": "tax_1NVcKqBUZ691iUZ4xMZtcGYt" }, "shipping_cost": null, "tax_date": 1670863654, "type": "reversal" } ``` Da der verbleibende Gesamtbetrag der Transaktion jetzt 22,00 USD beträgt und der Posten in Höhe von 10 USD vollständig zurückerstattet wird, werden die 16,50 USD vollständig auf den Posten über 20 USD aufgeteilt. Die 16,50 USD werden dann gemäß der Logik aus Schritt 3 auf `amount = -15.00 USD` und `amount_tax = -1.50 USD` aufgeteilt. In der Zwischenzeit wird für den 10-USD-Posten der Transaktion eine Rückerstattung von 0 USD erfasst. ### Eine teilweise Rückerstattung rückgängig machen Steuertransaktionen sind unveränderlich, aber Sie können eine Teilrückerstattung stornieren, indem Sie eine [vollständige Stornierung](https://docs.stripe.com/api/tax/transactions/create_reversal.md#tax_transaction_create_reversal-mode) erstellen. Dies kann in folgenden Fällen erforderlich sein: - Die [Rückerstattung der Zahlung schlägt fehl](https://docs.stripe.com/refunds.md#failed-refunds) und Sie haben die Ware oder Dienstleistung Ihrer Kundin oder Ihrem Kunden nicht bereitgestellt - Die falsche Bestellung oder die falschen Beträge werden zurückerstattet - Der ursprüngliche Verkauf wird vollständig zurückerstattet und die Teilrückerstattungen sind nicht mehr gültig Im folgenden Beispiel ist `tax_1MEFACI6rIcR421eHrjXCSmD` die Transaktion, die die Teilrückerstattung darstellt: ```curl curl https://api.stripe.com/v1/tax/transactions/create_reversal \ -u "<>:" \ -d mode=full \ -d original_transaction=tax_1MEFACI6rIcR421eHrjXCSmD \ -d reference=pi_123456789-refund_1-cancel \ -d "metadata[refund_reason]"="User called to cancel because they selected the wrong item" \ -d "expand[]"=line_items ``` ```cli stripe tax transactions create_reversal \ --mode=full \ --original-transaction=tax_1MEFACI6rIcR421eHrjXCSmD \ --reference=pi_123456789-refund_1-cancel \ -d "metadata[refund_reason]"="User called to cancel because they selected the wrong item" \ -d "expand[0]"=line_items ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") transaction = client.v1.tax.transactions.create_reversal({ mode: 'full', original_transaction: 'tax_1MEFACI6rIcR421eHrjXCSmD', reference: 'pi_123456789-refund_1-cancel', metadata: {refund_reason: 'User called to cancel because they selected the wrong item'}, expand: ['line_items'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. transaction = client.v1.tax.transactions.create_reversal({ "mode": "full", "original_transaction": "tax_1MEFACI6rIcR421eHrjXCSmD", "reference": "pi_123456789-refund_1-cancel", "metadata": { "refund_reason": "User called to cancel because they selected the wrong item", }, "expand": ["line_items"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $transaction = $stripe->tax->transactions->createReversal([ 'mode' => 'full', 'original_transaction' => 'tax_1MEFACI6rIcR421eHrjXCSmD', 'reference' => 'pi_123456789-refund_1-cancel', 'metadata' => [ 'refund_reason' => 'User called to cancel because they selected the wrong item', ], 'expand' => ['line_items'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); TransactionCreateReversalParams params = TransactionCreateReversalParams.builder() .setMode(TransactionCreateReversalParams.Mode.FULL) .setOriginalTransaction("tax_1MEFACI6rIcR421eHrjXCSmD") .setReference("pi_123456789-refund_1-cancel") .putMetadata( "refund_reason", "User called to cancel because they selected the wrong item" ) .addExpand("line_items") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Transaction transaction = client.v1().tax().transactions().createReversal(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const transaction = await stripe.tax.transactions.createReversal({ mode: 'full', original_transaction: 'tax_1MEFACI6rIcR421eHrjXCSmD', reference: 'pi_123456789-refund_1-cancel', metadata: { refund_reason: 'User called to cancel because they selected the wrong item', }, expand: ['line_items'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxTransactionCreateReversalParams{ Mode: stripe.String("full"), OriginalTransaction: stripe.String("tax_1MEFACI6rIcR421eHrjXCSmD"), Reference: stripe.String("pi_123456789-refund_1-cancel"), } params.AddMetadata( "refund_reason", "User called to cancel because they selected the wrong item") params.AddExpand("line_items") result, err := sc.V1TaxTransactions.CreateReversal(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.TransactionCreateReversalOptions { Mode = "full", OriginalTransaction = "tax_1MEFACI6rIcR421eHrjXCSmD", Reference = "pi_123456789-refund_1-cancel", Metadata = new Dictionary { { "refund_reason", "User called to cancel because they selected the wrong item" }, }, Expand = new List { "line_items" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Transactions; Stripe.Tax.Transaction transaction = service.CreateReversal(options); ``` Dadurch wird die erstellte vollständige Stornotransaktion zurückgegeben: ```json { "id": "tax_1MEFADI6rIcR421e94fNTOCK", "object": "tax.transaction", "created": 1670863657, "currency": "eur", ... "line_items": { "object": "list", "data": [ { "id": "tax_li_MyBXMOlwenCyFB", "object": "tax.transaction_line_item", "amount": 4999, "amount_tax": 1150, "livemode": false, "metadata": { }, "quantity": 1, "reference": "L1", "reversal": { "original_line_item": "tax_li_MyBXC98AhtaR37" }, "tax_behavior": "exclusive", "tax_code": "txcd_10000000", "type": "reversal" } ], "has_more": false, "total_count": 1, "url": "/v1/tax/transactions/tax_1MEFADI6rIcR421e94fNTOCK/line_items" }, "livemode": false, "metadata": { "refund_reason": "User called to cancel because they picked the wrong item" }, "reference": "pi_123456789-refund_1-cancel", "reversal": { "original_transaction": "tax_1MEFACI6rIcR421eHrjXCSmD" }, "shipping_cost": null, "tax_date": 1670863654, "type": "reversal" } ``` ## Testen Verwenden Sie *Sandboxes* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes), deren Antwortstruktur mit dem Live-Modus identisch ist, um sicherzustellen, dass Ihre Integration korrekt funktioniert, bevor Sie live gehen. > In Testumgebungen ist nicht garantiert, dass die Berechnungen aktuelle Steuerergebnisse liefern. Sie sind auf 1.000 Steuerberechnungen pro Tag beschränkt. Wenn Sie ein höheres Limit benötigen, wenden Sie sich bitte an den [Stripe-Support](https://support.stripe.com/contact). Hinweise zu automatisierten Tests und Strategien zur Umgehung von Begrenzungen in Testumgebungen finden Sie unter [Automatisierte Tests](https://docs.stripe.com/automated-testing.md). ## Steuertransaktionen anzeigen Sie können alle Steuertransaktionen für Ihr Konto auf der Seite [Steuertransaktionen](https://dashboard.stripe.com/test/tax/transactions) im Dashboard einsehen. Klicken Sie auf eine einzelne Transaktion, um eine detaillierte Aufschlüsselung der berechneten Steuern nach Zuständigkeitsbereich und nach einzelnen Produkten anzuzeigen, die in der Transaktion enthalten sind. > Die Steuertransaktionsseite enthält nur *Transaktionen* und keine *Berechnungen*. Wenn Sie eine Berechnung erwarten und sie auf dieser Seite nicht finden können, überprüfen Sie, ob Sie aus der Berechnung [erfolgreich eine Steuertransaktion erstellt haben](https://docs.stripe.com/tax/custom.md#tax-transaction). ## Optional: Integrationsbeispiele Sie können Steuern für Ihre Kundin oder Ihren Kunden berechnen, bevor Sie Zahlungsmethode erfassen und [einen PaymentIntent erstellen](https://docs.stripe.com/payments/accept-a-payment.md?platform=web&ui=elements#web-create-intent). Beispielsweise können Sie den Gesamtbetrag des Warenkorbs anzeigen, wenn die Kundin oder der Kunde die Postleitzahl angibt. Im folgenden Beispiel definiert Ihr Server einen Endpoint `/preview-cart`, an den die Kundenadresse von Ihrem clientseitigen Formular gesendet wird. Der Server kombiniert die Posten des Warenkorbs mit der Kundenadresse, um die Steuer zu berechnen. #### Node.js ```javascript // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const express = require('express'); const app = express(); // Parse the request body as JSON. app.use(express.json()); app.post('/preview-cart', async (req, res) => { const cart = ...; // Load the cart/order from your system // Convert each cart item to a Stripe line item object const lineItems = cart.items.map( cartItem => ({ reference: cartItem.id, amount: cartItem.unitPrice * cartItem.quantity, quantity: cartItem.quantity }) ); // Get the customer's address from the request body const address = req.body.address; // Create a tax calculation using the Stripe API const calculation = await stripe.tax.calculations.create({ currency: cart.currency, line_items: lineItems, customer_details: { address: { line1: address.line1, city: address.city, state: address.state, postal_code: address.postal_code, country: address.country, }, address_source: "billing" }, expand: ['line_items.data.tax_breakdown'] }); // Return the tax amount as a JSON response res.json({ tax_amount: calculation.tax_amount_exclusive }); }); app.listen(4242, () => { console.log('Running on port 4242'); }); ``` #### Java ```java package com.stripe.sample; import static spark.Spark.post; import static spark.Spark.port; import static spark.Spark.staticFiles; import com.stripe.Stripe; import com.stripe.exception.StripeException; import com.stripe.model.tax.Calculation; import com.stripe.param.tax.CalculationCreateParams; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class Server { public static void main(String[] args) throws StripeException { port(4242); // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; post("/preview-cart", (request, response) -> { var cart = ...; // Load the cart/order from your system // Convert each cart item to a Stripe line item object List lineItems = cart.getItems().stream() .map(cartItem -> CalculationCreateParams.LineItem .builder() .setReference(cartItem.id()) .setAmount(cartItem.unitPrice() * cartItem.quantity()) .setQuantity(cartItem.quantity()) .build()).collect(Collectors.toList()); // Get the customer's address from the request body var userAddress = ...; // Convert the customer's address to a Stripe customer address object CalculationCreateParams.CustomerDetails.Address address = CalculationCreateParams.CustomerDetails.Address .builder() .setLine1(userAddress.getLine1()) .setLine2(userAddress.getLine2()) .setCity(userAddress.getCity()) .setCountry(userAddress.getCountry()) .setPostalCode(userAddress.getPostalCode()) .build(); // Create a tax calculation using the Stripe API CalculationCreateParams params = CalculationCreateParams .builder() .setCurrency(cart.getCurrency()) .addAllLineItem(lineItems) .setCustomerDetails( CalculationCreateParams.CustomerDetails .builder() .setAddress(address) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .build() ) .addExpand("line_items.data.tax_breakdown") .build(); Calculation calculation = Calculation.create(params); // Return the tax amount as a JSON response return Map.of( "tax_amount", calculation.getTaxAmountExclusive() ); } } } ``` #### Ruby ```ruby require 'stripe' require 'sinatra' # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' set :static, true set :port, 4242 post '/preview-cart' do payload = JSON.parse(request.body.read) # Parse the request body as JSON. cart = ... # Load the cart/order from your system # Convert each cart item to a Stripe line item object line_items = cart.items.map do |cart_item| { reference: cart_item.id, amount: cart_item.unit_price * cart_item.quantity, quantity: cart_item.quantity } end # Get the customer's address from the request body address = payload['address'] # Create a tax calculation using the Stripe API calculation = Stripe::Tax::Calculation.create({ currency: cart.currency, line_items: line_items, customer_details: { address: { line1: address['line1'], line2: address['line2'], city: address['city'], state: address['state'], postal_code: address['postal_code'], country: address['country'], }, address_source: 'billing', }, expand: ['line_items.data.tax_breakdown'], }) # Return the tax amount as a JSON response { tax_amount: calculation.tax_amount_exclusive }.to_json end ``` #### PHP ```php >'); $app->post('/preview-cart', function($request, $response) { $cart = ...; // Load the cart/order from your system // Convert each cart item to a Stripe line item object $lineItems = array_map(fn($cartItem) => [ 'reference' => $cartItem->id, 'amount' => $cartItem->quantity * $cartItem->unitPrice, 'quantity' => $cartItem->quantity, ], $cart->getItems()); // Get the customer's address from the request body $address = $request->getParsedBody()['address']; // Create a tax calculation using the Stripe API $calculation = $stripe->tax->calculations->create([ 'currency' => $cart->currency, 'line_items' => $line_items, 'customer_details' => [ 'address' => [ 'line1' => $address['line1'], 'line2' => $address['line2'], 'city' => $address['city'], 'state' => $address['state'], 'postal_code' => $address['postal_code'], 'country' => $address['country'], ], 'address_source' => 'billing', ], 'expand' => ['line_items.data.tax_breakdown'], ]); # Return the tax amount as a JSON response return $response->withJson([ 'tax_amount' => $calculation->tax_amount_exclusive ]); }); ``` #### Python ```python from flask import Flask, request import stripe # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys stripe.api_key = '<>' app = Flask(__name__, static_url_path='', static_folder='public') @app.route('/preview-cart', methods=['POST']) def preview_cart(): # Load the cart/order from your system cart = ... # Convert each cart item to a Stripe line item object line_items = [{ 'reference': cart_item.id, 'amount': cart_item.unit_price * cart_item.quantity, 'quantity': cart_item.quantity } for cart_item in cart.items] # Get the customer's address from the request body address = request.json['address'] # Create a tax calculation using the Stripe API calculation = stripe.tax.Calculation.create( currency=cart.currency, line_items=line_items, customer_details={ 'address': { 'line1': address.get('line1', ''), 'line2': address.get('line2', ''), 'city': address.get('city', ''), 'state': address.get('state', ''), 'postal_code': address.get('postal_code', ''), 'country': address.get('country', ''), }, 'address_source': 'billing' }, expand=['line_items.data.tax_breakdown'] ) # Return the tax amount as a JSON response return { 'tax_amount': calculation['tax_amount_exclusive'] } if __name__ == '__main__': app.run(port=4242) ``` #### Go ```go package main import ( "log" "encoding/json" "io/ioutil" "net/http" "github.com/stripe/stripe-go/v74" "github.com/stripe/stripe-go/v74/tax/calculation" "github.com/stripe/stripe-go/v74" ) func main() { // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" http.Handle("/", http.FileServer(http.Dir("public"))) http.HandleFunc("/preview-cart", previewCart) addr := "localhost:4242" log.Printf("Listening on %s", addr) log.Fatal(http.ListenAndServe(addr, nil)) } type RequestBody struct { Address map[string]string `json:"address"` } func previewCart(w http.ResponseWriter, r *http.Request) { cart := ... // Load the cart/order from your system // Convert each cart item to a Stripe line item object var lineItems []*stripe.TaxCalculationLineItemParams for _, cartItem := range cart.Items { item := &stripe.TaxCalculationLineItemParams{ Amount: stripe.Int64(cartItem.UnitPrice * cartItem.Quantity), Reference: stripe.String(cartItem.Id), Quantity: stripe.Int64(cartItem.Quantity), } lineItems = append(lineItems, item) } // Get the customer's address from the request body body, err := ioutil.ReadAll(r.Body) if err != nil { panic(err) } var parsedBody RequestBody err = json.Unmarshal([]byte(body), &parsedBody) if err != nil { http.Error(w, "Invalid address parameter", http.StatusBadRequest) return } address := parsedBody.Address // Create a tax calculation using the Stripe API params := &stripe.TaxCalculationParams{ Currency: stripe.String(cart.Currency), LineItems: lineItems, CustomerDetails: &stripe.TaxCalculationCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String(address["line1"]), Line2: stripe.String(address["line2"]), City: stripe.String(address["city"]), State: stripe.String(address["state"]), PostalCode: stripe.String(address["postal_code"]), Country: stripe.String(address["country"]), }, AddressSource: stripe.String(string(stripe.TaxCalculationCustomerDetailsAddressSourceBilling)), }, }; params.AddExpand("line_items.data.tax_breakdown") result, _ := calculation.New(params); // Return the tax amount as a JSON response data := map[string]interface{}{ "tax_amount": result.TaxAmountExclusive, } json.NewEncoder(w).Encode(data) } ``` #### .NET ```dotnet using System.Collections.Generic; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Stripe; using Stripe.Tax; namespace server.Controllers { public class Program { public static void Main(string[] args) { WebHost.CreateDefaultBuilder(args) .UseUrls("http://0.0.0.0:4242") .UseWebRoot("public") .UseStartup() .Build() .Run(); } } public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddNewtonsoftJson(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; if (env.IsDevelopment()) app.UseDeveloperExceptionPage(); app.UseRouting(); app.UseStaticFiles(); app.UseEndpoints(endpoints => endpoints.MapControllers()); } } [Route("preview-cart")] [ApiController] public class PreviewCartController : Controller { [HttpPost] public ActionResult Preview([FromBody] Address address) { var cart = ...; // Load the cart/order from your system // Convert each cart item to a Stripe line item object var lineItems = new List(); foreach (var cartItem in cart.Items) { lineItems.Add(new CalculationLineItemOptions { Reference = cartItem.Id, Amount = cartItem.Quantity * cartItem.UnitPrice, Quantity = cartItem.Quantity }); } // Create a tax calculation using the Stripe API var options = new CalculationCreateOptions { Currency = cart.Currency, LineItems = LineItems, CustomerDetails = new CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = address.Line1, Line2 = address.Line2, City = address.City, State = address.State, PostalCode = address.PostalCode, Country = address.Country, }, AddressSource = "billing", }, Expand = new List { "line_items.data.tax_breakdown" }, }; var service = new CalculationService(); var calculation = service.Create(options); // Return the tax amount as a JSON response var preview = new Dictionary { { "tax_amount", calculation.TaxAmountExclusive }, }; return Json(preview); } } } ``` Wenn Sie bereit sind, Zahlungen entgegenzunehmen, erstellen Sie einen PaymentIntent aus dem Ergebnis der Steuerberechnung. Speichern Sie die Steuerberechnungs-ID in den [Metadaten](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-metadata) des PaymentIntent oder in Ihrer eigenen Datenbank, damit Sie eine Steuertransaktion erstellen können, wenn Ihre Kundin oder Ihr Kunde die Zahlung abschließt. Das folgende Beispiel zeigt einen Server-Endpunkt, der die Steuer berechnet, einen PaymentIntent erstellt (oder aktualisiert) und das Ergebnis an den Client zurückgibt. Sie können dann die Steuer für Ihre Kundin oder Ihren Kunden anzeigen. Verwenden Sie das `client_secret`, um [die Zahlung anzunehmen](https://docs.stripe.com/payments/accept-a-payment.md?platform=web&ui=elements#web-collect-payment-details). #### Node.js ```javascript // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const express = require('express'); const app = express(); // Parse the request body as JSON. app.use(express.json()); app.post('/calculate-cart', async (req, res) => { const cart = ...; // Load the cart/order from your system // Create a tax calculation using the Stripe API const calculation = await stripe.tax.calculations.create(...); let paymentIntent; // Update the PaymentIntent if one already exists for this cart. if (cart.paymentIntent) { paymentIntent = await stripe.paymentIntents.update(cart.paymentIntent, { amount: calculation.amount_total, metadata: {tax_calculation: calculation.id}, }); } else { paymentIntent = await stripe.paymentIntents.create({ currency: cart.currency, amount: calculation.amount_total, metadata: {tax_calculation: calculation.id}, // In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default. automatic_payment_methods: {enabled: true}, }); } // Store PaymentIntent ID in cart or customer session. cart.paymentIntent = paymentIntent.id; // Return calculated amounts and PaymentIntent secret to the client. res.json({ total: calculation.amount_total, tax_amount: calculation.tax_amount_exclusive, client_secret: paymentIntent.client_secret }); }); app.listen(4242, () => { console.log('Running on port 4242'); }); ``` #### Java ```java package com.stripe.sample; import static spark.Spark.post; import static spark.Spark.port; import static spark.Spark.staticFiles; import com.stripe.Stripe; import com.stripe.exception.StripeException; import com.stripe.model.PaymentIntent; import com.stripe.model.tax.Calculation; import com.stripe.param.PaymentIntentCreateParams; import com.stripe.param.PaymentIntentUpdateParams; import com.stripe.param.tax.CalculationCreateParams; public class Server { public static void main(String[] args) throws StripeException { port(4242); // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; post("/calculate-cart", (request, response) -> { var cart = ...; // Load the cart/order from your system // Create a tax calculation using the Stripe API CalculationCreateParams params = ...; Calculation calculation = Calculation.create(params); PaymentIntent paymentIntent; // Update the PaymentIntent if one already exists for this cart. if (cart.paymentIntent != null){ paymentIntent = PaymentIntent.retrieve(cart.paymentIntent); PaymentIntentUpdateParams params = PaymentIntentUpdateParams.builder() .setAmount(calculation.getAmountTotal()) .putMetadata("tax_calculation", calculation.getId()) .build(); paymentIntent = paymentIntent.update(params); } else { PaymentIntentCreateParams params = PaymentIntentCreateParams.builder() .setAmount(calculation.getAmountTotal()) .setCurrency(cart.getCurrency()) // In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default. .setAutomaticPaymentMethods( PaymentIntentCreateParams.AutomaticPaymentMethods.builder() .setEnabled(true) .build() ) .putMetadata("tax_calculation", calculation.getId()) .build(); paymentIntent = PaymentIntent.create(params); } // Store PaymentIntent ID in cart or customer session. cart.setPaymentIntent(paymentIntent.getId()); return Map.of( "total", calculation.getAmountTotal(), "tax_amount", calculation.getTaxAmountExclusive(), "client_secret", paymentIntent.getClientSecret() ); }); } } ``` #### Ruby ```ruby require 'stripe' require 'sinatra' # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' set :static, true set :port, 4242 post '/calculate-cart' do cart = ... # Load the cart/order from your system # Create a tax calculation using the Stripe API calculation = Stripe::Tax::Calculation.create(...) # Update the PaymentIntent if one already exists for this cart. if cart.payment_intent.present? payment_intent = Stripe::PaymentIntent.update( cart.payment_intent, { amount: calculation.amount_total, metadata: {tax_calculation: calculation.id}, }, ) else payment_intent = Stripe::PaymentIntent.create({ amount: calculation.amount_total, currency: cart.currency, # In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default. automatic_payment_methods: {enabled: true}, metadata: {tax_calculation: calculation.id}, }) end # Store PaymentIntent ID in cart or customer session. cart.payment_intent = payment_intent.id # Return calculated amounts and PaymentIntent secret to the client. result = { total: calculation.amount_total, tax_amount: calculation.tax_amount_exclusive, client_secret: payment_intent.client_secret } result.to_json end ``` #### PHP ```php >'); $app->post('/calculate-cart', function($request, $response) { $cart = $body['cart']; // Load the cart/order from your system // Create a tax calculation using the Stripe API $calculation = $stripe->tax->calculations->create(...) // Update the PaymentIntent if one already exists for this cart. if ($cart->paymentIntent) { $paymentIntent = $stripe->paymentIntents->update($cart->paymentIntent, [ 'amount' => $calculation->amount_total, 'metadata' => [ 'tax_calculation' => $calculation->id ] ]); } else { $paymentIntent = $stripe->paymentIntents->create([ 'amount' => $calculation->amount_total, 'currency' => $cart->currency, // In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default. 'automatic_payment_methods' => [ 'enabled' => true, ], 'metadata' => [ 'tax_calculation' => $calculation->id ] ]); } // Store PaymentIntent ID in cart or customer session. $cart->paymentIntent = $paymentIntent->id; // Return calculated amounts and PaymentIntent secret to the client. return $response->withJson([ 'total' => $calculation->amount_total, 'tax_amount' => $calculation->tax_amount_exclusive, 'client_secret' => $calculation->client_secret ]); }); ``` #### Python ```python import os from flask import Flask, request import stripe # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys stripe.api_key = '<>' app = Flask(__name__, static_url_path='', static_folder='public') @app.route('/calculate-cart', methods=['POST']) def calculate_cart(): # Load the cart/order from your system cart = ... # Create a tax calculation using the Stripe API calculation = stripe.tax.Calculation.create( #... ) payment_intent = None # Update the PaymentIntent if one already exists for this cart. if cart.payment_intent: payment_intent = stripe.PaymentIntent.modify( cart.payment_intent, amount=calculation.amount_total, metadata={"tax_calculation": calculation.id}, ) else: payment_intent = stripe.PaymentIntent.create( amount=calculation.amount_total, currency=cart.currency, # In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default. automatic_payment_methods={"enabled": True}, metadata={"tax_calculation": calculation.id}, ) # Store PaymentIntent ID in cart or customer session. cart.payment_intent = payment_intent.id # Return calculated amounts and PaymentIntent secret to the client. return { 'total': calculation.amount_total, 'tax_amount': calculation.tax_amount_exclusive, 'client_secret': payment_intent.client_secret } if __name__ == '__main__': app.run(port=4242) ``` #### Go ```go package main import ( "log" "encoding/json" "net/http" "github.com/stripe/stripe-go/v74" "github.com/stripe/stripe-go/v74/paymentintent" "github.com/stripe/stripe-go/v74/tax/calculation" ) func main() { // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" http.Handle("/", http.FileServer(http.Dir("public"))) http.HandleFunc("/calculate-cart", calculateCart) addr := "localhost:4242" log.Printf("Listening on %s", addr) log.Fatal(http.ListenAndServe(addr, nil)) } func calculateCart(w http.ResponseWriter, r *http.Request) { cart := ... // Load the cart/order from your system // Create a tax calculation using the Stripe API calculation, _ := calculation.New(...); // Update the PaymentIntent if one already exists for this cart. if cart.PaymentIntent != nil { params := &stripe.PaymentIntentParams{ Amount: &calculation.AmountTotal, } params.AddMetadata("tax_calculation", calculation.ID) pi, _ := paymentintent.Update(cart.PaymentIntent, params,) } else { params := &stripe.PaymentIntentParams{ Currency: stripe.String(string(cart.Currency)), Amount: &calculation.AmountTotal, // In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default. AutomaticPaymentMethods: &stripe.PaymentIntentAutomaticPaymentMethodsParams{ Enabled: stripe.Bool(true), }, } params.AddMetadata("tax_calculation", calculation.ID) pi, _ := paymentintent.New(params) } // Store PaymentIntent ID in cart or customer session. cart.SetPaymentIntent(pi.ID) result := map[string]interface{}{ "total": calculation.AmountTotal, "tax_amount": calculation.TaxAmountExclusive, "client_secret": pi.ClientSecret, } json.NewEncoder(w).Encode(result) } ``` #### .NET ```dotnet using System.Collections.Generic; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Stripe; using Stripe.Tax; namespace server.Controllers { public class Program { public static void Main(string[] args) { WebHost.CreateDefaultBuilder(args) .UseUrls("http://0.0.0.0:4242") .UseWebRoot("public") .UseStartup() .Build() .Run(); } } public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddNewtonsoftJson(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; if (env.IsDevelopment()) app.UseDeveloperExceptionPage(); app.UseRouting(); app.UseStaticFiles(); app.UseEndpoints(endpoints => endpoints.MapControllers()); } } [Route("calculate-cart")] [ApiController] public class CalculateCartController : Controller { [HttpPost] public ActionResult Calculate([FromBody] Address address) { var cart = ...; // load cart from your system // Create a tax calculation using the Stripe API var taxService = new CalculationService(); var calculation = taxService.Create(...); var paymentService = new PaymentIntentService(); PaymentIntent paymentIntent; // Update the PaymentIntent if one already exists for this cart. if (cart.PaymentIntent != null) { var options = new PaymentIntentUpdateOptions { Amount = calculation.AmountTotal, Metadata = new Dictionary { { "tax_calculation", calculation.Id }, }, }; paymentIntent = paymentService.Update(cart.PaymentIntent, options); } else { var options = new PaymentIntentCreateOptions { Amount = calculation.AmountTotal, Currency = cart.Currency, // In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default. AutomaticPaymentMethods = new PaymentIntentAutomaticPaymentMethodsOptions { Enabled = true, }, Metadata = new Dictionary { { "tax_calculation", calculation.Id }, }, }; paymentIntent = paymentService.Create(options); } // Store PaymentIntent ID in cart or customer session. cart.PaymentIntent = paymentIntent.Id; var result = new Dictionary { { "total", calculation.AmountTotal }, { "tax_amount", calculation.TaxAmountExclusive }, { "client_secret", paymentIntent.ClientSecret }, }; return Json(result); } } } ``` Wenn Ihre Integration das Payment Element verwendet, [rufen Sie Updates vom Server ab](https://docs.stripe.com/payments/accept-a-payment.md?platform=web&ui=elements#fetch-updates), nachdem Sie den PaymentIntent aktualisiert haben. ## Optional: Berechnung der Steuer auf die Versandkosten [Serverseitig] Verwenden Sie den Parameter `shipping_cost`, um die Steuer auf die Versandkosten zu berechnen: ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, shipping_cost: { amount: 500, tax_code: 'txcd_92010001', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": { "address": { "line1": "920 5th Ave", "city": "Seattle", "state": "WA", "postal_code": "98104", "country": "US", }, "address_source": "shipping", }, "shipping_cost": {"amount": 500, "tax_code": "txcd_92010001"}, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => [ 'address' => [ 'line1' => '920 5th Ave', 'city' => 'Seattle', 'state' => 'WA', 'postal_code' => '98104', 'country' => 'US', ], 'address_source' => 'shipping', ], 'shipping_cost' => [ 'amount' => 500, 'tax_code' => 'txcd_92010001', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("920 5th Ave") .setCity("Seattle") .setState("WA") .setPostalCode("98104") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .setShippingCost( CalculationCreateParams.ShippingCost.builder() .setAmount(500L) .setTaxCode("txcd_92010001") .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, shipping_cost: { amount: 500, tax_code: 'txcd_92010001', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("920 5th Ave"), City: stripe.String("Seattle"), State: stripe.String("WA"), PostalCode: stripe.String("98104"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, ShippingCost: &stripe.TaxCalculationCreateShippingCostParams{ Amount: stripe.Int64(500), TaxCode: stripe.String("txcd_92010001"), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "920 5th Ave", City = "Seattle", State = "WA", PostalCode = "98104", Country = "US", }, AddressSource = "shipping", }, ShippingCost = new Stripe.Tax.CalculationShippingCostOptions { Amount = 500, TaxCode = "txcd_92010001", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` Übergeben Sie die ID einer vorhandenen [ShippingRate](https://docs.stripe.com/api/shipping_rates/object.md), um dessen `amount`, `tax_code` und `tax_behavior` zu verwenden: ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, shipping_cost: {shipping_rate: 'shr_1Mlh8YI6rIcR421eUr9SJzAD'}, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": { "address": { "line1": "920 5th Ave", "city": "Seattle", "state": "WA", "postal_code": "98104", "country": "US", }, "address_source": "shipping", }, "shipping_cost": {"shipping_rate": "shr_1Mlh8YI6rIcR421eUr9SJzAD"}, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => [ 'address' => [ 'line1' => '920 5th Ave', 'city' => 'Seattle', 'state' => 'WA', 'postal_code' => '98104', 'country' => 'US', ], 'address_source' => 'shipping', ], 'shipping_cost' => ['shipping_rate' => 'shr_1Mlh8YI6rIcR421eUr9SJzAD'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("920 5th Ave") .setCity("Seattle") .setState("WA") .setPostalCode("98104") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .setShippingCost( CalculationCreateParams.ShippingCost.builder() .setShippingRate("shr_1Mlh8YI6rIcR421eUr9SJzAD") .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, shipping_cost: { shipping_rate: 'shr_1Mlh8YI6rIcR421eUr9SJzAD', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("920 5th Ave"), City: stripe.String("Seattle"), State: stripe.String("WA"), PostalCode: stripe.String("98104"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, ShippingCost: &stripe.TaxCalculationCreateShippingCostParams{ ShippingRate: stripe.String("shr_1Mlh8YI6rIcR421eUr9SJzAD"), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "920 5th Ave", City = "Seattle", State = "WA", PostalCode = "98104", Country = "US", }, AddressSource = "shipping", }, ShippingCost = new Stripe.Tax.CalculationShippingCostOptions { ShippingRate = "shr_1Mlh8YI6rIcR421eUr9SJzAD", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` ## Optional: Steuern mit einer IP-Adresse schätzen [Serverseitig] Wenn Sie die [IP-Adresse](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-customer_details-ip_address) Ihrer Kundinnen und Kunden angeben, wird sie geolokalisiert und als Kundenstandort verwendet. Auf diese Weise können Sie Kundinnen und Kunden eine Steuerschätzung anzeigen, bevor sie ihre Postanschrift angeben. > Da der Standort einer IP-Adresse möglicherweise weit vom tatsächlichen Standort der Kundin oder des Kunden entfernt ist, raten wir davon ab, eine IP-Adresse zur Ermittlung des *endgültigen* Steuerbetrags zu verwenden. ```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" ``` ```cli stripe tax calculations create \ --currency=usd \ -d "line_items[0][amount]"=1000 \ -d "line_items[0][reference]"=L1 \ -d "customer_details[ip_address]"="127.0.0.1" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: {ip_address: '127.0.0.1'}, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": {"ip_address": "127.0.0.1"}, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => ['ip_address' => '127.0.0.1'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder().setIpAddress("127.0.0.1").build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { ip_address: '127.0.0.1', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ IPAddress: stripe.String("127.0.0.1"), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { IpAddress = "127.0.0.1", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` ## Optional: Steueridentifikationsnummern von Kundinnen und Kunden erfassen [Serverseitig] In einigen Fällen, wie etwa bei grenzüberschreitenden Dienstleistungen, muss Ihre Kundin oder Ihr Kunde die Steuer möglicherweise auf [Reverse-Charge](https://docs.stripe.com/tax/zero-tax.md#reverse-charges)-Basis abrechnen. Anstatt die Steuer einzuziehen, müssen Sie eine Rechnung mit dem Text „Steuer vom Leistungsempfänger zu zahlen“ ausstellen. Dies informiert Ihre Kundin oder Ihren Kunden darüber, dass sie oder er für die Steuer auf den Kauf verantwortlich ist. Geben Sie die [Steueridentifikationsnummern](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-customer_details-tax_ids) Ihrer Kundinnen und Kunden an, um automatisch zu bestimmen, wann die Umkehrung der Steuerschuld (Reverse Charge) angewendet wird: ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: {country: 'IE'}, address_source: 'billing', tax_ids: [ { type: 'eu_vat', value: 'DE123456789', }, ], }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": { "address": {"country": "IE"}, "address_source": "billing", "tax_ids": [{"type": "eu_vat", "value": "DE123456789"}], }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => [ 'address' => ['country' => 'IE'], 'address_source' => 'billing', 'tax_ids' => [ [ 'type' => 'eu_vat', 'value' => 'DE123456789', ], ], ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setCountry("IE") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .addTaxId( CalculationCreateParams.CustomerDetails.TaxId.builder() .setType(CalculationCreateParams.CustomerDetails.TaxId.Type.EU_VAT) .setValue("DE123456789") .build() ) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { country: 'IE', }, address_source: 'billing', tax_ids: [ { type: 'eu_vat', value: 'DE123456789', }, ], }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{Country: stripe.String("IE")}, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), TaxIDs: []*stripe.TaxCalculationCreateCustomerDetailsTaxIDParams{ &stripe.TaxCalculationCreateCustomerDetailsTaxIDParams{ Type: stripe.String(stripe.TaxCalculationCustomerDetailsTaxIDTypeEUVAT), Value: stripe.String("DE123456789"), }, }, }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Country = "IE" }, AddressSource = "billing", TaxIds = new List { new Stripe.Tax.CalculationCustomerDetailsTaxIdOptions { Type = "eu_vat", Value = "DE123456789", }, }, }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` Wenn Sie eine Steueridentifikationsnummer mit einem ungültigen Format angeben, gibt die Berechnung den Fehlercode `tax_id_invalid` zurück: ```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" } } ``` Die Tax API validiert Steueridentifikationsnummern nicht automatisch gegen staatliche Datenbanken. Um eine Steueridentifikationsnummer vor der Steuerberechnung zu validieren, müssen Sie die [Validierung der Kunden-Steueridentifikationsnummer](https://docs.stripe.com/billing/customer/tax-ids.md#validation) verwenden. ## Optional: Preisangaben inklusive Steuern [Serverseitig] Standardmäßig wird die Steuer zusätzlich zu den von Ihnen angegebenen Beträgen für Einzelposten und Versandkosten berechnet. Um die in Ihren Preisen enthaltene Steuer zu berechnen, setzen Sie `tax_behavior` für den [Einzelposten](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-line_items-tax_behavior) oder die [Versandkosten](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-shipping_cost-tax_behavior) auf `inklusive`. Im folgenden Beispiel zahlt die Kundin oder der immer 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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 10000, reference: 'L1', tax_behavior: 'inclusive', tax_code: 'txcd_10103000', }, ], customer_details: { address: {country: 'IE'}, address_source: 'billing', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "eur", "line_items": [ { "amount": 10000, "reference": "L1", "tax_behavior": "inclusive", "tax_code": "txcd_10103000", }, ], "customer_details": {"address": {"country": "IE"}, "address_source": "billing"}, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'eur', 'line_items' => [ [ 'amount' => 10000, 'reference' => 'L1', 'tax_behavior' => 'inclusive', 'tax_code' => 'txcd_10103000', ], ], 'customer_details' => [ 'address' => ['country' => 'IE'], 'address_source' => 'billing', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("eur") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(10000L) .setReference("L1") .setTaxBehavior(CalculationCreateParams.LineItem.TaxBehavior.INCLUSIVE) .setTaxCode("txcd_10103000") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setCountry("IE") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 10000, reference: 'L1', tax_behavior: 'inclusive', tax_code: 'txcd_10103000', }, ], customer_details: { address: { country: 'IE', }, address_source: 'billing', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyEUR), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(10000), Reference: stripe.String("L1"), TaxBehavior: stripe.String("inclusive"), TaxCode: stripe.String("txcd_10103000"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{Country: stripe.String("IE")}, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "eur", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 10000, Reference = "L1", TaxBehavior = "inclusive", TaxCode = "txcd_10103000", }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Country = "IE" }, AddressSource = "billing", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` Die Antwort gibt die enthaltene Steuer zurück: ```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: Ein vorhandenes Produktobjekt verwenden [Serverseitig] Sie können für jeden Posten ein [Produktobjekt](https://docs.stripe.com/api/products/object.md) angeben. Wenn das Produkt einen [tax_code](https://docs.stripe.com/api/products/object.md#product_object-tax_code) hat, verwenden wir diesen als `tax_code` – sofern er nicht bereits ausgefüllt ist. Andere Produktwerte einschließlich `tax_behavior` und `Preis` werden bei der Steuerberechnung nicht berücksichtigt. ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', product: '{{PRODUCT_ID}}', }, ], customer_details: { address: {country: 'IE'}, address_source: 'billing', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1", "product": "{{PRODUCT_ID}}"}], "customer_details": {"address": {"country": "IE"}, "address_source": "billing"}, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', 'product' => '{{PRODUCT_ID}}', ], ], 'customer_details' => [ 'address' => ['country' => 'IE'], 'address_source' => 'billing', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .setProduct("{{PRODUCT_ID}}") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setCountry("IE") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', product: '{{PRODUCT_ID}}', }, ], customer_details: { address: { country: 'IE', }, address_source: 'billing', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), Product: stripe.String("{{PRODUCT_ID}}"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{Country: stripe.String("IE")}, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1", Product = "{{PRODUCT_ID}}", }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Country = "IE" }, AddressSource = "billing", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` ## Optional: Ein vorhandenes Kundenobjekt verwenden [Serverseitig] Wenn Sie ein [Kundenobjekt](https://docs.stripe.com/api/customers/object.md) angeben, kopieren und verwenden wir automatisch die Kundenadresse und die Steueridentifikationsnummern für die Berechnung: - Wenn die `shipping`-Adresse von Kundinnen oder Kunden vorhanden ist, wird sie in `customer_details.address` kopiert. - Andernfalls, falls die `address` der Kundin oder des Kunden vorhanden ist, wird sie in `customer_details.address` kopiert. - Andernfalls, wenn die Kunden-`tax.ip_address` vorhanden ist, wird sie in `customer_details.ip_address` kopiert. - Andernfalls, wenn der `tax.tax_exempt` der Kundin oder des Kunden vorhanden ist, wird er in `customer_details.taxability_override` kopiert. Die [Steueridentifikationsnummern](https://docs.stripe.com/api/customer_tax_ids.md) von Kundinnen und Kunden werden in `customer_details.tax_ids` kopiert. ```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}}" ``` ```cli stripe tax calculations create \ --currency=usd \ -d "line_items[0][amount]"=1000 \ -d "line_items[0][reference]"=L1 \ --customer="{{CUSTOMER_ID}}" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer: '{{CUSTOMER_ID}}', }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer": "{{CUSTOMER_ID}}", }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer' => '{{CUSTOMER_ID}}', ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomer("{{CUSTOMER_ID}}") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer: '{{CUSTOMER_ID}}', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, Customer: stripe.String("{{CUSTOMER_ID}}"), } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, Customer = "{{CUSTOMER_ID}}", }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` ## Optional: Kundensteuerbarkeit aufheben [Serverseitig] In bestimmten Fällen müssen Sie keine Steuer erheben, z. B. wenn Ihre Kundin oder Ihr Kunde steuerbefreit ist. Sie können die Steuerbefreiung über den Parameter [taxability_override](https://docs.stripe.com/api/tax/calculations/create.md#calculate_tax-customer_details-taxability_override) an Stripe Tax übermitteln. So geben Sie die Überschreibung der Kundensteuerpflicht in Ihren Berechnungen an: ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'billing', taxability_override: 'customer_exempt', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": { "address": { "line1": "920 5th Ave", "city": "Seattle", "state": "WA", "postal_code": "98104", "country": "US", }, "address_source": "billing", "taxability_override": "customer_exempt", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => [ 'address' => [ 'line1' => '920 5th Ave', 'city' => 'Seattle', 'state' => 'WA', 'postal_code' => '98104', 'country' => 'US', ], 'address_source' => 'billing', 'taxability_override' => 'customer_exempt', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("920 5th Ave") .setCity("Seattle") .setState("WA") .setPostalCode("98104") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .setTaxabilityOverride( CalculationCreateParams.CustomerDetails.TaxabilityOverride.CUSTOMER_EXEMPT ) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'billing', taxability_override: 'customer_exempt', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("920 5th Ave"), City: stripe.String("Seattle"), State: stripe.String("WA"), PostalCode: stripe.String("98104"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), TaxabilityOverride: stripe.String(stripe.TaxCalculationCustomerDetailsTaxabilityOverrideCustomerExempt), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "920 5th Ave", City = "Seattle", State = "WA", PostalCode = "98104", Country = "US", }, AddressSource = "billing", TaxabilityOverride = "customer_exempt", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` ### Umkehrung der Steuerschuld In einigen Regionen, wie z. B. in der Europäischen Union, gilt ein „Reverse-Charge“-System, bei dem Kundinnen und Kunden für die Abrechnung der Steuern verantwortlich ist, wenn sie als Unternehmen einkaufen. Damit Stripe Tax die korrekte steuerliche Behandlung anwendet, empfehlen wir Ihnen, [Steueridentifikationsnummern](https://docs.stripe.com/tax/custom.md#tax-ids) von Ihren Kundinnen und Kunden zu erfassen. Manchmal liegen Ihnen die Steueridentifikationsnummern Ihrer Kundinnen und Kunden nicht vor oder Sie haben separat festgelegt, dass die Umkehrung der Steuerschuld gilt. In solchen Fällen können Sie `taxability_override` verwenden, um Stripe Tax zu zwingen, das Reverse-Charge-Verfahren anzuwenden. So geben Sie die Überschreibung der Kundensteuerpflicht in Ihren Berechnungen an: ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: {country: 'IE'}, address_source: 'billing', taxability_override: 'reverse_charge', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "eur", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": { "address": {"country": "IE"}, "address_source": "billing", "taxability_override": "reverse_charge", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'eur', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => [ 'address' => ['country' => 'IE'], 'address_source' => 'billing', 'taxability_override' => 'reverse_charge', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("eur") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setCountry("IE") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .setTaxabilityOverride( CalculationCreateParams.CustomerDetails.TaxabilityOverride.REVERSE_CHARGE ) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'eur', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { country: 'IE', }, address_source: 'billing', taxability_override: 'reverse_charge', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyEUR), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{Country: stripe.String("IE")}, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), TaxabilityOverride: stripe.String(stripe.TaxCalculationCustomerDetailsTaxabilityOverrideReverseCharge), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "eur", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Country = "IE" }, AddressSource = "billing", TaxabilityOverride = "reverse_charge", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` ## Optional: Einen Absenderort angeben [Serverseitig] Wenn Sie Waren von einem anderen Standort als Ihrem Hauptgeschäftssitz aus versenden, können Sie diese Adresse für die Steuerberechnungen angeben. Verwenden Sie den Parameter `ship_from_details`, um einen Absenderort anzugeben. In diesem Beispiel ist der/die Nutzer/in in Florida ansässig, der Kunde/die Kundin ist in Springfield, IL und der/die Nutzer/in versendet die Waren aus Naperville, IL: ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_behavior: 'exclusive', tax_code: 'txcd_99999999', }, ], customer_details: { address: { city: 'Springfield', state: 'IL', postal_code: '62704', country: 'US', }, address_source: 'billing', }, ship_from_details: { address: { city: 'Naperville', state: 'IL', postal_code: '60540', country: 'US', }, }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [ { "amount": 1000, "reference": "L1", "tax_behavior": "exclusive", "tax_code": "txcd_99999999", }, ], "customer_details": { "address": { "city": "Springfield", "state": "IL", "postal_code": "62704", "country": "US", }, "address_source": "billing", }, "ship_from_details": { "address": { "city": "Naperville", "state": "IL", "postal_code": "60540", "country": "US", }, }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', 'tax_behavior' => 'exclusive', 'tax_code' => 'txcd_99999999', ], ], 'customer_details' => [ 'address' => [ 'city' => 'Springfield', 'state' => 'IL', 'postal_code' => '62704', 'country' => 'US', ], 'address_source' => 'billing', ], 'ship_from_details' => [ 'address' => [ 'city' => 'Naperville', 'state' => 'IL', 'postal_code' => '60540', 'country' => 'US', ], ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .setTaxBehavior(CalculationCreateParams.LineItem.TaxBehavior.EXCLUSIVE) .setTaxCode("txcd_99999999") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setCity("Springfield") .setState("IL") .setPostalCode("62704") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.BILLING) .build() ) .setShipFromDetails( CalculationCreateParams.ShipFromDetails.builder() .setAddress( CalculationCreateParams.ShipFromDetails.Address.builder() .setCity("Naperville") .setState("IL") .setPostalCode("60540") .setCountry("US") .build() ) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_behavior: 'exclusive', tax_code: 'txcd_99999999', }, ], customer_details: { address: { city: 'Springfield', state: 'IL', postal_code: '62704', country: 'US', }, address_source: 'billing', }, ship_from_details: { address: { city: 'Naperville', state: 'IL', postal_code: '60540', country: 'US', }, }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), TaxBehavior: stripe.String("exclusive"), TaxCode: stripe.String("txcd_99999999"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ City: stripe.String("Springfield"), State: stripe.String("IL"), PostalCode: stripe.String("62704"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceBilling), }, ShipFromDetails: &stripe.TaxCalculationCreateShipFromDetailsParams{ Address: &stripe.AddressParams{ City: stripe.String("Naperville"), State: stripe.String("IL"), PostalCode: stripe.String("60540"), Country: stripe.String("US"), }, }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1", TaxBehavior = "exclusive", TaxCode = "txcd_99999999", }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { City = "Springfield", State = "IL", PostalCode = "62704", Country = "US", }, AddressSource = "billing", }, }; options.AddExtraParam("ship_from_details[address][city]", "Naperville"); options.AddExtraParam("ship_from_details[address][state]", "IL"); options.AddExtraParam("ship_from_details[address][postal_code]", "60540"); options.AddExtraParam("ship_from_details[address][country]", "US"); var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` Die Antwort gibt die berechnete Steuer basierend auf dem Versandort der Bestellung (Naperville, IL) zurück, anstatt auf dem Bestimmungsort (Springfield, IL) oder dem Geschäftssitz der Verkäuferin oder des Verkäufers: ```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 } ], ... } ``` Weitere Informationen zur Berechnung von Steuern in diesen Szenarien finden Sie in der [Dokumentation zu Stripe Tax](https://docs.stripe.com/tax/calculating.md). ## Optional: Einzelhandelsliefergebühr berechnen [Serverseitig] Stripe Tax unterstützt die Berechnung der Liefergebühr für Einzelhändler/innen in Minnesota und Colorado. Nachdem Sie in den unterstützten Bundesstaaten eine Steuerregistrierung vom Typ `state_retail_delivery_fee` hinzugefügt haben, wird die Liefergebühr für Einzelhändler/innen anhand von Steuerberechnungen berechnet. ```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 ``` ```cli stripe tax registrations create \ --country=US \ -d "country_options[us][state]"=CO \ -d "country_options[us][type]"=state_retail_delivery_fee \ --active-from=now ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") registration = client.v1.tax.registrations.create({ country: 'US', country_options: { us: { state: 'CO', type: 'state_retail_delivery_fee', }, }, active_from: 'now', }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. registration = client.v1.tax.registrations.create({ "country": "US", "country_options": {"us": {"state": "CO", "type": "state_retail_delivery_fee"}}, "active_from": "now", }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $registration = $stripe->tax->registrations->create([ 'country' => 'US', 'country_options' => [ 'us' => [ 'state' => 'CO', 'type' => 'state_retail_delivery_fee', ], ], 'active_from' => 'now', ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); RegistrationCreateParams params = RegistrationCreateParams.builder() .setCountry("US") .setCountryOptions( RegistrationCreateParams.CountryOptions.builder() .setUs( RegistrationCreateParams.CountryOptions.Us.builder() .setState("CO") .setType( RegistrationCreateParams.CountryOptions.Us.Type.STATE_RETAIL_DELIVERY_FEE ) .build() ) .build() ) .setActiveFrom(RegistrationCreateParams.ActiveFrom.NOW) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Registration registration = client.v1().tax().registrations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const registration = await stripe.tax.registrations.create({ country: 'US', country_options: { us: { state: 'CO', type: 'state_retail_delivery_fee', }, }, active_from: 'now', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxRegistrationCreateParams{ Country: stripe.String("US"), CountryOptions: &stripe.TaxRegistrationCreateCountryOptionsParams{ US: &stripe.TaxRegistrationCreateCountryOptionsUSParams{ State: stripe.String("CO"), Type: stripe.String(stripe.TaxRegistrationCountryOptionsUSTypeStateRetailDeliveryFee), }, }, ActiveFromNow: stripe.Bool(true), } result, err := sc.V1TaxRegistrations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.RegistrationCreateOptions { Country = "US", CountryOptions = new Stripe.Tax.RegistrationCountryOptionsOptions { Us = new Stripe.Tax.RegistrationCountryOptionsUsOptions { State = "CO", Type = "state_retail_delivery_fee", }, }, ActiveFrom = Stripe.Tax.RegistrationActiveFrom.Now, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Registrations; Stripe.Tax.Registration registration = service.Create(options); ``` Um die Liefergebühr für Einzelhändler/innen zu berechnen, rufen Sie die Tax Calculations API unter Verwendung eines [Steuercodes für physische Posten](https://docs.stripe.com/tax/tax-codes.md?type=physical) auf, z. B. `txcd_30011000`, der für Kleidung und Schuhe steht. Nicht alle physischen Artikel lösen die Berechnung der Liefergebühr für Einzelhändler/innen aus. Informationen dazu, wann die Steuer anfällt, finden Sie in der Dokumentation des jeweiligen Bundesstaats: - [Einzelhandelsliefergebühr – Colorado](https://docs.stripe.com/tax/supported-countries/united-states/colorado.md#other-taxes) - [Einzelhandelsliefergebühr – Minnesota](https://docs.stripe.com/tax/supported-countries/united-states/minnesota.md#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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_behavior: 'exclusive', tax_code: 'txcd_30011000', }, ], shipping_cost: {amount: 400}, customer_details: { address: { line1: '1437 Bannock St Room 451', city: 'Springfield', state: 'CO', postal_code: '80202', country: 'US', }, address_source: 'shipping', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [ { "amount": 1000, "reference": "L1", "tax_behavior": "exclusive", "tax_code": "txcd_30011000", }, ], "shipping_cost": {"amount": 400}, "customer_details": { "address": { "line1": "1437 Bannock St Room 451", "city": "Springfield", "state": "CO", "postal_code": "80202", "country": "US", }, "address_source": "shipping", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', 'tax_behavior' => 'exclusive', 'tax_code' => 'txcd_30011000', ], ], 'shipping_cost' => ['amount' => 400], 'customer_details' => [ 'address' => [ 'line1' => '1437 Bannock St Room 451', 'city' => 'Springfield', 'state' => 'CO', 'postal_code' => '80202', 'country' => 'US', ], 'address_source' => 'shipping', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .setTaxBehavior(CalculationCreateParams.LineItem.TaxBehavior.EXCLUSIVE) .setTaxCode("txcd_30011000") .build() ) .setShippingCost( CalculationCreateParams.ShippingCost.builder().setAmount(400L).build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("1437 Bannock St Room 451") .setCity("Springfield") .setState("CO") .setPostalCode("80202") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_behavior: 'exclusive', tax_code: 'txcd_30011000', }, ], shipping_cost: { amount: 400, }, customer_details: { address: { line1: '1437 Bannock St Room 451', city: 'Springfield', state: 'CO', postal_code: '80202', country: 'US', }, address_source: 'shipping', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), TaxBehavior: stripe.String("exclusive"), TaxCode: stripe.String("txcd_30011000"), }, }, ShippingCost: &stripe.TaxCalculationCreateShippingCostParams{Amount: stripe.Int64(400)}, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("1437 Bannock St Room 451"), City: stripe.String("Springfield"), State: stripe.String("CO"), PostalCode: stripe.String("80202"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1", TaxBehavior = "exclusive", TaxCode = "txcd_30011000", }, }, ShippingCost = new Stripe.Tax.CalculationShippingCostOptions { Amount = 400 }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "1437 Bannock St Room 451", City = "Springfield", State = "CO", PostalCode = "80202", Country = "US", }, AddressSource = "shipping", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` Die Antwort gibt die berechnete Steuer mit der Liefergebühr für Einzelhändler/innen für Colorado zurück. Diese erscheint als zusätzlicher Eintrag im `tax_breakdown-`Objekt, wobei `tax_breakdown.tax_rate_details.rate_type` auf `flat_amount` gesetzt ist: ```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: Detaillierte Aufschlüsselung der Steuern nach Posten [Serverseitig] Die übergeordnete [tax_breakdown](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-tax_breakdown) wird immer zurückgegeben und bietet eine einfache Aufschlüsselung, die sich für die Anzeige einer Liste von Steuern beim Bezahlvorgang oder auf einem Zahlungsbeleg eignet. Sie können den [taxability_reason](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown-taxability_reason) verwenden, um zu verstehen, warum während der Integration keine Steuer angewendet wird. Zum Beispiel bedeutet `not_collecting`, dass in dem Land oder Bundesstaat, in dem die Steuer fällig wäre, keine Steuer erhoben wird. Durch das Hinzufügen von [Steuerregistrierungen](https://docs.stripe.com/tax/set-up.md#add-registrations) zu Ihren Kontoeinstellungen geben Sie Stripe an, wo Sie Steuern erheben. Wenn Sie eine Registrierung für Washington hinzugefügt haben, wird in Ihrem Ergebnis als Steuerpflichtgrund `standard_rated` angezeigt, was darauf hinweist, dass das Produkt zum Standardsatz besteuert wird. Erweitern Sie das Attribut [tax_breakdown](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown) des Postens, um eine detaillierte Aufschlüsselung einschließlich lokaler Steuern und Attribute zu erhalten, die den Grund für die einzelnen Steuern erklären. - Das Feld `tax_type` aus [tax_rate_details](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown-tax_rate_details) ist eine übergeordnete Angabe zum Steuertyp, die möglicherweise nicht immer mit dem in Berichten und Transaktionen zurückgegebenen Typ übereinstimmt. Beispielsweise wird nicht zwischen US-amerikanischer Sales Tax und Use Tax unterschieden. - Verwenden Sie das Feld `display_name` aus [tax_rate_details](https://docs.stripe.com/api/tax/calculations/object.md#tax_calculation_object-line_items-data-tax_breakdown-tax_rate_details) in Ihrem Bezahlvorgang, um alle Steuern anzuzeigen. Die Steuern werden basierend auf dem Standort der Kundin oder des Kunden und den Steuerinformationen des Produkts lokalisiert. Wenn beispielsweise für Deutschland die Umsatzsteuer (USt.) angewendet wird, weil sich die Kundin oder der Kunde in Deutschland befindet und das Produkt am Bestimmungsort besteuert wird – etwa [txcd_10103001: Software as a service (SaaS) for business use](https://docs.stripe.com/tax/tax-codes.md?tax_code=txcd_10103001) –, wird `Umsatzsteuer (USt)` angezeigt, also die deutsche Bezeichnung für VAT. Wenn dagegen für Frankreich Umsatzsteuer (VAT) angewendet wird, weil die Firmenadresse in Frankreich liegt und das Produkt am Ursprungsort besteuert wird – etwa [txcd_20030000: General – Services](https://docs.stripe.com/tax/tax-codes.md?tax_code=txcd_20030000) –, wird `Taxe sur la valeur ajoutée (TVA)` angezeigt, also die französische Bezeichnung für 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" ``` ```cli stripe tax calculations create \ --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" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, expand: ['line_items.data.tax_breakdown'], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1"}], "customer_details": { "address": { "line1": "920 5th Ave", "city": "Seattle", "state": "WA", "postal_code": "98104", "country": "US", }, "address_source": "shipping", }, "expand": ["line_items.data.tax_breakdown"], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', ], ], 'customer_details' => [ 'address' => [ 'line1' => '920 5th Ave', 'city' => 'Seattle', 'state' => 'WA', 'postal_code' => '98104', 'country' => 'US', ], 'address_source' => 'shipping', ], 'expand' => ['line_items.data.tax_breakdown'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("920 5th Ave") .setCity("Seattle") .setState("WA") .setPostalCode("98104") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .addExpand("line_items.data.tax_breakdown") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', }, ], customer_details: { address: { line1: '920 5th Ave', city: 'Seattle', state: 'WA', postal_code: '98104', country: 'US', }, address_source: 'shipping', }, expand: ['line_items.data.tax_breakdown'], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("920 5th Ave"), City: stripe.String("Seattle"), State: stripe.String("WA"), PostalCode: stripe.String("98104"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, } params.AddExpand("line_items.data.tax_breakdown") result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1" }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "920 5th Ave", City = "Seattle", State = "WA", PostalCode = "98104", Country = "US", }, AddressSource = "shipping", }, Expand = new List { "line_items.data.tax_breakdown" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` ```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: Häufige Fehler beheben [Serverseitig] Befolgen Sie die folgenden Schritte, um Fehler in Ihrer Steuerintegration zu beheben. ### Fehler wegen ungültiger Steuercodes beheben Wenn Sie einen `Ungültiger Steuercode`-Fehler erhalten, können Sie in den [Produktsteuercodes](https://docs.stripe.com/tax/tax-codes.md) eine Liste der verfügbaren Steuercodes einsehen. Gehen Sie dann wie folgt vor, um das Problem zu beheben: 1. **Prüfen Sie den Steuercode**: Stellen Sie sicher, dass Sie einen gültigen Steuercode aus der [Liste der verfügbaren Steuercodes](https://docs.stripe.com/tax/tax-codes.md) verwenden. Häufige Fehler sind: - Leere Zeichenfolge oder `null` als Steuercode verwenden - Falsch geschriebener Steuercode - Verwenden eines nicht vorhandenen Steuercodes 1. **Aktualisieren Sie Ihren Code**: Achten Sie darauf, beim Erstellen einer `TaxCalculation` einen gültigen Steuercode zu übergeben. Zum Beispiel: ```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 ``` ```cli stripe tax calculations create \ --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 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") calculation = client.v1.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_code: 'txcd_10000000', }, ], customer_details: { address: { line1: '354 Oyster Point Blvd', city: 'South San Francisco', state: 'CA', postal_code: '94080', country: 'US', }, address_source: 'shipping', }, }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. calculation = client.v1.tax.calculations.create({ "currency": "usd", "line_items": [{"amount": 1000, "reference": "L1", "tax_code": "txcd_10000000"}], "customer_details": { "address": { "line1": "354 Oyster Point Blvd", "city": "South San Francisco", "state": "CA", "postal_code": "94080", "country": "US", }, "address_source": "shipping", }, }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $calculation = $stripe->tax->calculations->create([ 'currency' => 'usd', 'line_items' => [ [ 'amount' => 1000, 'reference' => 'L1', 'tax_code' => 'txcd_10000000', ], ], 'customer_details' => [ 'address' => [ 'line1' => '354 Oyster Point Blvd', 'city' => 'South San Francisco', 'state' => 'CA', 'postal_code' => '94080', 'country' => 'US', ], 'address_source' => 'shipping', ], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); CalculationCreateParams params = CalculationCreateParams.builder() .setCurrency("usd") .addLineItem( CalculationCreateParams.LineItem.builder() .setAmount(1000L) .setReference("L1") .setTaxCode("txcd_10000000") .build() ) .setCustomerDetails( CalculationCreateParams.CustomerDetails.builder() .setAddress( CalculationCreateParams.CustomerDetails.Address.builder() .setLine1("354 Oyster Point Blvd") .setCity("South San Francisco") .setState("CA") .setPostalCode("94080") .setCountry("US") .build() ) .setAddressSource(CalculationCreateParams.CustomerDetails.AddressSource.SHIPPING) .build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Calculation calculation = client.v1().tax().calculations().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const calculation = await stripe.tax.calculations.create({ currency: 'usd', line_items: [ { amount: 1000, reference: 'L1', tax_code: 'txcd_10000000', }, ], customer_details: { address: { line1: '354 Oyster Point Blvd', city: 'South San Francisco', state: 'CA', postal_code: '94080', country: 'US', }, address_source: 'shipping', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxCalculationCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), LineItems: []*stripe.TaxCalculationCreateLineItemParams{ &stripe.TaxCalculationCreateLineItemParams{ Amount: stripe.Int64(1000), Reference: stripe.String("L1"), TaxCode: stripe.String("txcd_10000000"), }, }, CustomerDetails: &stripe.TaxCalculationCreateCustomerDetailsParams{ Address: &stripe.AddressParams{ Line1: stripe.String("354 Oyster Point Blvd"), City: stripe.String("South San Francisco"), State: stripe.String("CA"), PostalCode: stripe.String("94080"), Country: stripe.String("US"), }, AddressSource: stripe.String(stripe.TaxCalculationCustomerDetailsAddressSourceShipping), }, } result, err := sc.V1TaxCalculations.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.CalculationCreateOptions { Currency = "usd", LineItems = new List { new Stripe.Tax.CalculationLineItemOptions { Amount = 1000, Reference = "L1", TaxCode = "txcd_10000000", }, }, CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions { Address = new AddressOptions { Line1 = "354 Oyster Point Blvd", City = "South San Francisco", State = "CA", PostalCode = "94080", Country = "US", }, AddressSource = "shipping", }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Calculations; Stripe.Tax.Calculation calculation = service.Create(options); ``` 1. **Verwenden Sie den Standard-Steuercode**: Stripe Tax verwendet einen Standard-Steuercode für Berechnungen, wenn kein spezifischer Steuercode für ein Produkt oder in einer Steuerberechnungsanfrage angegeben ist. Den Standardwert können Sie in Ihren Steuereinstellungen einsehen und aktualisieren. Verwenden Sie die API, um den Standard-Steuercode zu aktualisieren: ```curl curl https://api.stripe.com/v1/tax/settings \ -u "<>:" \ -d "defaults[tax_code]"=txcd_10000000 ``` ```cli stripe tax settings update \ -d "defaults[tax_code]"=txcd_10000000 ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") settings = client.v1.tax.settings.update({defaults: {tax_code: 'txcd_10000000'}}) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. settings = client.v1.tax.settings.update({"defaults": {"tax_code": "txcd_10000000"}}) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $settings = $stripe->tax->settings->update([ 'defaults' => ['tax_code' => 'txcd_10000000'], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); SettingsUpdateParams params = SettingsUpdateParams.builder() .setDefaults( SettingsUpdateParams.Defaults.builder().setTaxCode("txcd_10000000").build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Settings settings = client.v1().tax().settings().update(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const settings = await stripe.tax.settings.update({ defaults: { tax_code: 'txcd_10000000', }, }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.TaxSettingsUpdateParams{ Defaults: &stripe.TaxSettingsUpdateDefaultsParams{ TaxCode: stripe.String("txcd_10000000"), }, } result, err := sc.V1TaxSettings.Update(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Tax.SettingsUpdateOptions { Defaults = new Stripe.Tax.SettingsDefaultsOptions { TaxCode = "txcd_10000000" }, }; var client = new StripeClient("<>"); var service = client.V1.Tax.Settings; Stripe.Tax.Settings settings = service.Update(options); ``` 1. **Überprüfen Sie Ihren Produktkatalog**: Wenn Sie Steuercodes verwenden, die mit Produkten in Ihrem Stripe-Produktkatalog verknüpft sind, stellen Sie sicher, dass die Steuercodes Ihren Produkten korrekt zugeordnet sind. 1. **Überprüfen Sie die Daten auf Inkonsistenzen**: Stellen Sie sicher, dass der Steuercode korrekt aus Ihrer Datenbank oder Ihrem Frontend an Ihren serverseitigen Code übergeben wird, der den API-Aufruf an Stripe ausführt. Verwenden Sie für genauere Steuerberechnungen den spezifischsten Steuercode, der für Ihr Produkt oder Ihre Dienstleistung gilt. Wenn Sie sich nicht sicher sind, welchen Steuercode Sie verwenden sollen, lesen Sie die [Dokumentation zu Steuercodes](https://docs.stripe.com/tax/tax-codes.md). Wenn weiterhin Probleme auftreten, prüfen Sie die [Dokumentation zur Tax Settings API](https://docs.stripe.com/api/tax/settings.md). ## See also - [Stripe Tax mit Connect verwenden](https://docs.stripe.com/tax/connect.md)