Skip to content

Commit 82e846b

Browse files
committed
🔧 auto cancel at period end when subscription becomes "unpaid"
1 parent cdc177d commit 82e846b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/billing/src/api/webhookHandler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ export const webhookHandler = async (
208208
previous.status !== "unpaid" &&
209209
!existingWorkspace.isQuarantined
210210
) {
211+
if (!subscription.cancel_at_period_end)
212+
await stripe.subscriptions.update(subscription.id, {
213+
cancel_at_period_end: true,
214+
});
211215
await prisma.workspace.updateMany({
212216
where: {
213217
id: existingWorkspace.id,

0 commit comments

Comments
 (0)