Bugra
Bugra

Reputation: 189

Stripe subscriptions: Modify when period ends instead of now

Context: There is a Stripe plan "Starter". The customer subscribes to the "Starter" plan. Within a subscription period the user wants to up- or downgrade the subscription (in my case: the quantity will be increased or decreased). Programmatically I want to achieve this with a subscription update.

Problem: Stripe wants to make the update immediately. But I want to have it changed at the end of the period.

Alternatives:

I'm relly looking forward for (high-level) solutions to solve this problem. Thank you in advance.

Upvotes: 1

Views: 1782

Answers (2)

Bugra
Bugra

Reputation: 189

This is what I discussed with the Stripe support channel:

I understand that scheduling is not the best fit for you, as you'd have to release the schedule once the update is made so the new subscription rolls over, and this doesn't cancel the subscription, but start a new one.

What you could do, is to cancel the first subscription at_period_end, and then start the next one when the event customer.subscription.deleted comes through: https://stripe.com/docs/api/events/types#event_types-customer.subscription.deleted

If you don't want to use Webhooks, you can also cancel at period end and then generate the new subscription at the same time using the billing cycle anchor https://stripe.com/docs/api/subscriptions/create#create_subscription-billing_cycle_anchor. This will only work though for subscriptions with the same interval, or if the second subscription interval is shorter than the first.

I implemented the webhook solution. It works perfectly for me.

Upvotes: 3

Imtiaz Sakib
Imtiaz Sakib

Reputation: 1849

So you want to update the subscription details at the end of the current period. In that case, you may want to use the subscription webhook events mentioned here

"When the subscription period elapses, invoice.created event is sent, indicating the creation of a draft invoice."

"About an hour after the invoice is created, it is finalized (changes are no longer permitted), and an invoice.finalized event is sent."

So you can listen to that invoice.created event and then update the subscription.

Upvotes: 2

Related Questions