I'm using the Stripe API to configure the billing portal and allow subscription updates with scheduled downgrades. But, when I attempt to select a lower tiered plan with a shorter interval, the downgrade is not scheduled to occur at the period end, even though I believe my configuration is correct.
According to the Stripe documentation from October 2024:
"You can now configure the customer portal so that subscription downgrades occur at the end of the billing cycle, rather than immediately."
I made sure my Stripe SDK is updated to the latest version too.
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: '2024-12-18.acacia'
});
const configuration = await stripe.billingPortal.configurations.create({
features: {
payment_method_update: { enabled: true },
subscription_cancel: { enabled: true, mode: 'at_period_end' },
subscription_update: {
enabled: true,
proration_behavior: 'none',
default_allowed_updates: ['price'],
products: subscriptionUpdateProducts,
schedule_at_period_end: {
conditions: [
{ type: 'shortening_interval' } // Schedule downgrades at period end (Not working)
]
}
},
invoice_history: { enabled: true }
},
business_profile: {
headline: 'Manage your subscription'
}
});
const session = await stripe.billingPortal.sessions.create({
customer: customerId,
configuration: configuration.id,
return_url: `${process.env.FRONTEND_URL}/app/price/price1`
});
New subscription updated to, clearly with a shortened interval as its a per month subscription but still trying to charge me immediately
The issue was that I had three separate subscription products (e.g., one month, three months, and one year), and users were switching between them. However, for the billing portal to handle subscription updates correctly, the subscriptions need to be part of a single product with multiple pricing tiers.
The correct approach is to have a single subscription product with all pricing tiers (e.g., one month, three months, one year) associated with it. Users should be allowed to change prices within the same product. If a user changes to a different product, the billing portal will process the change immediately instead of applying the correct "schedule at period end" behavior.