Skip to content

Commit 919a856

Browse files
committed
Fix: when cancelling a downgrade, scheduled_tier was not being cleared
1 parent f23f122 commit 919a856

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/billing/src/subscription-webhooks.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,14 @@ export async function handleSubscriptionScheduleReleasedOrCanceled(params: {
505505
}): Promise<void> {
506506
const { schedule, logger } = params
507507

508+
// When a schedule is released, the subscription field becomes null and
509+
// the subscription ID moves to released_subscription. When canceled,
510+
// the subscription field is retained. Check both fields.
508511
const subscriptionId = schedule.subscription
509512
? getStripeId(schedule.subscription)
510-
: null
513+
: schedule.released_subscription
514+
? getStripeId(schedule.released_subscription)
515+
: null
511516

512517
if (!subscriptionId) {
513518
logger.debug(

0 commit comments

Comments
 (0)