diff --git a/front/pages/api/stripe/webhook.ts b/front/pages/api/stripe/webhook.ts index 1aa0c8e5ec7e..cfac3bf7f218 100644 --- a/front/pages/api/stripe/webhook.ts +++ b/front/pages/api/stripe/webhook.ts @@ -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( {