#El_Chapalero - Subscription Schedule
1 messages · Page 1 of 1 (latest)
Hi there. I am running into an error saying I cant update a phase that has already ended.
All I am trying to do is update the current schedule to a new one.
This is the request id req_BXlAckVjD5Cl8K
Thanks for the request ID. Checking in to this
It looks like the subscription schedule was updated shortly before that failed request: https://dashboard.stripe.com/test/logs/req_gTTibFf9Tt7VIw
the end date for phase 0 was updated to now , so any subsequent requests to update phase 0 will fail
Ok. That makes sense, however I wasnt trying to update phase 0, I was trying to update the current phase and add a new one. How do I specifically update the current one?
got it
your request to update a subscription schedule should include any current and future phases you want to keep in the schedule: https://stripe.com/docs/billing/subscriptions/subscription-schedules#updating
if you want to end the phase for price_1KsS82J9bSycjaToX4l8bShN and start a new one, you can set the end_date of the current phase to now
how do I specify the current phase though? This is the phase value I pass in
{
items: [{ price: currentPlanPrice.data[0].id, quantity: 1 }],
start_date: subscription.current_period_start,
end_date: subscription.current_period_end,
},
{
items: [{ price: newPlanPrice.data[0].id, quantity: 1 }],
start_date: subscription.current_period_end,
iterations: 1,
},
],```
The first one is the current phase, and the second is the new phase
But the error I get is that I cant modify a phase that has ended
looking!
Thanks, I appreciate all the help
i think you'll either want to store information about the current phase in your own system or retrieve a subscription schedule prior to updating its phases
when retrieving a subscription schedule, index 0 in the phase array will be the current phase
Ok, let me try something
If I want to keep the current phase the same, do I need to pass it in?
yes
Ok, if I pass in the current phase from when I retrieved the subscriptionSchedule, it gives me a ton of errors for empty parameters. Is there a way to solve that easily or do I just have to remove them all?
do you have a request ID for that error?
I do but it didnt work anyways, I ended up with an error about an invalid decimal which I assume is something from the phases object.
ah i see!
i believe it's this request that failed: https://dashboard.stripe.com/test/logs/iar_DZni726RRyiPNX
Ok, so I think the problem is that when I am retrieving the current subscriptionSchedule, phases[0] is actually a phase that is in the past
Because when I send an update with those values from phase[0] it immediately ends
if a subscription schedule includes multiple phases and the intent is to update the schedule but leave some phases unchanged, you should only include the phase items in your request: https://stripe.com/docs/api/subscription_schedules/update#update_subscription_schedule-phases-items
in the failed request above, application_fee_percent, billing_cycle_anchor, etc. and any other parameters that you don't intend to update should be omitted
Ya I figured that part out, the request I was looking at now is req_6xzNLLhn5Y8l65
This is when I updated a subscriptionSchedule with phase[0] using the values I got from the retrieve request. The timestamp for the end date is actually in the past for phase 0
So I guess my question is how can I get the actual current phase, because I retrieved the subscriptionSchedule phase 0 was one that was in the past
yes, i think i misspoke here. there is a current_phase parameter on the schedule object, but this just has the start/end times for the current phase
i think the best way to do this is to store information on your end about the current phase or retrieve a subscription schedule, inspect the start/end times of current_phase, and use that to determine which phase items to keep in your update call and which to omit
Is there a way to get the most updated logs? It seems to be behind by around 10 minutes
logs should be up to date in the dashboard: https://dashboard.stripe.com/test/logs
depending on what you're looking for, you may need to adjust the filters at the top
ok, it seems if I adjust to only the last hour it gives me the latest
Ok, last question. I made the update to my subscriptionSchedule, and the request was successful but it seems it didnt actually change it yet, and theres an icon that says Update scheduled next to the subscription
what does that mean?
Hi there! Stepping in. This should mean that the actual update is still yet to take place because it is scheduled for the future
Ok so Im a bit confused, if I click the "manage scheduled update" it says the product will be changing from the 40/month to 5/month option, which is correct. However if I go to the customer, it shows that their next bill will include a charge for the 40/month subscription not the 5/month one
Can you provide the Subscription ID you are looking at?
yes sub_1Ku0ePJ9bSycjaToIY9WrlnD
Thanks, looking!
Thanks
Okay yeah, so I just double checked and Sub Schedules and the upcoming invoice endpoint aren't fully compatible right now. There is already a feature request in to improve this but not a timeline currently. So you won't see the Sub Schedule change reflected when using the upcoming invoice API (which is what the Dashboard is showing).
Ok, interesting. So this means the upcoming invoice API is the one thats incorrect here right?
And it will actually charge the $5 plan for the next month as shown in the schedule?
Ok great. Well you guys have been a huge help. Thanks a lot!