# Anteilmäßige Verrechnung Verwalten Sie anteilmäßige Verrechnungen für geänderte Abonnements. Der aufwändigste Aspekt beim Ändern bestehender Abonnements sind anteilmäßige Verrechnungen, bei denen Kundinnen/Kunden ein prozentualer Anteil der Kosten eines Abonnements berechnet wird, um die anteilmäßige Nutzung zu berücksichtigen. Auf dieser Seite wird erläutert, wie anteilmäßige Verrechnungen bei Abonnements funktionieren und wie Sie diese für Ihre Kundinnen/Kunden verwalten. ## So funktionieren anteilmäßige Verrechnungen Zum Beispiel kann das [Upgrade oder Downgrade](https://docs.stripe.com/billing/subscriptions/change-price.md) eines Abonnements zu anteilmäßig verrechneten Zahlungen führen. Wenn ein/e Kundin/Kunde von einem monatlichen Plan im Wert von 10 USD auf eine Option im Wert von 20 USD umsteigt, werden ihr/ihm anteilmäßig verrechnete Beträge für die Zeit berechnet, die sie/er mit jeder Option verbracht hat. Unter der Annahme, dass der Wechsel nach der Hälfte des Rechnungsstellungszeitraums erfolgte, werden der/dem Kundin/Kunden zusätzlich 5 USD in Rechnung gestellt: -5 USD für die ungenutzte Zeit im ursprünglichen Preis und 10 USD für die verbleibende Zeit im neuen Preis. Die anteilmäßige Verrechnung stellt sicher, dass die Kundinnen/Kunden genaue Rechnungen erhalten. Allerdings kann die anteilmäßige Verrechnung zu unerwarteten Zahlungsbeträgen führen. Negative anteilmäßige Verrechnungen werden nicht automatisch zurückerstattet und positive anteilmäßige Verrechnungen nicht sofort in Rechnung gestellt, obwohl beides manuell möglich ist. Sie können sich eine [Vorschau der anteilmäßigen Verrechnung](https://docs.stripe.com/billing/subscriptions/prorations.md#preview-proration) anzeigen lassen, um den Betrag vor dem Übernehmen der Änderungen zu sehen. Wenn Sie mehr darüber erfahren möchten, [wie die anteilmäßige Verrechnung von Gutschriften funktioniert](https://docs.stripe.com/billing/subscriptions/prorations.md#credit-prorations), lesen Sie unseren Leitfaden. ### Anteilmäßige Verrechnungen und Rabatte Alle [Rechnungsposten](https://docs.stripe.com/api/invoiceitems/object.md#invoiceitem_object) bei denen es sich um anteilmäßige Verrechnungen (`prorations=true`) sind auf `discountable=false` gesetzt. Rabatte, die auf eine Rechnung angewendet werden, die anteilige Verrechnungen enthält, werden nur auf [Rechnungsposten](https://docs.stripe.com/api/invoiceitems/object.md#invoiceitem_object-discounts) und [Rechnungszeilenposten](https://docs.stripe.com/api/invoice-line-item/object.md#invoice_line_item_object-discounts) angewendet, die keine anteilmäßige Verrechnungen sind. Alle Rabatte, die zuvor auf das Abonnement angewendet wurden und sich auf den Betrag der anteiligen Verrechnungen auswirken, spiegeln sich im Betrag des anteiligen Rechnungspostens wider. Nicht anteilmäßige Verrechnungen zeigen Rabattkorrekturen in [discount_amounts](https://docs.stripe.com/api/invoice-line-item/object.md#invoice_line_item_object-discount_amounts). ### Wodurch werden anteilmäßige Verrechnungen ausgelöst Standardmäßig führen die folgenden Szenarien zu einer anteilmäßigen Verrechnung: | Aktualisieren | Beschreibung | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | | [Posten](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-items) ändern | Neuen Posten hinzufügen oder bestehenden Posten entfernen | | [Preis](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-items-price) ändern | Wechsel zu einem Preis mit einen Basiskosten oder Rechnungsstellungszeitraum | | [Menge](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-items-quantity) ändern | Menge eines Abonnement-Posten erhöhen oder verringern | | [trial_end](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-trial_end) oder [trial_from_plan](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-trial_from_plan) hinzufügen | Hinzufügen eines Testzeitraums zu einem aktiven Abonnement | | [billing_cycle_anchor](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-billing_cycle_anchor) ändern | Abrechnungszeitraum auf ein neues Datum zurücksetzen | | [cancel_at](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-cancel_at) festlegen | Ein Abo mitten im Zeitraum kündigen (nicht zum Ende des Zeitraums) | ### Was keine anteilsmäßigen Verrechnungen auslöst Viele Aktualisierungen von Abonnements wirken sich nicht auf die Abrechnung aus bzw. generieren keine anteilmäßige Verrechnung. Nehmen Sie diese Aktualisierungen jederzeit vor, ohne Rechnungsposten mit *anteilmäßiger* Verrechnung zu erstellen: | Parameter | Beschreibung | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | **Konfigurations- und Einstellungsaktualisierungen** | | | [automatic_tax](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-automatic_tax) | Automatische Steuerberechnung aktivieren oder deaktivieren | | [default_payment_method](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-default_payment_method) | Standard-Zahlungsmethode ändern | | [default_source](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-default_source) | Standardquelle der Zahlung ändern | | [payment_behavior](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-payment_behavior) | Verhalten des Zahlungsversuchs steuern | | [collection_method](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-collection_method) | Wechsel zwischen automatischer Zahlung und Rechnungsversand | | [days_until_due](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-days_until_due) | Fälligkeitsdatum der Zahlung für den Versand von Abonnement-Rechnungen aktualisieren | | [tax_filing_currency](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-tax_filing_currency) | Währung der Steuererklärung ändern | | [retry_settings](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-retry_settings) | Wiederholungsverhalten bei fehlgeschlagenen Zahlungen ändern | | [trial_settings](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-trial_settings) | Einstellungen für das Endverhalten des Testzeitraums aktualisieren | | [pay_immediately](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-pay_immediately) | Sofortiges Zahlungsverhalten steuern | | [pending_invoice_item_interval](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-pending_invoice_item_interval) | Ändern, wie oft ausstehende Posten in Rechnung gestellt werden | | [pause_collection](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-pause_collection) | Zahlungseinzug unterbrechen oder wiederaufnehmen | | [proration_date](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-proration_date) | Festlegen eines bestimmten Datums für anteilmäßige Verrechnungen (erstellt selbst keine anteilmäßige Verrechnung) | | **Metadaten und beschreibende Felder** | | | [Metadaten](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-metadata) und [items.metadata](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-items-metadata) | Metadaten zu den Abonnements/Abonnementposten aktualisieren | | [cancellation_details](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-cancellation_details) | Stornofeedback und -Kommentare hinzufügen | | **Aktualisierungen, die als Einstellungen für zukünftige Abrechnungsänderungen ohne anteilmäßige Verrechnung dienen** | | | [Rabatte](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-discounts) und [items.discounts](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-items-discounts) | Rabatte hinzufügen oder aktualisieren (gilt für zukünftige Rechnungen) | | [billing_thresholds](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-billing_thresholds) und [items.billing_thresholds](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-items-billing_thresholds) | Abrechnungs-Schwellenwerte bei Abonnements/Abonnementposten aktualisieren | | [cancel_at_period_end](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-cancel_at_period_end) | Zum Ende des aktuellen Zeitraums ohne anteilmäßige Verrechnung kündigen | | [add_invoice_items](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-add_invoice_items) | Einmalige Zahlungen zur nächsten Rechnung hinzufügen | > Diese Aktualisierungen generieren keine Rechnungsposten mit anteilmäßiger Verrechnung mit `proration_behavior=create_prorations` oder Rechnungen mit Rechnungsposten mit anteilmäßiger Verrechnung mit `proration_behavior=always_invoice`, da sich dadurch der Abrechnungsbetrag für den aktuellen Zeitraum nicht ändert. ### Eigene anteilmäßige Verrechnungen manuell erstellen Um Ihre eigene anteilmäßige Verrechnung außerhalb von Stripe zu berechnen und sie dem Abonnement hinzuzufügen, übergeben [Sie add_invoice_items](https://docs.stripe.com/api/subscription_schedules/create.md#create_subscription_schedule-add_invoice_items) mit einem negativen `unit_amount` (gleich dem berechneten Anteilsbetrag) an diese Endpoints: - [CreateSubscription](https://docs.stripe.com/api/subscriptions/create.md) - [UpdateSubscription](https://docs.stripe.com/api/subscriptions/update.md) - [CreateSubscriptionSchedule](https://docs.stripe.com/api/subscription_schedules/create.md) - [UpdateSubscriptionSchedule](https://docs.stripe.com/api/subscription_schedules/update.md) ### Anteilmäßige Verrechnungen werden unter folgenden Umständen angewendet Anteilmäßige Verrechnungen gelten nur für Gebühren, die vor Beginn des Rechnungsstellungszeitraums anfallen. [Nutzungsbasierte Abrechnung](https://docs.stripe.com/billing/subscriptions/usage-based.md) unterliegt nicht der anteilmäßigen Verrechnung. Der anteilige Betrag wird berechnet, sobald das Abonnement über die API aktualisiert wird. Anhand der Start- und Endzeiten des aktuellen Abrechnungszeitraums werden die Kosten des Abonnements vor und nach der Änderung berechnet. ### Anteilmäßige Verrechnungen und unbezahlte Rechnungen Stripe kalkuliert anteilmäßige Verrechnungen auf der Grundlage des Status des Abonnements zum Zeitpunkt der Aktualisierung und geht davon aus, dass alle früheren Rechnungen für das Abonnement irgendwann bezahlt werden. Wenn eine Kundin / ein Kunde ihr/sein Abonnement ändert, während sie/er eine unbezahlte Rechnung für die aktuelle Laufzeit hat, erhält sie/er möglicherweise eine Gutschrift für die ungenutzte Zeit im höherpreisigen Plan, auch wenn sie/er für diese Zeit noch nicht bezahlt hat. Um eine Gutschrift für unbezahlte Zeit zu vermeiden, können Sie die anteilmäßige Verrechnung deaktivieren, wenn die letzte Rechnung des Abonnements nicht bezahlt ist. Legen Sie beim Aktualisieren des Abonnements [proration_behavior](https://docs.stripe.com/api/subscriptions/update.md?update_subscription-proration_behavior=#update_subscription-proration_behavior) auf `none` fest. Wählen Sie eines der folgenden Verfahren aus: 1. **Um den ursprünglichen Rechnungsstellungszeitraum beizubehalten:** [Erstellen Sie manuell eine Einmalrechnung](https://docs.stripe.com/api/invoices/create.md) für alle neuen Gebühren. 1. **Um die neue Preisstufe sofort in Rechnung zu stellen und den Rechnungsstellungszeitraum zurückzusetzen:** Setzen Sie `billing_cycle_anchor` auf `now`. Weitere Informationen finden Sie unter [Rechnungsstellungszeitraum auf die aktuelle Uhrzeit zurücksetzen](https://docs.stripe.com/billing/subscriptions/billing-cycle.md#reset-the-billing-period-to-the-current-time). Beide Vorgehensweisen können zu einer doppelten Zahlung führen, wenn die/der Kundin/Kunde vielleicht die alte Rechnung bezahlt. Um dies zu vermeiden, [stornieren Sie die unbezahlte Rechnung](https://docs.stripe.com/api/invoices/void.md). ### Steuern und anteilmäßige Verrechnungen Informationen darüber, wie Steuern mit anteilmäßiger Verrechnung funktionieren, finden Sie unter [Steuern für wiederkehrende Zahlungen einziehen](https://docs.stripe.com/billing/taxes/collect-taxes.md). ## Anteilmäßige Verrechnung von Gutschriften Anteilmäßige Verrechnungen werden ausgestellt, wenn Kund/innen ihre Abonnements herabstufen oder Posten vor dem Ende des Rechnungsstellungszeitraums stornieren. Stripe bietet zwei Ansätze zur Berechnung der anteilmäßigen Verrechnung, je nachdem, ob Sie den [billing_mode](https://docs.stripe.com/billing/subscriptions/billing-mode.md#differences-between-classic-and-flexible-billing-mode) Ihres Abonnements auf `classic` oder `flexible` setzen. ### Berechnungslogik ohne anteilmäßige Verrechnungen Im folgenden Szenario erhöhen Sie ein monatliches Abonnement von 10 USD auf 20 USD mit der Einstellung `proration_behavior` auf `none` für 10 Tage. Es gibt keine vorherige Abbuchung, auf die Sie sich stützen könnten. Später stufen Sie das Abonnement auf 10 USD pro Monat herab, wobei `proration_behavior` auf `always_invoice` eingestellt ist. Um dieses Szenario einzurichten, müssen Sie zunächst ein [Abonnement erstellen](https://docs.stripe.com/api/subscriptions/create.md) und zwar für 10 USD pro Monat am 1. April: ```curl curl https://api.stripe.com/v1/subscriptions \ -u "<>:" \ -d "items[0][price]"=price_10_monthly ``` ```cli stripe subscriptions create \ -d "items[0][price]"=price_10_monthly ``` ```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("<>") subscription = client.v1.subscriptions.create({items: [{price: 'price_10_monthly'}]}) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys # This example uses the beta SDK. See https://github.com/stripe/stripe-python#public-preview-sdks client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. subscription = client.v1.subscriptions.create({"items": [{"price": "price_10_monthly"}]}) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys // This example uses the beta SDK. See https://github.com/stripe/stripe-php#public-preview-sdks $stripe = new \Stripe\StripeClient('<>'); $subscription = $stripe->subscriptions->create([ 'items' => [['price' => 'price_10_monthly']], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys // This example uses the beta SDK. See https://github.com/stripe/stripe-java#public-preview-sdks StripeClient client = new StripeClient("<>"); SubscriptionCreateParams params = SubscriptionCreateParams.builder() .addItem(SubscriptionCreateParams.Item.builder().setPrice("price_10_monthly").build()) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Subscription subscription = client.v1().subscriptions().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 // This example uses the beta SDK. See https://github.com/stripe/stripe-node#public-preview-sdks const stripe = require('stripe')('<>'); const subscription = await stripe.subscriptions.create({ items: [ { price: 'price_10_monthly', }, ], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys // This example uses the beta SDK. See https://github.com/stripe/stripe-go#public-preview-sdks sc := stripe.NewClient("<>") params := &stripe.SubscriptionCreateParams{ Items: []*stripe.SubscriptionCreateItemParams{ &stripe.SubscriptionCreateItemParams{Price: stripe.String("price_10_monthly")}, }, } result, err := sc.V1Subscriptions.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 SubscriptionCreateOptions { Items = new List { new SubscriptionItemOptions { Price = "price_10_monthly" }, }, }; var client = new StripeClient("<>"); var service = client.V1.Subscriptions; Subscription subscription = service.Create(options); ``` Die Antwort enthält die Rechnung, die für dieses Abonnement erstellt wurde: ```json { id: "sub_123", latest_invoice: { id: "in_123", total: 10_00, currency: "usd" } } ``` Am 11. April folgt die [Aufstockung des Abonnements](https://docs.stripe.com/billing/subscriptions/change-price.md#changing) auf 20 USD pro Monat, ohne anteilmäßige Verrechnungen zu erstellen: ```curl curl https://api.stripe.com/v1/subscriptions/sub_123 \ -u "<>:" \ -d "items[0][id]"=sub_item_1 \ -d "items[0][price]"=price_20_monthly \ -d proration_behavior=none ``` ```cli stripe subscriptions update sub_123 \ -d "items[0][id]"=sub_item_1 \ -d "items[0][price]"=price_20_monthly \ --proration-behavior=none ``` ```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("<>") subscription = client.v1.subscriptions.update( 'sub_123', { items: [ { id: 'sub_item_1', price: 'price_20_monthly', }, ], proration_behavior: 'none', }, ) ``` ```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. subscription = client.v1.subscriptions.update( "sub_123", { "items": [{"id": "sub_item_1", "price": "price_20_monthly"}], "proration_behavior": "none", }, ) ``` ```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('<>'); $subscription = $stripe->subscriptions->update( 'sub_123', [ 'items' => [ [ 'id' => 'sub_item_1', 'price' => 'price_20_monthly', ], ], 'proration_behavior' => 'none', ] ); ``` ```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("<>"); SubscriptionUpdateParams params = SubscriptionUpdateParams.builder() .addItem( SubscriptionUpdateParams.Item.builder() .setId("sub_item_1") .setPrice("price_20_monthly") .build() ) .setProrationBehavior(SubscriptionUpdateParams.ProrationBehavior.NONE) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Subscription subscription = client.v1().subscriptions().update("sub_123", 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 subscription = await stripe.subscriptions.update( 'sub_123', { items: [ { id: 'sub_item_1', price: 'price_20_monthly', }, ], proration_behavior: 'none', } ); ``` ```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.SubscriptionUpdateParams{ Items: []*stripe.SubscriptionUpdateItemParams{ &stripe.SubscriptionUpdateItemParams{ ID: stripe.String("sub_item_1"), Price: stripe.String("price_20_monthly"), }, }, ProrationBehavior: stripe.String("none"), } result, err := sc.V1Subscriptions.Update(context.TODO(), "sub_123", 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 SubscriptionUpdateOptions { Items = new List { new SubscriptionItemOptions { Id = "sub_item_1", Price = "price_20_monthly" }, }, ProrationBehavior = "none", }; var client = new StripeClient("<>"); var service = client.V1.Subscriptions; Subscription subscription = service.Update("sub_123", options); ``` Die letzte Rechnung bleibt unverändert, da `proration_behavior` gleich `none` ist: ```json { id: "sub_123", latest_invoice: { id: "in_123" } } ``` Am 21. April [stufen Sie das Abonnement](https://docs.stripe.com/billing/subscriptions/change-price.md#changing) auf 10 USD pro Monat herab und verrechnen anteilmäßig: ```curl curl https://api.stripe.com/v1/subscriptions/sub_123 \ -u "<>:" \ -d "items[0][id]"=sub_item_1 \ -d "items[0][price]"=price_10_monthly \ -d proration_behavior=always_invoice ``` ```cli stripe subscriptions update sub_123 \ -d "items[0][id]"=sub_item_1 \ -d "items[0][price]"=price_10_monthly \ --proration-behavior=always_invoice ``` ```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("<>") subscription = client.v1.subscriptions.update( 'sub_123', { items: [ { id: 'sub_item_1', price: 'price_10_monthly', }, ], proration_behavior: 'always_invoice', }, ) ``` ```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. subscription = client.v1.subscriptions.update( "sub_123", { "items": [{"id": "sub_item_1", "price": "price_10_monthly"}], "proration_behavior": "always_invoice", }, ) ``` ```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('<>'); $subscription = $stripe->subscriptions->update( 'sub_123', [ 'items' => [ [ 'id' => 'sub_item_1', 'price' => 'price_10_monthly', ], ], 'proration_behavior' => 'always_invoice', ] ); ``` ```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("<>"); SubscriptionUpdateParams params = SubscriptionUpdateParams.builder() .addItem( SubscriptionUpdateParams.Item.builder() .setId("sub_item_1") .setPrice("price_10_monthly") .build() ) .setProrationBehavior(SubscriptionUpdateParams.ProrationBehavior.ALWAYS_INVOICE) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Subscription subscription = client.v1().subscriptions().update("sub_123", 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 subscription = await stripe.subscriptions.update( 'sub_123', { items: [ { id: 'sub_item_1', price: 'price_10_monthly', }, ], proration_behavior: 'always_invoice', } ); ``` ```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.SubscriptionUpdateParams{ Items: []*stripe.SubscriptionUpdateItemParams{ &stripe.SubscriptionUpdateItemParams{ ID: stripe.String("sub_item_1"), Price: stripe.String("price_10_monthly"), }, }, ProrationBehavior: stripe.String("always_invoice"), } result, err := sc.V1Subscriptions.Update(context.TODO(), "sub_123", 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 SubscriptionUpdateOptions { Items = new List { new SubscriptionItemOptions { Id = "sub_item_1", Price = "price_10_monthly" }, }, ProrationBehavior = "always_invoice", }; var client = new StripeClient("<>"); var service = client.V1.Subscriptions; Subscription subscription = service.Update("sub_123", options); ``` | **Klassisch** | **Flexibel** | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Die Berechnungslogik `billing_mode=classic` erstellt eine anteilmäßige Verrechnung basierend auf dem aktuellen Preis, obwohl die/der Kundin/Kunde die 20 USD Monatsrate nie bezahlt hat. Die letzte Rechnung schreibt ein Drittel des Monats für 20 USD (-6.67 USD) vor, obwohl die/der Kundin/Kunde den `price_20_monthly` nie bezahlt hat. Außerdem wird ein Drittel des Monats für 10 USD (3.33 USD) berechnet. | Die mit `billing_mode=flexible` aktivierte Berechnungslogik erstellt eine anteilmäßige Verrechnung, die auf dem zuletzt für den Posten des Abonnements abgerechneten Preis basiert. In diesem Fall schreibt die letzte Rechnung ein Drittel eines Monats für den am 1. April abgerechneten monatlichen Preis von 10 USD gut (3.33 USD) und belastet ein Drittel des Monats für den Preis von 10 USD (3.33 USD). Die Gutschrift und die Belastung heben sich auf, sodass der Rechnungsbetrag 0 USD beträgt. | | ```json # billing_mode = classic { id: "sub_123", latest_invoice: { id: "in_456", total: -3_34, currency: "usd" } } ``` | ```json # billing_mode = flexible { id: "sub_123", latest_invoice: { id: "in_456", total: 0, currency: "usd" } } ``` | ### Berechnungslogik für Gutscheine, die auf mehrere Abonnementartikel angewendet werden Stripe gewichtet den `amount_off`-Gutschein bei der anteilmäßigen Verrechnung der Gutschrift, um eine überhöhte Rechnungsstellung zu vermeiden. Im folgenden Szenario wird ein Gutschein in Höhe von 5 USD ungleichmäßig einem monatlichen Abonnement in Höhe von 25 USD für einen Artikel über 10 USD und einen Artikel über 20 USD zugewiesen. Um dieses Szenario einzurichten, erstellen Sie ein Abonnement mit mehreren Posten und einem Gutschein für den 1. Februar: ```curl curl https://api.stripe.com/v1/subscriptions \ -u "<>:" \ -d "items[0][price]"=price_20_monthly \ -d "discounts[0][coupon]"=five_dollars_off ``` ```cli stripe subscriptions create \ -d "items[0][price]"=price_20_monthly \ -d "discounts[0][coupon]"=five_dollars_off ``` ```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("<>") subscription = client.v1.subscriptions.create({ items: [{price: 'price_20_monthly'}], discounts: [{coupon: 'five_dollars_off'}], }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys # This example uses the beta SDK. See https://github.com/stripe/stripe-python#public-preview-sdks client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. subscription = client.v1.subscriptions.create({ "items": [{"price": "price_20_monthly"}], "discounts": [{"coupon": "five_dollars_off"}], }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys // This example uses the beta SDK. See https://github.com/stripe/stripe-php#public-preview-sdks $stripe = new \Stripe\StripeClient('<>'); $subscription = $stripe->subscriptions->create([ 'items' => [['price' => 'price_20_monthly']], 'discounts' => [['coupon' => 'five_dollars_off']], ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys // This example uses the beta SDK. See https://github.com/stripe/stripe-java#public-preview-sdks StripeClient client = new StripeClient("<>"); SubscriptionCreateParams params = SubscriptionCreateParams.builder() .addItem(SubscriptionCreateParams.Item.builder().setPrice("price_20_monthly").build()) .addDiscount( SubscriptionCreateParams.Discount.builder().setCoupon("five_dollars_off").build() ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Subscription subscription = client.v1().subscriptions().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 // This example uses the beta SDK. See https://github.com/stripe/stripe-node#public-preview-sdks const stripe = require('stripe')('<>'); const subscription = await stripe.subscriptions.create({ items: [ { price: 'price_20_monthly', }, ], discounts: [ { coupon: 'five_dollars_off', }, ], }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys // This example uses the beta SDK. See https://github.com/stripe/stripe-go#public-preview-sdks sc := stripe.NewClient("<>") params := &stripe.SubscriptionCreateParams{ Items: []*stripe.SubscriptionCreateItemParams{ &stripe.SubscriptionCreateItemParams{Price: stripe.String("price_20_monthly")}, }, Discounts: []*stripe.SubscriptionCreateDiscountParams{ &stripe.SubscriptionCreateDiscountParams{Coupon: stripe.String("five_dollars_off")}, }, } result, err := sc.V1Subscriptions.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 SubscriptionCreateOptions { Items = new List { new SubscriptionItemOptions { Price = "price_20_monthly" }, }, Discounts = new List { new SubscriptionDiscountOptions { Coupon = "five_dollars_off" }, }, }; var client = new StripeClient("<>"); var service = client.V1.Subscriptions; Subscription subscription = service.Create(options); ``` Dadurch wird die folgende Antwort zurückgegeben: ```json { id: "sub_123", latest_invoice: { id: "in_123", total: 25_00, currency: "usd", lines: { data: [ { id: "ili_1", amount: 10_00, price: "price_10_monthly", discount_amounts: [{ discount: "di_a", amount: 1_66 }] }, { id: "ili_2", amount: 20_00, price: "price_20_monthly", discount_amounts: [{ discount: "di_a", amount: 3_34 }] }, ] } } } ``` Um den Posten des monatlichen Abonnements zu stornieren: ```curl curl https://api.stripe.com/v1/subscription_items/si_10_monthly \ -u "<>:" \ -d proration_behavior=create_prorations ``` ```cli stripe subscription_items delete si_10_monthly \ --proration-behavior=create_prorations ``` ```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("<>") deleted = client.v1.subscription_items.delete( 'si_10_monthly', {proration_behavior: 'create_prorations'}, ) ``` ```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. deleted = client.v1.subscription_items.delete( "si_10_monthly", {"proration_behavior": "create_prorations"}, ) ``` ```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('<>'); $deleted = $stripe->subscriptionItems->delete( 'si_10_monthly', ['proration_behavior' => 'create_prorations'] ); ``` ```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("<>"); SubscriptionItemDeleteParams params = SubscriptionItemDeleteParams.builder() .setProrationBehavior( SubscriptionItemDeleteParams.ProrationBehavior.CREATE_PRORATIONS ) .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. SubscriptionItem subscriptionItem = client.v1().subscriptionItems().delete("si_10_monthly", 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 deleted = await stripe.subscriptionItems.del( 'si_10_monthly', { proration_behavior: 'create_prorations', } ); ``` ```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.SubscriptionItemDeleteParams{ ProrationBehavior: stripe.String("create_prorations"), } result, err := sc.V1SubscriptionItems.Delete(context.TODO(), "si_10_monthly", 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 SubscriptionItemDeleteOptions { ProrationBehavior = "create_prorations", }; var client = new StripeClient("<>"); var service = client.V1.SubscriptionItems; SubscriptionItem deleted = service.Delete("si_10_monthly", options); ``` Wenn ein Posten des Abonnements gelöscht wird, beeinflusst der `billing_mode`, der mit diesem Abonnement verbunden ist, wie die anteilmäßige Verrechnung kalkuliert wird: | **Klassisch** | **Flexibel** | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Es wird standardmäßig ein 5 USD Gutschein auf jeden Posten (2.5 USD each) angewendet, wodurch der günstigere Posten (5 USD) storniert wird und eine Rückerstattung von 2.5 USD erfolgt. Stripe berechnet den Gesamtbetrag mit der Formel `-0.5 x (10 USD price - 5 USD coupon) = -2.50 USD`. | Diese flexible Lösung spiegelt den proportionalen Rabatt wider, der auf den stornierten Posten angewandt wird, anstatt möglicherweise den gesamten Rabattbetrag anteilmäßig zu verrechnen. Stripe berechnet den Gesamtbetrag nach der Formel `-0.5 x (10 USD price - 1.66 USD discount amount) = -4.17 USD`. | | ```json # billing_mode = classic { "id": "sub_123", "latest_invoice": { "id": "in_456", "total": -250, "currency": "usd" } } ``` | ```json # billing_mode = flexible { "id": "sub_123", "latest_invoice": { "id": "in_789", "total": -417, "currency": "usd" } } ``` | ## Vorschau für eine anteilmäßige Verrechnung anzeigen Sie können eine [Rechnungsvorschau erstellen](https://docs.stripe.com/api/invoices/create_preview.md), um eine Vorschau der Änderungen an einem Abonnement anzuzeigen. Dieser API-Aufruf ändert das Abonnement nicht. Stattdessen wird die ausstehende *Rechnung* (Invoices are statements of amounts owed by a customer. They track the status of payments from draft through paid or otherwise finalized. Subscriptions automatically generate invoices, or you can manually create a one-off invoice) nur basierend auf den von Ihnen übergebenen Parametern zurückgegeben. Änderungen sowohl am `price` als auch an der `quantity` führen zu einer anteilmäßigen Verrechnung. In diesem Beispiel wird der `price` geändert und ein Datum für die anteilmäßige Verrechnung festgelegt. #### Ruby ```ruby # 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 proration date to this moment: proration_date = Time.now.to_i subscription = Stripe::Subscription.retrieve('sub_49ty4767H20z6a') # See what the next invoice would look like with a price switch # and proration set: items = [{ id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f', # Switch to new price }] invoice = Stripe::Invoice.create_preview({ customer: 'cus_4fdAW5ftNQow1a', subscription: 'sub_49ty4767H20z6a', subscription_details: { items: items, proration_date: proration_date, } }) ``` #### Python ```python # 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 proration date to this moment: import time proration_date = int(time.time()) subscription = stripe.Subscription.retrieve('sub_49ty4767H20z6a') # See what the next invoice would look like with a price switch # and proration set: items=[{ 'id': subscription['items']['data'][0].id, 'price': 'price_CBb6IXqvTLXp3f', # Switch to new price }] invoice = stripe.Invoice.create_preview( customer='cus_4fdAW5ftNQow1a', subscription='sub_49ty4767H20z6a', subscription_details={"items": items, "proration_date": proration_date} ) ``` #### PHP ```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\Stripe::setApiKey('<>'); // Set proration date to this moment: $proration_date = time(); $subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a'); // See what the next invoice would look like with a price switch // and proration set: $items = [ [ 'id' => $subscription->items->data[0]->id, 'price' => 'price_CBb6IXqvTLXp3f', # Switch to new price ], ]; $invoice = \Stripe\Invoice::createPreview([ 'customer' => 'cus_4fdAW5ftNQow1a', 'subscription' => 'sub_49ty4767H20z6a', 'subscription_details' => [ 'items' => $items, 'proration_date' => $proration_date ] ]); ``` #### Java ```java // 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 = "<>"; // Set proration date to this moment: long prorationDate = System.currentTimeMillis() / 1000L; Subscription subscription = Subscription.retrieve("sub_49ty4767H20z6a"); // See what the next invoice would look like with a price switch // and proration set: InvoiceCreatePreviewParams params = InvoiceCreatePreviewParams.builder() .setCustomer("cus_4fdAW5ftNQow1a") .setSubscription("sub_49ty4767H20z6a") .setSubscriptionDetails( InvoiceCreatePreviewParams.SubscriptionDetails.builder() .addItem( InvoiceCreatePreviewParams.SubscriptionDetails.Item.builder() .setId(subscription.getItems().getData().get(0).getId()) .setPrice("price_CBb6IXqvTLXp3f") // Switch to new price .build() ) .setProrationDate(prorationDate) .build() ) .build(); Invoice invoice = Invoice.createPreview(params); ``` #### 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')('<>'); // Set proration date to this moment: const proration_date = Math.floor(Date.now() / 1000); const subscription = await stripe.subscriptions.retrieve('sub_49ty4767H20z6a'); // See what the next invoice would look like with a price switch // and proration set: const items = [{ id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f', // Switch to new price }]; const invoice = await stripe.invoices.createPreview({ customer: 'cus_4fdAW5ftNQow1a', subscription: 'sub_49ty4767H20z6a', subscription_details: { items: items, proration_date: proration_date }, }); ``` #### Go ```go // 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 = "<>" // Set the proration date to this moment: prorationDate := time.Now().Unix() subscription, err := subscription.Get("sub_49ty4767H20z6a", nil) // See what the next invoice would look like with a price switch // and proration set: items := []*stripe.SubscriptionItemsParams{ { ID: stripe.String(subscription.Items.Data[0].ID), Price: stripe.String("price_CBb6IXqvTLXp3f"), // Switch to new price }, } params := &stripe.InvoiceCreatePreviewParams{ Customer: stripe.String("cus_4fdAW5ftNQow1a"), Subscription: stripe.String("sub_49ty4767H20z6a"), SubscriptionDetails: &stripe.InvoiceCreatePreviewSubscriptionDetailsParams{ Items: items, ProrationDate: stripe.Int64(prorationDate), }, } result, err := invoice.CreatePreview(params) ``` #### .NET ```dotnet // 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 = "<>"; // Set the proration date to this moment: DateTimeOffset prorationDate = DateTimeOffset.UtcNow; var subService = new SubscriptionService(); Subscription subscription = subService.Get("sub_49ty4767H20z6a"); // See what the next invoice would look like with a price switch // and proration set: var items = new List { new InvoiceSubscriptionItemOptions { Id = subscription.Items.Data[0].Id, Price = "price_CBb6IXqvTLXp3f", // switch to new price }, }; var options = new InvoiceCreatePreviewOptions { Customer = "cus_4fdAW5ftNQow1a", Subscription = "sub_49ty4767H20z6a", SubscriptionDetails = new InvoiceSubscriptionDetailsOptions { Items = items, ProrationDate = prorationDate.UtcDateTime, }, }; var invService = new InvoiceService(); Invoice invoice = invService.CreatePreview(options); ``` Sie können die Beispielantwort erweitern, um Folgendes anzuzeigen: - Das Guthaben für nicht genutzte Zeit zum vorherigen Preis in den Zeilen 36 bis 38. - Die Kosten für genutzte Zeit zum neuen Preis in den Zeilen 107 bis 109. - Die neue Zwischensumme und die Summe für die Rechnung in den Zeilen 276 bis 279. ```json { "id": "upcoming_in_1OujwkClCIKljWvsq5v2ICAN", "account_country": "US", "account_name": "Test account", "amount_due": 3627, "amount_paid": 0, "amount_remaining": 3627, "application_fee_amount": null, "attempt_count": 0, "attempted": false, "billing_reason": "upcoming", "charge": null, "collection_method": "charge_automatically", "created": 1599427688, "currency": "usd", "custom_fields": null, "customer": "cus_DGEhAXrZWrzdYs", "customer_address": null, "customer_email": "jenny.rosen@example.com", "customer_name": null, "customer_phone": null, "customer_shipping": null, "customer_tax_exempt": "none", "customer_tax_ids": [], "default_payment_method": null, "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "discounts": [], "due_date": null, "ending_balance": 0, "footer": null, "lines": { "data": [ {"amount": -166, "currency": "usd", "description": "Unused time on Silver plan after 01 Sep 2020", "discount_amounts": [], "discountable": false, "discounts": [], "id": "il_tmp1HMdV2AJVYItwOKqQi4H", "invoice_item": "ii_1HMdV2AJVYItwUH1Qi4H", "livemode": false, "metadata": {}, "object": "line_item", "period": { "end": 1599427688, "start": 1598982148 }, "plan": { "active": true, "amount": 1000, "amount_decimal": "1000", "billing_scheme": "per_unit", "created": 1585856460, "currency": "usd", "id": "price_H1c8v1lifcd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "object": "plan", "product": "prod_c7exjJHbC4", "tiers": null, "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "price": { "active": true, "billing_scheme": "per_unit", "created": 1585856460, "currency": "usd", "id": "price_c8v1liEvrf", "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "object": "price", "product": "prod_c7exjJHbC4", "recurring": { "interval": "month", "interval_count": 1, "trial_period_days": null, "usage_type": "licensed" }, "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 1000, "unit_amount_decimal": "1000" }, "proration": true, "quantity": 1, "subscription": "sub_H38lqYjDO0DSzl", "subscription_item": "si_H38lIMagWoFx0W", "tax_amounts": [], "tax_rates": [], "type": "invoiceitem" }, {"amount": 541, "currency": "usd", "description": "Remaining time on Gold plan after 01 Sep 2020", "discount_amounts": [], "discountable": false, "discounts": [], "id": "il_tmp1HMdV2AJVYItwOKqDcgkmpzz", "invoice_item": "ii_1HMdV2AJVYItwOKqDcgkmpzz", "livemode": false, "metadata": {}, "object": "line_item", "period": { "end": 1599427688, "start": 1598982148 }, "plan": { "active": true, "amount": 3252, "amount_decimal": "3252", "billing_scheme": "per_unit", "created": 1598473039, "currency": "usd", "id": "price_KV3bAJVYItwOKq16frkr", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "object": "plan", "product": "prod_JfJiw2l6ke", "tiers": null, "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "price": { "active": true, "billing_scheme": "per_unit", "created": 1598473039, "currency": "usd", "id": "price_KV3bAJVYItwOKq16frkr", "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "object": "price", "product": "prod_JfJiw2l6ke", "recurring": { "interval": "month", "interval_count": 1, "trial_period_days": null, "usage_type": "licensed" }, "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 3252, "unit_amount_decimal": "3252" }, "proration": true, "quantity": 1, "subscription": "sub_H38lqYjDO0DSzl", "subscription_item": "si_H38lIMagWoFx0W", "tax_amounts": [], "tax_rates": [], "type": "invoiceitem" }, { "amount": 3252, "currency": "usd", "description": "1 \u00d7 Gold product (at $32.52 / month)", "discount_amounts": [], "discountable": true, "discounts": [], "id": "il_tmp_7fc9ba9b6aa9aa", "livemode": false, "metadata": {}, "object": "line_item", "period": { "end": 1602019688, "start": 1599427688 }, "plan": { "active": true, "amount": 3252, "amount_decimal": "3252", "billing_scheme": "per_unit", "created": 1598473039, "currency": "usd", "id": "price_KV3bAJVYItwOKq16frkr", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "object": "plan", "product": "prod_JfJiw2l6ke", "tiers": null, "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "price": { "active": true, "billing_scheme": "per_unit", "created": 1598473039, "currency": "usd", "id": "price_KV3bAJVYItwOKq16frkr", "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "object": "price", "product": "prod_JfJiw2l6ke", "recurring": { "interval": "month", "interval_count": 1, "trial_period_days": null, "usage_type": "licensed" }, "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 3252, "unit_amount_decimal": "3252" }, "proration": false, "quantity": 1, "subscription": "sub_H38lqYjDO0DSzl", "subscription_item": "si_H38lIMagWoFx0W", "tax_amounts": [], "tax_rates": [], "type": "subscription" } ], "has_more": false, "object": "list", "total_count": 3, "url": "/v1/invoices/upcoming_in_1OujwkClCIKljWvsq5v2ICAN/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1599431288, "number": null, "object": "invoice", "paid": false, "payment_intent": null, "period_end": 1599427688, "period_start": 1596749288, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "receipt_number": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": "sub_8lqYjDO0DS", "subscription_details": { "proration_date": 1598982148, },"subtotal": 3627, "tax": null, "tax_percent": null, "total": 3627, "total_discount_amounts": [], "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null } ``` Anhand dieser Informationen können Sie die Kundin/den Kunden die Änderungen bestätigen lassen, bevor Sie das Abonnement ändern. Da Stripe sekundengenau anteilmäßig verrechnet, können sich anteilmäßig verrechnete Beträge zwischen der Vorschau und dem Zeitpunkt der Aktualisierung ändern. Um das zu vermeiden, übergeben Sie einen Wert `subscription_details.proration_date` beim Erstellen einer Vorschau. Übergeben Sie beim Aktualisieren des Abonnements das gleiche Datum mithilfe des Parameters `proration_date` für ein Abonnement, sodass der Anteil zur gleichen Zeit berechnet wird. #### Ruby ```ruby # 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 = '<>' subscription = Stripe::Subscription.update( 'sub_49ty4767H20z6a', { items: [ { id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f', }, ], proration_date: proration_date, } ) ``` #### Python ```python # 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 = '<>' subscription = stripe.Subscription.modify( 'sub_49ty4767H20z6a', items=[{ 'id': subscription['items']['data'][0].id, 'price': 'price_CBb6IXqvTLXp3f', }], proration_date=proration_date, ) ``` #### PHP ```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\Stripe::setApiKey('<>'); $subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a'); \Stripe\Subscription::update('sub_49ty4767H20z6a', [ 'items' => [ [ 'id' => $subscription->items->data[0]->id, 'price' => 'price_CBb6IXqvTLXp3f', ], ], 'proration_date' => $proration_date, ]); ``` #### Java ```java // 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 = "<>"; Subscription subscription = Subscription.retrieve("sub_49ty4767H20z6a"); SubscriptionUpdateParams params = SubscriptionUpdateParams.builder() .addItem( SubscriptionUpdateParams.Item.builder() .setId(subscription.getItems().getData().get(0).getId()) .setPrice("price_CBb6IXqvTLXp3f") .build()) .setProrationDate(prorationDate) .build(); subscription.update(params); ``` #### 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 subscription = await stripe.subscriptions.retrieve('sub_49ty4767H20z6a'); await stripe.subscriptions.update( 'sub_49ty4767H20z6a', { items: [{ id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f', }], proration_date: proration_date, } ); ``` #### Go ```go // 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 = "<>" subscription, err := subscription.Get("sub_49ty4767H20z6a", nil) params := &stripe.SubscriptionParams{ Items: []*stripe.SubscriptionItemsParams{ { ID: stripe.String(subscription.Items.Data[0].ID), Price: stripe.String("price_CBb6IXqvTLXp3f"), }, }, ProrationDate: stripe.Int64(proration_date), } subscription, err = subscription.Update("sub_49ty4767H20z6a", params) ``` #### .NET ```dotnet // 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 = "<>"; var service = new SubscriptionService(); Subscription subscription = service.Get("sub_49ty4767H20z6a"); var items = new List { new SubscriptionItemOptions { Id = subscription.Items.Data[0].Id, Price = "price_CBb6IXqvTLXp3f", }, }; var prorationDate = DateTime.Now; var options = new SubscriptionUpdateOptions { Items = items, ProrationDate = prorationDate, }; subscription = service.Update("sub_49ty4767H20z6a", options); ``` ## Anteilmäßige Verrechnung steuern Die anteilmäßige Verrechnung wird durch den Parameter [proration_behavior](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-proration_behavior) gesteuert, der über drei mögliche Parameteroptionen verfügt: `create_prorations`, `always_invoice` und `none`. ### Standardverhalten Der Standardparameter für `proration_behavior` ist `create_prorations`, wodurch gegebenenfalls anteilige Rechnungsposten erstellt werden. Diese anteilmäßigen Posten werden nur unter [bestimmten Voraussetzungen](https://docs.stripe.com/billing/subscriptions/change-price.md#immediate-payment) sofort in Rechnung gestellt. ### Sofortige anteilmäßige Verrechnungen erstellen Um einer Kundin/einem Kunden eine Änderung an einem Abo innerhalb desselben Rechnungsstellungszeitraums sofort in Rechnung zu stellen, setzen Sie beim Ändern des Abos `proration_behavior` auf`always_invoice`. Dadurch wird die anteilmäßige Verrechnung berechnet und sofort eine Rechnung erstellt. ### Anteilmäßige Verrechnung deaktivieren Um die anteilige Verrechnung auf Anforderungsbasis zu deaktivieren, legen Sie den Parameter `proration_behavior` auf `none` fest. Es gibt keinen Parameter, der alle zukünftigen anteilmäßigen Verrechnungen für ein Abonnement deaktiviert. Um die anteilmäßige Verrechnung auf unbestimmte Zeit zu deaktivieren, legen Sie `proration_behavior` für jede Anfrage, die anteilmäßige Verrechnungen generiert, auf `none` fest: #### Curl ```bash curl https://api.stripe.com/v1/subscriptions/sub_49ty4767H20z6a \ -u <>: \ -d "items[0][id]"="si_1AkFf6LlRB0eXbMtRFjYiJ0J" \ -d "items[0][price]"="price_CBb6IXqvTLXp3f" \ -d "proration_behavior"="none" ``` #### Ruby ```ruby # 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 = '<>' subscription = Stripe::Subscription.update( 'sub_49ty4767H20z6a', { items: [ { id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f', }, ], proration_behavior: 'none', } ) ``` #### Python ```python # 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 = '<>' subscription = stripe.Subscription.modify( 'sub_49ty4767H20z6a', items=[{ 'id': subscription['items']['data'][0].id, 'price': 'price_CBb6IXqvTLXp3f', }], proration_behavior='none', ) ``` #### PHP ```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\Stripe::setApiKey('<>'); $subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a'); \Stripe\Subscription::update('sub_49ty4767H20z6a', [ 'items' => [ [ 'id' => $subscription->items->data[0]->id, 'price' => 'price_CBb6IXqvTLXp3f', ], ], 'proration_behavior' => 'none', ]); ``` #### Java ```java // 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 = "<>"; Subscription subscription = Subscription.retrieve("sub_49ty4767H20z6a"); SubscriptionUpdateParams params = SubscriptionUpdateParams.builder() .addItem( SubscriptionUpdateParams.Item.builder() .setId(subscription.getItems().getData().get(0).getId()) .setPrice("price_CBb6IXqvTLXp3f") .build()) .setProrationBehavior(SubscriptionUpdateParams.ProrationBehavior.NONE) .build(); subscription.update(params); ``` #### 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 subscription = await stripe.subscriptions.retrieve('sub_49ty4767H20z6a'); await stripe.subscriptions.update('sub_49ty4767H20z6a', { items: [{ id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f', }], proration_behavior: 'none', }); ``` #### Go ```go // 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 = "<>" subscription, err := subscription.Get("sub_49ty4767H20z6a", nil) params := &stripe.SubscriptionParams{ Items: []*stripe.SubscriptionItemsParams{ { ID: stripe.String(subscription.Items.Data[0].ID), Price: stripe.String("price_CBb6IXqvTLXp3f"), }, }, ProrationBehavior: stripe.String(string(stripe.SubscriptionProrationBehaviorNone)), } subscription, err = subscription.Update("sub_49ty4767H20z6a", params) ``` #### .NET ```dotnet // 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 = "<>"; var service = new SubscriptionService(); Subscription subscription = service.Get("sub_49ty4767H20z6a"); var items = new List { new SubscriptionItemOptions { Id = subscription.Items.Data[0].Id, Price = "price_CBb6IXqvTLXp3f", }, }; var options = new SubscriptionUpdateOptions { Items = items, ProrationBehavior = "none", }; subscription = service.Update("sub_49ty4767H20z6a", options); ``` Wenn die anteilmäßige Verrechnung deaktiviert ist, wird Kundinnen/Kunden mit der nächsten Rechnung der gesamte Betrag zum neuen Preis in Rechnung gestellt.