Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
csuermann committed Sep 30, 2023
1 parent e3906fe commit 5b6b0fd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export async function handleCheckoutSessionCompleted({
}

export async function handleCustomerSubscriptionDeleted({ metadata }) {
if (!hasActiveSubscription(metadata.userId as string)) {
const hasSubscription = await hasActiveSubscription(metadata.userId as string)

if (!hasSubscription) {
await switchToPlan(metadata.userId, PlanName.FREE)
}
}
Expand All @@ -77,7 +79,9 @@ export async function handleInvoicePaymentFailed({
return
}

if (!hasActiveSubscription(customerId as string)) {
const hasSubscription = await hasActiveSubscription(customerId as string)

if (!hasSubscription) {
await switchToPlan(metadata.userId, PlanName.FREE)
}
}
Expand Down

0 comments on commit 5b6b0fd

Please sign in to comment.