Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Skip already completed org onboarding, as webhook request can come when invoice is paid again next month (#20984)

Hariom Balhara26051833cf76
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 a79fa0b9014..c40d2dbdb2d 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,