#mikes - Schedule Update

1 messages · Page 1 of 1 (latest)

atomic gulch
#

Subscription schedules can help you with that

clear wigeon
#

Thank you. I am trying to pass a new item with the updated price, and the start_date, but if I only pass in one phase I get You can not modify the start date of the current phase

#

that is the response I get when I go to update.

#

Seems like maybe I am missing a way to reference the current phase that was created when I created the schedule?

atomic gulch
#

Can you show me what your current call looks like?

clear wigeon
#

await stripe.subscriptionSchedules.update(stripeSub.id, {
  end_behavior: 'release',
  phases: [
    {                          start_date: transitionDate,
     items: [{ price:     'price_1KFQD8AdcHugBdl61DpTQJxI', quantity: 1 }]
    }
  ]
});
#

if I prepend an object to the phases array containing what items the subscription currently contains, I get The subscription schedule update is missing at least one phase with a `start_date` to anchor end dates to

atomic gulch
#

So you will want to pass in two phases when you update the schedule

#

The first one should be a copy of the current phase of the schedule with the addition of end_date: transitionDate

#

And the second phase would be the price you want it to update to

clear wigeon
#

thank you, that is what I am doing in my message immediately above and getting that error message

#

I believe this is what you are telling me to do, but I get The subscription schedule update is missing at least one phase with a `start_date` to anchor end dates to

atomic gulch
#

When you create the schedule, the one phase that it has should have a start_date

#

You will want to pass that back in as the start_date of the first phrase

#

In fact just copy the entire phase object from that original schedule if you can

clear wigeon
#

the original schedule has no phase object because it is existing

#

i am creating with from_subscription

#

so I cant set phase values at creation time

atomic gulch
#

The call with from_subscription should return a schedule with phases with that info

#

As in stripeSub from your snippet. If stripeSub does not have a phases property, can you send me its ID?

clear wigeon
#

it does have that property, thank you. trying it now!

#

@atomic gulch that worked - the start_date needed to match the unix timestamp exactly. thanks so much for your help!

atomic gulch
#

Glad to hear!