#TonyS
1 messages · Page 1 of 1 (latest)
Hey there
Released means that the underlying Sub is kept going whereas canceled means the underlying Sub was also canceled at the end of the Sub Schedule
Ok what we try to do is the following : our user can downgrade their current subscription with another subscription and hence loosing some privileges. What we do is schedule the new subscription at the end of their current subscription so this is "smooth" downgrade.
We like to print to them how much they will pay and hence we create subscription to have access to all the details about price etc... and then release the subscription schedule. It's made only to do a simulation
The subscriptionSchedules of the Customer is therefore not empty, and contains a subscription plan with a status "released"
Could we consider that this "released" status means the schedule is not going through?
(Sorry if I'm unclear do not hesitate to ask about more details)
So first, you don't need a schedule for this if you are just using it for a preview. You can use https://stripe.com/docs/api/invoices/upcoming and it will be much cleaner
That said, why are you creating a new Subscription upon the downgrade, why not just downgrade the current Subscription?
Ok I simplified a little bit our use case I will go more in details and you let me know if we do the right thing
We have 2 kinds of subscription : Basic and Pro. Pro has more features obviously and is more expensive. Users can pay monthly of yearly for both plans
We let our users change their plan freely in their account details
meaning a Customer that paid Basic Yearly can decide to upgrade to a Pro Yearly plan. Hence, we apply a discount proportional to the amount of unused days of his Basic Yearly subscription.
We have 2 parts : 1) we show the user how much he will pay by doing the switch 2) Actually doing the switch
Hence, we apply a discount proportional to the amount of unused days of his Basic Yearly subscription.
You are calculating this yourself right now?
Or you use our proration?
we indeed use stripe proration to do the calculation
We do not downgrade immediatly the subscription because someone that for example switch from Pro Monthly to Basic Monthly will still benefit from the Pro Feature until the end of his period
We rely on subscriptionSchedule to do the simulation with the proration data and get the calculation of the discount and so on
Do you think this is not the right way of doing this?
Well it depends. That is a fine way to do it if you are going to leave the Sub Schedule in place and then downgrade at the end of the cycle based on the Sub Schedule actions. It sounds like from the above that you are instead canceling the Sub and creating a new one at the end of the cycle?
we release the subscription since we use it only to "simulate" the price and show the calculation to our users
the subscription schedule*
How do you perform the actual update?
depending if it's an upgrade or a downgrade we change the plan or we create a subscription schedule
Oh okay. So you are literally just creating a Sub Schedule for the preview here in your UI and then handling the upgrade/downgrade separately.
yes
Then no, this is not the best way. Much much easier to just use https://stripe.com/docs/api/invoices/upcoming which I mentioned above
Ok I'll check it out thanks you so much
That endpoint allows you to preview any update to the Subscription
that seems awesome
And it will do all of the calculations that you are currently relying on the fake Sub Schedule for
So yeah, check that out
It doesn't actually create an invoice at all
It just previews what the invoice would be
Ok I think we tried this solution but I do not recall exactly why we discarded it, I'll have a look thanks again very much
Check it out and come back if you run into any challenges!
Just to be clear, to do the exact simulation
meaning
someone paid 150€ at a Basic Yearly Plan and used only 50% of his plan
and decide to upgrade to a Pro Yearly Plan at 200€
we should show to him 200€ - 75€= you'll pay 125€
Yep that endpoint will calculate that
this is done with the Retrieve an upcoming invoice ?
So retrieve actually "create" an invoice kind of ?
Yep basically simulates the creation of an invoice for you with all the details
Ok checking it now thanks! Have a great day