From 26051833cf76aa8e0c342b6696fdf26fa5d4ebb4 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Mon, 28 Apr 2025 18:36:14 +0530 Subject: [PATCH] fix: Skip already completed org onboarding, as webhook request can come when invoice is paid again next month (#20984) * there is nothing to do for repeat invoice payment * there is nothing to do for repeat invoice payment --- .../ee/billing/api/webhook/_invoice.paid.org.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/features/ee/billing/api/webhook/_invoice.paid.org.ts b/packages/features/ee/billing/api/webhook/_invoice.paid.org.ts index a79fa0b901..c40d2dbdb2 100644 --- a/packages/features/ee/billing/api/webhook/_invoice.paid.org.ts +++ b/packages/features/ee/billing/api/webhook/_invoice.paid.org.ts @@ -78,6 +78,16 @@ const handler = async (data: SWHMap["invoice.paid"]["data"]) => { stripeSubscriptionId: organizationOnboarding.stripeSubscriptionId, }) ); + + if (organizationOnboarding.isComplete) { + // If the organization is already complete, there is nothing to do + // Repeat requests can come for recurring payments + return { + success: true, + message: "Onboarding already completed, skipping", + }; + } + const { organization } = await createOrganizationFromOnboarding({ organizationOnboarding, paymentSubscriptionId,