Update subscription at next billing cycle.

3,585 views
Skip to first unread message

Akshay Chavan

unread,
May 23, 2017, 9:06:48 AM5/23/17
to Stripe API Discussion
Hi,

I want to implement recurring payments in my application. I do not want any reduction in the quantity of plan to be reflected immediately instead of that I want any update should happen at next billing cycle. Stripe API does not allows to update subscription at next billing cycle also webhook does not inform that subscription is going to end at the period.  Am I suppose to end current subscription and resubscribe with new quantity? or there is any other workaround to this?

Remi J.

unread,
May 23, 2017, 9:16:33 AM5/23/17
to api-d...@lists.stripe.com
Hey Akshay,

One solution here would be to downgrade the subscription immediately and disable any proration. The idea would be to call the Update Subscription API [1], set the new quantity and pass `prorate: false` so that we don't credit the customer yet. On the next billing cycle, a new invoice will be created for the new quantity automatically.

You would be able to keep track of the original quantity in your own database so that you can display the right information to your customer until the end of the current billing cycle. At the end, you'd be able to update your database to reflect the new quantity that is now officially in place.

Otherwise, canceling the current subscription when it's renewed would automatically close the pending invoice. You'd then create a new subscription with the new quantity so that the customer is charged the new amount for the new quantity immediately. This would be less flexible as you wouldn't be able to rely on the retry logic anymore after a failed payment.

Hope this helps!
Remi

On Tue, May 23, 2017 at 6:24 AM, Akshay Chavan <akshay...@krixi.in> wrote:
Hi,

I want to implement recurring payments in my application. I do not want any reduction in the quantity of plan to be reflected immediately instead of that I want any update should happen at next billing cycle. Stripe API does not allows to update subscription at next billing cycle also webhook does not inform that subscription is going to end at the period.  Am I suppose to end current subscription and resubscribe with new quantity? or there is any other workaround to this?

--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.

Akshay Chavan

unread,
May 24, 2017, 9:28:42 AM5/24/17
to Stripe API Discussion
Hey Remi,

Thanks for the information.

I have started with the first approach that you have suggested. But I am having a very tricky problem due to which customer is getting charged for extra quantities. Here is the scenario

Suppose I have a created a plan of 10$ per month and user Subscribe to this plan.

Now user updates subscription in the following manner.

Actions in same month(1) Add +1(2)Add +1(3)Reduce -1(4)Add +2
Stripe Quantity1213
Database Quantity1223
charge10$10$0$20$

 At action (2) the user has already paid for two licenses so when user reduce the quantity(3) stripe will not generate the credit as well as an invoice. In case of action(4) user think that he has paid for two licence so I am able to access then at the application level, but when he moved to a quantity to three user ends up paying for two licenses but ideally, he should be paying for 1 quantity. How to tackle this at stripe side? I don't want to refund money for reduction and also want the user to have access to the licence for which he/she has already paid.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Remi J.

unread,
May 24, 2017, 10:10:28 AM5/24/17
to api-d...@lists.stripe.com
Hey Akshay,

You'll need to handle this logic on your end unfortunately. For example, you could move them back to quantity `2` without proration, as you know they already paid for this and then upgrade to quantity `3` with proration so that we charge them only for the increase of the quantity by 1.

It's definitely not the cleanest solution but there's no better way if you want the downgrade to happen immediately. I'd personally go with the other option when I downgrade at the end of the period instead by canceling the subscription first and then creating a new one with the new quantity if it changed.

Cheers,
Remi

To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.

Akshay Chavan

unread,
May 25, 2017, 8:34:01 AM5/25/17
to Stripe API Discussion
Hey Remi,

I have a question here,

If the user moves the to quantity '3' from quantity '1' and we have quantity in the database is '2'. 

So, as you suggested I will set quantity from '1' to '2' using prorate false and I will again update stripe quantity from '2' to '3' using prorate true.  

But What would be actual value will be get reflected in next invoice? eg  $30(ie. 3 quanity * amount) or $30+1 license amount for which prorate was set to false when quantity was updated?

I don't want the user to be get charged extra in the next billing cycle. 

Remi J.

unread,
May 25, 2017, 8:38:22 AM5/25/17
to api-d...@lists.stripe.com
Hey Akshay,

The next invoice would charge for the new quantity and the new billing cycle, so in your example $30, along with the proration calculated for the move from quantity 2 to quantity 3 during the billing cycle. Assuming the upgrade happened right at the middle of the month, the customer would be owed $10 (for half a month with quantity 2) and he would owe you $15 (for half a month with quantity 3). Ultimately he would owe you $5 extra for the current month and would be charged $35 on the next billing cycle. This is expected as they only paid for quantity 2 and they end up using quantity 3 for the current billing cycle.

I'd recommend playing with this in Test mode as you can simulate all of this by enabling or disabling proration and quickly see what would appear on the upcoming invoice both in the API or in the dashboard!

If you have follow-up questions, I'd recommend emailing our support team directly from here: https://support.stripe.com/email and they will be able to look into your account with you and clarify any upgrade or downgrade that confused you.

All the best,
Remi

To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.

Yarden Even

unread,
Jun 13, 2020, 2:22:49 PM6/13/20
to Stripe API Discussion, akshay...@krixi.in
Checking if this has somehow changed in the last 3 years.  I have a similar use case and I don't wish to cancel the subscription but to downgrade it at the end of the period. 

Are the answers here still relevant ones?

The perfect solution (in my opinion) would if Stripe could change plans at period end, and when changing it would trigger a webhook so my backend will get updated as well.

Remi J.

unread,
Jun 13, 2020, 2:25:14 PM6/13/20
to api-d...@lists.stripe.com, akshay...@krixi.in
Hello Yarden,

This is definitely something you can do now using SubscriptionSchedules as documented here: https://stripe.com/docs/billing/subscriptions/subscription-schedules

The idea is that you create a schedule to manage your subscription with multiple separate phases. You would create a schedule from you existing Subscription which would have the current cycle as its ongoing phase and you would add a new phase that represents the downgrade operation.

Hope this helps!
Remi

--

Yarden Even

unread,
Jun 13, 2020, 2:38:01 PM6/13/20
to Stripe API Discussion, akshay...@krixi.in
Thanks for the very needed information and the swift reply.
To unsubscribe from this group and stop receiving emails from it, send an email to api-d...@lists.stripe.com.

Yarden Even

unread,
Jun 17, 2020, 12:08:53 PM6/17/20
to Stripe API Discussion, akshay...@krixi.in
In the scenario that you described, do all the subscriptions have to become managed using phases?

Right now I switch between plans whenever the user requests for a change. After starting to use phases, as I understand it, I'll always have to use phases. I'll have some accounts with phases and others without.
That introduces some overhead as I'll have to check for each new plan-change if it's managed by phases or not. 

Is this the best practice for subscriptions? to manage them with schedules and phases? if so, why isn't a schedule being created automatically as I create the subscription? 

Just for framing, my exact scenario is that upgrades to the account happen immediately and downgrades should happen at the end of the current period, so users won't lose the time they paid for.
I don't use Cancel Subscription because we use a subscription for the free tier as well, as it's more convenient to simply change between plans on an existing subscription.


On Saturday, June 13, 2020 at 9:25:14 PM UTC+3, Remi J. wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to api-d...@lists.stripe.com.

Remi J.

unread,
Jun 17, 2020, 12:12:31 PM6/17/20
to api-d...@lists.stripe.com, akshay...@krixi.in
Yes, I would say using Subscription Schedules is the best option in your situation. In most cases you shouldn't have to dig into whether the Subscription is now managed by a schedule since your only usage will be to defer a downgrade at the end of the period. The only reason to dig would be to plan a different downgrade at the end of the month or to surface whether they have a scheduled change (which you could store in your own database).

Also the Subscription stays active and unchanged, it just has the `schedule` property [1] set to the Subscription Schedule that controls it. At the end of the period, the schedule will change the Subscription for the new plan and then release the Subscription.


To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Yarden Even

unread,
Jun 17, 2020, 8:16:56 PM6/17/20
to Stripe API Discussion, akshay...@krixi.in
That's not what I understood from the docs. Please correct what I got wrong:

What I understand is that you attach a plan to a phase and it starts at the beginning of the phase. So if I wish to downgrade, I create a phase that starts in the future (current_period_end) and attach the free plan to it. Then it runs indefinitely on that phase unless you give it an end date.
I didn't see an option there to apply the specified plan when the phase ends. So as I understood it when one phase ends you must specify another phase.

I would love to know how to implement it the way you specified, where I can start a plan at the end of the phase and release the current phase so now the subscription remains "phase-less".
To unsubscribe from this group and stop receiving emails from it, send an email to api-d...@lists.stripe.com.

Remi J.

unread,
Jun 17, 2020, 9:45:58 PM6/17/20
to api-d...@lists.stripe.com
What you described is correct but it doesn't really conflict with what I was explaining I think but that API is definitely advanced and powerful so there's a lot you can do with it.

The idea is that you have a Subscription today with one plan called plan A and the billing cycle is monthly. What you should do is create a SubscriptionSchedule from that subscription first by passing `from_subscription: "sub_123"`. This will create a Schedule with one phase, which matches the current subscription's billing cycle. Then, you can update that Schedule to repeat that first phase and add a second one that will be on plan B. At the end of that second phase, the Schedule will terminate and release the Subscription and you'll now have the same subscription again but on plan B now.

Here's some simple PHP code that does this: https://hastebin.com/jajiguwiko.php

It doesn't cover all situations where you have tax rates or discounts ongoing but for a simple subscription with one plan, it should work as you'd expect.

I hope this makes things clearer!
Remi

To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Yarden Even

unread,
Jun 20, 2020, 3:13:12 PM6/20/20
to Stripe API Discussion
Thank you Remi for all the help.
To unsubscribe from this group and stop receiving emails from it, send an email to api-d...@lists.stripe.com.
Reply all
Reply to author
Forward
0 new messages