Stripe: The subscription schedule update is missing at least one phase with a `start_date` to anchor end dates to

Viewed 33

I'm trying to create a subscription schedule from existing subscription using Stripe API. My current steps are:

  1. Create subscription
  2. Create subscription schedule from subscription above
  3. Update subscription schedule with new phases

But what I get is an error from the title:

The subscription schedule update is missing at least one phase with a `start_date` to anchor end dates to

Problem is that my code actually does have start_date in the phases:

const subscriptionSchedule = await this.stripe.subscriptionSchedules.create({
  from_subscription: subscription.id
});

return await this.stripe.subscriptionSchedules.update(subscriptionSchedule.id, {
  end_behavior: "release",
  phases:[
    {
      end_date: canceledSubscription.current_period_end,
      items: [{
        price: plan
      }]
    },
    {
      start_date: canceledSubscription.current_period_end,
      items: [{
        price: plan
      }]
    }
  ]
});

So subscription is newly created subscription, and canceledSubscription is the subscription that got canceled in order for new subscription to take effect. And the point of whole logic is for new subscription to start once old one has ended.

So any ideas here would be helpful. Thanks

1 Answers

you're missing a start_date in the first phase.

Example

const subscriptionSchedule = await stripe.subscriptionSchedules.update(
        'sub_...', {
          end_behavior: "release",
          phases:[
            {
              start_date : 1662427226,
              end_date: 1664583692,
              items: [{
                price: 'price_...'
              }]
            },
            {
              start_date: 1664583692,
              items: [{
                price: 'price_...'
              }]
            }
          ]
        }
        );
Related