fix: Stop throwing 202 for stripe handler (#20397)

* dont throw - log error

* invoice paid

* update to warn

* Update packages/features/ee/billing/api/webhook/_invoice.paid.ts

---------

Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
sean-brydonandKeith Williams authored and GitHub committed 2025-03-27 15:06:15 +00:00
1 parent 2aa583bb6d
commit da47168941
4 files changed
+41 -16

No files matched your search

@@ -54,10 +54,22 @@ export const stripeWebhookHandler = (handlers: SWHandlers) => async (req: NextAp
STRIPE_WEBHOOK_SECRET
) as Stripe.DiscriminatedEvent;
const handlerGetter = handlers[event.type];
if (!handlerGetter) throw new HttpCode(202, `Unhandled Stripe Webhook event type ${event.type}`);
if (!handlerGetter) {
console.log("Unhandled Stripe Webhook event type", event.type);
return {
success: false,
message: `Unhandled Stripe Webhook event type ${event.type}`,
};
}
const handler = (await handlerGetter())?.default;
// auto catch unsupported Stripe events.
if (!handler) throw new HttpCode(202, `Unhandled Stripe Webhook event type ${event.type}`);
if (!handler) {
console.log("Unhandled Stripe Webhook event type", event.type);
return {
success: false,
message: `Unhandled Stripe Webhook event type ${event.type}`,
};
}
// @ts-expect-error - we know the handler is defined and accepts the data type
return await handler(event.data);
};