diff --git a/apps/api/v2/src/modules/billing/controllers/billing.controller.ts b/apps/api/v2/src/modules/billing/controllers/billing.controller.ts index 00bca4190ae180..00319098f3845a 100644 --- a/apps/api/v2/src/modules/billing/controllers/billing.controller.ts +++ b/apps/api/v2/src/modules/billing/controllers/billing.controller.ts @@ -104,10 +104,19 @@ export class BillingController { if (event.type === "customer.subscription.created" || event.type === "customer.subscription.updated") { const subscription = event.data.object as Stripe.Subscription; + if (!subscription.metadata?.teamId) { + return { + status: "success", + }; + } + const teamId = Number.parseInt(subscription.metadata.teamId); const plan = subscription.metadata.plan; if (!plan || !teamId) { - throw new Error("Invalid webhook received."); + this.logger.log("Webhook received but not pertaining to Platform, discarding."); + return { + status: "success", + }; } await this.billingService.setSubscriptionForTeam( @@ -121,6 +130,8 @@ export class BillingController { }; } - throw new BadRequestException(`Unhandled event type ${event.type}`); + return { + status: "success", + }; } }