Skip to content

Commit

Permalink
fix: make sure the Polar subscription is active on `subscription.upda…
Browse files Browse the repository at this point in the history
…ted` (#94)

The `subscription.updated` event is sent whenever something happens on a subscription, including cancellation, revokation, or past due payment.

This is why we should check the `status` property before enabling the pro plan on the organization.
  • Loading branch information
frankie567 authored Feb 7, 2025
1 parent 26052d4 commit 6768e02
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/web/src/app/api/webhook/polar/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const POST = Webhooks({
break;
}

// Make sure the subscription is active before setting the plan
if (payload.data.status !== 'active') {
break;
}

await updateOrganization({
id: payload.data.metadata.organizationId as string,
polarCustomerId: payload.data.customerId!,
Expand Down

0 comments on commit 6768e02

Please sign in to comment.