I'm trying to create a subscription schedule from existing subscription using Stripe API. My current steps are:
- Create subscription
- Create subscription schedule from subscription above
- 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