From e4cfaa56f07c9a13bb0c8e2fb534b425f29f1ea5 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:48:38 +0000 Subject: [PATCH] no throw 202 (#20339) --- .../ee/billing/api/webhook/_invoice.paid.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/features/ee/billing/api/webhook/_invoice.paid.ts b/packages/features/ee/billing/api/webhook/_invoice.paid.ts index 123fecf777..6d524fb296 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); };