#El_Chapalero - Subscription Schedule

1 messages · Page 1 of 1 (latest)

jade elbow
#

Hello, what are you running in to that we can help with?

scarlet light
#

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

jade elbow
#

Thanks for the request ID. Checking in to this

scarlet light
#

Great thanks

#

I think my problem is that Im not making my phases array correctly.

dreamy pasture
#

the end date for phase 0 was updated to now , so any subsequent requests to update phase 0 will fail

scarlet light
#

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?

dreamy pasture
#

got it

#

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

scarlet light
#

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

dreamy pasture
#

looking!

scarlet light
#

Thanks, I appreciate all the help

dreamy pasture
#

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

scarlet light
#

Ok, let me try something

#

If I want to keep the current phase the same, do I need to pass it in?

dreamy pasture
#

yes

scarlet light
#

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?

dreamy pasture
#

do you have a request ID for that error?

scarlet light
#

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.

dreamy pasture
#

ah i see!

scarlet light
#

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

dreamy pasture
#

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

scarlet light
#

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

dreamy pasture
#

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

scarlet light
#

Ok that actually worked!

#

Not sure how I missed that property, thank you!

scarlet light
#

Is there a way to get the most updated logs? It seems to be behind by around 10 minutes

dreamy pasture
#

depending on what you're looking for, you may need to adjust the filters at the top

scarlet light
#

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?

ionic verge
#

Hi there! Stepping in. This should mean that the actual update is still yet to take place because it is scheduled for the future

scarlet light
#

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

ionic verge
#

Can you provide the Subscription ID you are looking at?

scarlet light
#

yes sub_1Ku0ePJ9bSycjaToIY9WrlnD

ionic verge
#

Thanks, looking!

scarlet light
#

Thanks

ionic verge
#

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).

scarlet light
#

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?

ionic verge
#

Yep

#

The Schedule looks good to me

scarlet light
#

Ok great. Well you guys have been a huge help. Thanks a lot!