Update a subscription
Updates an existing subscription to match the specified parameters. When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes. To preview how the proration is calculated, use the upcoming invoice endpoint.
By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a 100 USD price, they’ll be billed 100 USD immediately. If on May 15 they switch to a 200 USD price, then on June 1 they’ll be billed 250 USD (200 USD for a renewal of her subscription, plus a 50 USD prorating adjustment for half of the previous month’s 100 USD difference). Similarly, a downgrade generates a credit that is applied to the next invoice. We also prorate when you make quantity changes.
Switching prices does not normally change the billing date or generate an immediate charge unless:
- The billing interval is changed (for example, from monthly to yearly).
- The subscription moves from free to paid, or paid to free.
- A trial starts or ends.
In these cases, we apply a credit for the unused time on the previous price, immediately charge the customer using the new price, and reset the billing date.
If you want to charge for an upgrade immediately, pass proration_behavior
as always_invoice
to create prorations, automatically invoice the customer for those proration adjustments, and attempt to collect payment. If you pass create_prorations
, the prorations are created but not automatically invoiced. If you want to bill the customer for the prorations before the subscription’s renewal date, you need to manually invoice the customer.
If you don’t want to prorate, set the proration_behavior
option to none
. With this option, the customer is billed 100 USD on May 1 and 200 USD on June 1. Similarly, if you set proration_behavior
to none
when switching between different billing intervals (for example, from monthly to yearly), we don’t generate any credits for the old subscription’s unused time. We still reset the billing date and bill immediately for the new subscription.
Updating the quantity on a subscription many times in an hour may result in rate limiting. If you need to bill for a frequently changing quantity, consider integrating usage-based billing instead.
Parameters
- cancel_
at_ period_ endboolean Boolean indicating whether this subscription should cancel at the end of the current period.
- default_
payment_ methodstring ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over
default_source
. If neither are set, invoices will use the customer’s invoice_settings.default_payment_method or default_source. - descriptionstring
The subscription’s description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.
- itemsarray of Maps
A list of up to 20 subscription items, each with an attached price.
- metadataMap
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata
. - payment_
behaviorenum Use
allow_incomplete
to transition the subscription tostatus=past_due
if a payment is required but cannot be paid. This allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior.Use
default_incomplete
to transition the subscription tostatus=past_due
when payment is required and await explicit confirmation of the invoice’s payment intent. This allows simpler management of scenarios where additional user actions are needed to pay a subscription’s invoice. Such as failed payments, SCA regulation, or collecting a mandate for a bank debit payment method.Use
pending_if_incomplete
to update the subscription using pending updates. When you usepending_if_incomplete
you can only pass the parameters supported by pending updates.Use
error_if_incomplete
if you want Stripe to return an HTTP 402 status code if a subscription’s invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not update the subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more. - proration_
behaviorenum Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting
billing_cycle_anchor=now
, or starting a trial), or if an item’squantity
changes. The default value iscreate_prorations
.
More parameters
- add_
invoice_ itemsarray of Maps - application_
fee_ percentfloatConnect only - automatic_
taxMap - billing_
cycle_ anchorstring - billing_
thresholdsMap - cancel_
attimestamp - cancellation_
detailsMap - collection_
methodenum - couponstringDeprecated
- days_
until_ dueinteger - default_
sourcestring - default_
tax_ ratesarray of strings - discountsarray of Maps
- invoice_
settingsMap - off_
sessionboolean - on_
behalf_ ofstring - pause_
collectionMap - payment_
settingsMap - pending_
invoice_ item_ intervalMap - promotion_
codestring - proration_
datetimestamp - transfer_
dataMapConnect only - trial_
endstring | timestamp - trial_
from_ planboolean - trial_
settingsMap
Returns
The newly updated Subscription
object, if the call succeeded. If payment_behavior
is error_if_incomplete
and a charge is required for the update and it fails, this call raises an error, and the subscription update does not go into effect.
Retrieve a subscription
Retrieves the subscription with the given ID.
Parameters
No parameters.
Returns
Returns the subscription object.
List subscriptions
By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled
.
Parameters
- customerstring
The ID of the customer whose subscriptions will be retrieved.
- pricestring
Filter for subscriptions that contain this recurring price ID.
- statusenum
The status of the subscriptions to retrieve. Passing in a value of
canceled
will return all canceled subscriptions, including those belonging to deleted customers. Passended
to find subscriptions that are canceled and subscriptions that are expired due to incomplete payment. Passing in a value ofall
will return subscriptions of all statuses. If no value is supplied, all subscriptions that have not been canceled are returned.
More parameters
- automatic_
taxMap - collection_
methodenum - createdMap
- ending_
beforestring - limitinteger
- starting_
afterstring - test_
clockstring
Returns
Returns a list of subscriptions.
Cancel a subscription
Cancels a customer’s subscription immediately. The customer will not be charged again for the subscription.
Note, however, that any pending invoice items that you’ve created will still be charged for at the end of the period, unless manually deleted. If you’ve set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed.
By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.
Parameters
No parameters.
More parameters
- cancellation_
detailsMap - invoice_
nowboolean - prorateboolean
Returns
The canceled Subscription
object. Its subscription status will be set to canceled
.
Resume a subscription
Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active
, and if payment fails the subscription will be past_due
. The resumption invoice will void automatically if not paid by the expiration date.
Parameters
- billing_
cycle_ anchorstring Either
now
orunchanged
. Setting the value tonow
resets the subscription’s billing cycle anchor to the current time (in UTC). Setting the value tounchanged
advances the subscription’s billing cycle anchor to the period that surrounds the current time. For more information, see the billing cycle documentation. - proration_
behaviorenum Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting
billing_cycle_anchor=now
, or starting a trial), or if an item’squantity
changes. The default value iscreate_prorations
.
More parameters
- proration_
datetimestamp
Returns
The subscription object.