Skip to content

Commit

Permalink
If we receive multiple time the webhook checkout.session.completed we…
Browse files Browse the repository at this point in the history
… don't recreate it (#2360)
  • Loading branch information
PopDaph authored Nov 3, 2023
1 parent cfae126 commit 74828a3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions front/pages/api/stripe/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ async function handler(
where: { workspaceId: workspace.id, status: "active" },
transaction: t,
});

if (
activeSubscription &&
activeSubscription.stripeSubscriptionId === stripeSubscriptionId
) {
// We already have a subscription for this workspace and this stripe subscription.
logger.info(
{
workspaceId,
stripeCustomerId,
stripeSubscriptionId,
planCode,
},
"[Stripe Webhook] Received checkout.session.completed when we already have a subscription for this workspace and this stripe subscription. Ignoring event"
);
return;
}

if (activeSubscription) {
await activeSubscription.update(
{
Expand Down

0 comments on commit 74828a3

Please sign in to comment.