My goal
When a customer want to downgrade to a cheaper subscription, let he/she use current subscription until the end of current billing period, then switch to cheaper subscription automatically. Also I need to be notified about the change so that I can run some internal logic.
What I have tried
I have used subscription schedule to schedule for price change of a subscription at the end of its current period. Using Stripe dashboard I can see that the price has been successfully changed with correct timing, but:
- There was no webhook event. I am expecting customer.subscription.updated event, and also tried to listen to subscription_schedule.updated event without success.
- The customer was not charged for the new price, even after waiting for a few hours.
Bellow are detailed steps:
- Customer subscripts to a daily price.
- Customer want to change subscription to a cheaper price.
- I create a subscription schedule from the subscription with:
stripe.subscriptionSchedules.create({ from_subscription: subId }).
- I then update the schedule with:
stripe.subscriptionSchedules.update(schedule.id, {
phases: [
{
start_date, // billing_cycle_anchor of current subscription
items: [
{ price: currentPriceId, quantity: 1 }, // current plan to be used until period end
],
iterations: 1, // 'iterations' is set to 1, this is important because we want current phase to end at the end of current period
},
{
proration_behavior: 'none', // no proration when transition to this phase
items: [
{ price: nextPriceId, quantity: 1 }, // new plan to be switched to after current period
],
iterations: 1, // 'iterations' is set to 1 and 'end_behavior' need to be set to 'release'
},
],
end_behavior: 'release', // release this schedule after last phase, so that subscription will continue as normal
});
EDIT: This strange behavior is because our Stripe Account is blacklisted due to a problem with the credit card we are using. Resolve the credit card problem and everything is back to normal.