#Hydriad

1 messages · Page 1 of 1 (latest)

olive solsticeBOT
main spire
tribal hamlet
#

Hello

main spire
#

Hi! Happy to answer any clarifying questions

tribal hamlet
#

Hmm why couldn't you replace it?

#

What happened exactly?

main spire
#

ok here's the first time which succeeds:

#
const updatedSchedule = await stripe.subscriptionSchedules.update(
  `${subscription.schedule}`,
  {
    phases: [
      {
        items: [
          {
            plan: subscription.items.data[0]?.plan.id,
            quantity: subscription.items.data[0]?.quantity, // existing capacity
          },
        ],
        start_date: subscription.current_period_start,
        end_date: subscription.current_period_end,
      },
      {
        items: [
          {
            plan: subscription.items.data[0]?.plan.id,
            quantity: body.cap, // new capacity
          },
        ],
        start_date: subscription.current_period_end,
      },
    ],
  },
);

which worked. but then trying to do that a second time results in error "You can not update a phase that has already ended. Trying to update phase 0."

tribal hamlet
#

If you release a schedule you can't update it.

#

You would have to re-create it

#

Unless I'm misunderstanding what you are trying to accomplish?

main spire
#

ok thank you, how can I re-create or replace a schedule on an existing subscription? I tried

const schedule2 = await stripe.subscriptionSchedules.create({
    from_subscription: subscriptionId,
});

and got the error "You cannot migrate a subscription that is already attached to a schedule"

tribal hamlet
#

That error should only fire if you still have a schedule attached

main spire
#

i'll try that right now

#

you mean like this right?

const releasedSchedule = await stripe.subscriptionSchedules.release(
  scheduleId,
);
const newSchedule = await stripe.subscriptionSchedules.create({
  from_subscription: subscriptionId,
});
tribal hamlet
#

Yep

main spire
#

I get the error "You cannot update a subscription schedule that is currently in the released status. It must be in not_started, active status to be updated."

tribal hamlet
#

Hmm sounds like you already released that schedule?

main spire
#

yes in the line above creating it is where it's released

#

is there a way to remove a schedule from a subscription entirely and then create a new one?

#

or remove all phases from a schedule?

tribal hamlet
#

Sorry I don't understand. The error wouldn't be saying "You cannot update a subscription schedule" if you are creating a new one

main spire
#

okay i'll try commenting out everything else that might be interfering, thank you so much so far