Scheduling infrastructure for absolutely everyone.
chore: Discard unused Platform stripe events (#14822)
Erik00372b6b3bbb
diff --git a/apps/api/v2/src/modules/billing/controllers/billing.controller.ts b/apps/api/v2/src/modules/billing/controllers/billing.controller.tsindex 00bca4190ae..00319098f38 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",+ };}}