Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Stripe webhook event mismatch (#12522)

Erik5df41e37a0b5
diff --git a/.env.example b/.env.example
index 6d71f204ea0..64a1bfcf77e 100644
--- a/.env.example
+++ b/.env.example
@@ -155,6 +155,7 @@ NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE=
STRIPE_TEAM_MONTHLY_PRICE_ID=
STRIPE_ORG_MONTHLY_PRICE_ID=
STRIPE_WEBHOOK_SECRET=
+STRIPE_WEBHOOK_SECRET_APPS=
STRIPE_PRIVATE_KEY=
STRIPE_CLIENT_ID=
PAYMENT_FEE_FIXED=
diff --git a/apps/web/pages/api/integrations/subscriptions/webhook.ts b/apps/web/pages/api/integrations/subscriptions/webhook.ts
index 63f4cba4774..c1bb8b37905 100644
--- a/apps/web/pages/api/integrations/subscriptions/webhook.ts
+++ b/apps/web/pages/api/integrations/subscriptions/webhook.ts
@@ -83,13 +83,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
throw new HttpCode({ statusCode: 400, message: "Missing stripe-signature" });
}
- if (!process.env.STRIPE_WEBHOOK_SECRET) {
- throw new HttpCode({ statusCode: 500, message: "Missing process.env.STRIPE_WEBHOOK_SECRET" });
+ if (!process.env.STRIPE_WEBHOOK_SECRET_APPS) {
+ throw new HttpCode({ statusCode: 500, message: "Missing process.env.STRIPE_WEBHOOK_SECRET_APPS" });
}
const requestBuffer = await buffer(req);
const payload = requestBuffer.toString();
- const event = stripe.webhooks.constructEvent(payload, sig, process.env.STRIPE_WEBHOOK_SECRET);
+ const event = stripe.webhooks.constructEvent(payload, sig, process.env.STRIPE_WEBHOOK_SECRET_APPS);
const handler = webhookHandlers[event.type];
if (handler) {
diff --git a/packages/types/environment.d.ts b/packages/types/environment.d.ts
index 006be0478d8..caee8827917 100644
--- a/packages/types/environment.d.ts
+++ b/packages/types/environment.d.ts
@@ -27,6 +27,7 @@ declare namespace NodeJS {
readonly STRIPE_PRIVATE_KEY: string | undefined;
readonly STRIPE_CLIENT_ID: string | undefined;
readonly STRIPE_WEBHOOK_SECRET: string | undefined;
+ readonly STRIPE_WEBHOOK_SECRET_APPS: string | undefined;
readonly PAYMENT_FEE_PERCENTAGE: number | undefined;
readonly PAYMENT_FEE_FIXED: number | undefined;
readonly NEXT_PUBLIC_INTERCOM_APP_ID: string | undefined;
diff --git a/turbo.json b/turbo.json
index 0d7226a8ec0..4344ae0f256 100644
--- a/turbo.json
+++ b/turbo.json
@@ -312,6 +312,7 @@
"STRIPE_PRODUCT_ID_SCALE",
"STRIPE_PRODUCT_ID_STARTER",
"STRIPE_WEBHOOK_SECRET",
+ "STRIPE_WEBHOOK_SECRET_APPS",
"TANDEM_BASE_URL",
"TANDEM_CLIENT_ID",
"TANDEM_CLIENT_SECRET",