Skip to content

Scheduling infrastructure for absolutely everyone.

no throw 202 (#20339)

sean-brydone4cfaa56f07c
diff --git a/packages/features/ee/billing/api/webhook/_invoice.paid.ts b/packages/features/ee/billing/api/webhook/_invoice.paid.ts
index 123fecf7779..6d524fb2963 100644
--- a/packages/features/ee/billing/api/webhook/_invoice.paid.ts
+++ b/packages/features/ee/billing/api/webhook/_invoice.paid.ts
@@ -1,6 +1,5 @@
import logger from "@calcom/lib/logger";
-import { HttpCode } from "./__handler";
import type { LazyModule, SWHMap } from "./__handler";
type Data = SWHMap["invoice.paid"]["data"];
@@ -30,10 +29,20 @@ const stripeWebhookProductHandler = (handlers: Handlers) => async (data: Data) =
}
const handlerGetter = handlers[productId as keyof typeof handlers];
- if (!handlerGetter) throw new HttpCode(202, `No product handler found for product: ${productId}`);
+
+ /**
+ * If no handler is found, we skip the product. A handler could be null if we don't need webhooks to handle the business logic for the product.
+ */
+ if (!handlerGetter) {
+ log.error(`Skipping product: ${productId} because no handler found`);
+ return { success: true };
+ }
const handler = (await handlerGetter())?.default;
// auto catch unsupported Stripe products.
- if (!handler) throw new HttpCode(202, `No product handler found for product: ${productId}`);
+ if (!handler) {
+ log.error(`Skipping product: ${productId} because no handler found`);
+ return { success: true };
+ }
return await handler(data);
};