Billing
Change subscriptions
Cancel

Cancel subscriptions

Learn how to cancel existing subscriptions.

By default, subscriptions and billing continue until cancellation. As configured in your subscription lifecycle settings, a subscription may cancel automatically after up to four unsuccessful attempts to bill the customer. You can also cancel subscriptions yourself, either through the API or the Dashboard. If you want to temporarily offer your products and services for free, you can pause subscriptions instead of canceling them.

Canceling subscriptions

Subscriptions can be canceled through the API:

curl https://api.stripe.com/v1/subscriptions/sub_49ty4767H20z6a \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -X DELETE
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' Stripe::Subscription.delete('sub_49ty4767H20z6a')
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' stripe.Subscription.delete('sub_49ty4767H20z6a')
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a'); $subscription->cancel();
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Subscription subscription = Subscription.retrieve("sub_49ty4767H20z6a"); subscription.cancel();
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); stripe.subscriptions.del('sub_49ty4767H20z6a');
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" subscription, _ := sub.Cancel("sub_49ty4767H20z6a", nil)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var service = new SubscriptionService(); var cancelOptions = new SubscriptionCancelOptions { InvoiceNow = false, Prorate = false, }; Subscription subscription = service.Cancel("sub_49ty4767H20z6a", cancelOptions);

By default, the cancellation takes effect immediately. As soon as a customer’s subscription is canceled, no further invoices are generated for that subscription. You can configure the cancellation to prorate if the cancellation is part of the way through a paid billing period, and optionally invoice for any outstanding prorations and metered usage. Otherwise, all metered usage is discarded and the customer will not be credited for any potential prorations.

If you instead want to cancel the subscription at the end of the current billing period (i.e., for the duration of time the customer has already paid for), update the subscription with a cancel_at_period_end value of true:

curl https://api.stripe.com/v1/subscriptions/sub_49ty4767H20z6a \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -X POST \ -d cancel_at_period_end=true
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' Stripe::Subscription.update( 'sub_49ty4767H20z6a', { cancel_at_period_end: true, } )
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' stripe.Subscription.modify( 'sub_49ty4767H20z6a', cancel_at_period_end=True )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); \Stripe\Subscription::update( 'sub_49ty4767H20z6a', [ 'cancel_at_period_end' => true, ] );
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Subscription subscription = Subscription.retrieve("sub_49ty4767H20z6a"); SubscriptionUpdateParams params = SubscriptionUpdateParams.builder() .setCancelAtPeriodEnd(true) .build(); subscription.update(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); stripe.subscriptions.update('sub_49ty4767H20z6a', {cancel_at_period_end: true});
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SubscriptionParams{ CancelAtPeriodEnd: stripe.Bool(true), } subscription, _ := sub.Update("sub_49ty4767H20z6a", params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var service = new SubscriptionService(); var options = new SubscriptionUpdateOptions { CancelAtPeriodEnd = false, }; Subscription subscription = service.Update("sub_49ty4767H20z6a", options);

When a subscription has been scheduled for cancellation using cancel_at_period_end, it can be reactivated at any point up to the end of the period by updating cancel_at_period_end to false. Any metered usage is charged for in a final invoice when the subscription cancels at the end of the billing period.

Automatically canceling after a dispute

When a customer disputes a charge for a subscription, the subscription continues to cycle, which can create more disputed charges. You can change this behavior in the Stripe Dashboard so that subscriptions are canceled instead. Under Manage disputed payments, select cancel the subscription immediately without prorating or cancel the subscription at the end of the period. It takes about one hour for changes to the subscription to take effect.

If you choose to cancel immediately, the subscription cancels immediately without any prorating. A canceled subscription can’t be restarted, so you must create a new one for the customer if you want to continue billing them.

If you choose to cancel at the end of the period, cancel_at_period_end is set to true and the subscription cancels at the end of the current billing period. This allows you some time to work through the dispute process before the cancellation occurs.

For subscriptions managed with schedules, the subscription is first released from the schedule and then canceled. This means the rest of the scheduled changes won’t take effect.

Invoice items and usage

When a subscription has pending invoice items you’ve created, the customer may still be billed for those if the cancellation is set to include a final invoice or there is another subscription active on the customer. To avoid this, manually delete the invoice items.

Similarly, any usage reported during the billing period is billed at the end of the period. To avoid a final charge for usage, update the subscription and remove the metered price using the clear_usage parameter.

If you set the subscription to cancel at period end, any pending prorations are left in place and still collected at the end of the period. If you cancel the subscription before the end of the period, invoice items will remain—and won’t be processed unless you specifically generate an invoice with them.

Canceling a subscription causes all open and draft invoices for that subscription to have their auto_advance property set to false. This occurs to prevent unexpected automatic payment attempts and reminder emails. This effectively pauses automatic collection for these invoices. You can still manually attempt to collect payment and manually send emails.

Cancellation events

Stripe sends a customer.subscription.deleted event when a customer’s subscription is canceled immediately. If the customer.subscription.deleted event’s request property isn’t null, that indicates the cancellation was made by your request (as opposed to automatically based upon your subscription settings).

If you instead cancel a subscription at the end of the billing period (i.e., by setting cancel_at_period_end to true), a customer.subscription.updated event is immediately triggered. That event reflects the change in the subscription’s cancel_at_period_end value. When the subscription is actually canceled at the end of the period, a customer.subscription.deleted event then occurs.

Reactivating canceled subscriptions

If a customer’s subscription is canceled by updating cancel_at_period_end to true, and the subscription hasn’t yet reached the end of the billing period, it can be reactivated. Subscriptions canceled immediately, however, can’t be reactivated. To reactivate the subscription, update the subscription, setting the value of cancel_at_period_end to false.

# Retrieve the subscription: curl https://api.stripe.com/v1/subscriptions/sub_49ty4767H20z6a \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: # Update the subscription using retrieved ID: curl https://api.stripe.com/v1/subscriptions/sub_49ty4767H20z6a \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d cancel_at_period_end=false \ -d proration_behavior=create_prorations \ -d "items[0][id]"=si_09IkI4u3ZypJUk5onGUZpe8O \ -d "items[0][price]"=price_CBb6IXqvTLXp3f
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = Stripe::Subscription.retrieve('sub_49ty4767H20z6a') Stripe::Subscription.update( subscription.id, { cancel_at_period_end: false, proration_behavior: 'create_prorations', items: [ { id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f' } ] } )
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = stripe.Subscription.retrieve('sub_49ty4767H20z6a') stripe.Subscription.modify( subscription.id, cancel_at_period_end=False, proration_behavior='create_prorations', items=[{ 'id': subscription['items']['data'][0].id, 'price': 'price_CBb6IXqvTLXp3f', }] )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a'); \Stripe\Subscription::update('sub_49ty4767H20z6a', [ 'cancel_at_period_end' => false, 'proration_behavior' => 'create_prorations', 'items' => [ [ 'id' => $subscription->items->data[0]->id, 'price' => 'price_CBb6IXqvTLXp3f', ], ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Subscription subscription = Subscription.retrieve("sub_49ty4767H20z6a"); SubscriptionUpdateParams params = SubscriptionUpdateParams.builder() .setCancelAtPeriodEnd(false) .setProrationBehavior(SubscriptionUpdateParams.ProrationBehavior.CREATE_PRORATIONS) .addItem( SubscriptionUpdateParams.Item.builder() .setId(subscription.getItems().getData().get(0).getId()) .setPrice("price_CBb6IXqvTLXp3f") .build()) .build(); subscription.update(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const subscription = await stripe.subscriptions.retrieve('sub_49ty4767H20z6a'); stripe.subscriptions.update('sub_49ty4767H20z6a', { cancel_at_period_end: false, proration_behavior: 'create_prorations', items: [{ id: subscription.items.data[0].id, price: 'price_CBb6IXqvTLXp3f', }] });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" subscription, err := sub.Get("sub_49ty4767H20z6a", nil) params := &stripe.SubscriptionParams{ CancelAtPeriodEnd: stripe.Bool(false), ProrationBehavior: stripe.String(string(stripe.SubscriptionProrationBehaviorCreateProrations)), Items: []*stripe.SubscriptionItemsParams{ { ID: stripe.String(subscription.Items.Values[0].ID), Price: stripe.String("price_CBb6IXqvTLXp3f"), }, }, } subscription, err = sub.Update("sub_49ty4767H20z6a", params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var service = new SubscriptionService(); Subscription subscription = service.Get("sub_49ty4767H20z6a"); var items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions { Id = subscription.Items.Data[0].Id, Price = "price_CBb6IXqvTLXp3f", }, }; var options = new SubscriptionUpdateOptions { CancelAtPeriodEnd = false, ProrationBehavior = "create_prorations", Items = items, }; subscription = service.Update("sub_49ty4767H20z6a", options);

This prevents the subscription from canceling at the end of the billing period. You can also use the Dashboard’s Reactivate Subscription option.

If the cancellation has already been processed and the subscription is no longer active, a new subscription is needed for the customer. Keep in mind that Stripe immediately starts your customer’s subscription under a new billing cycle, so this action results in a new charge. You can override this behavior using the trial_end parameter so the customer isn’t immediately billed (e.g., to maintain the old billing cycle).

See also

Was this page helpful?
Questions? Contact us.
Developer tutorials on YouTube.