Skip to content

Commit

Permalink
fix(stripe): 🐛 Subscription cancel webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jun 1, 2022
1 parent 87fe479 commit 3592321
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions apps/builder/pages/api/stripe/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => {
}
case 'customer.subscription.deleted': {
const subscription = event.data.object as Stripe.Subscription
const { metadata } = subscription
if (!metadata.workspaceId)
return res.status(500).send(`workspaceId not found`)
await prisma.workspace.update({
where: {
id: metadata.workspaceId,
stripeId: subscription.customer as string,
},
data: {
plan: Plan.FREE,
Expand Down

0 comments on commit 3592321

Please sign in to comment.