From 36eb04dab548444535b2081213aee23b8d7cd220 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 12 Jul 2025 20:20:00 -0700 Subject: [PATCH] fix(stripe): added missing webhook secret for stripe webhook billing endpoint --- apps/sim/app/api/billing/webhooks/stripe/route.ts | 4 ++-- apps/sim/lib/env.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/sim/app/api/billing/webhooks/stripe/route.ts b/apps/sim/app/api/billing/webhooks/stripe/route.ts index 8d150286d4..d6b03f32d3 100644 --- a/apps/sim/app/api/billing/webhooks/stripe/route.ts +++ b/apps/sim/app/api/billing/webhooks/stripe/route.ts @@ -24,7 +24,7 @@ export async function POST(request: NextRequest) { return NextResponse.json({ error: 'Missing Stripe signature' }, { status: 400 }) } - if (!env.STRIPE_WEBHOOK_SECRET) { + if (!env.STRIPE_BILLING_WEBHOOK_SECRET) { logger.error('Missing Stripe webhook secret configuration') return NextResponse.json({ error: 'Webhook secret not configured' }, { status: 500 }) } @@ -43,7 +43,7 @@ export async function POST(request: NextRequest) { // Verify webhook signature let event: Stripe.Event try { - event = stripe.webhooks.constructEvent(body, signature, env.STRIPE_WEBHOOK_SECRET) + event = stripe.webhooks.constructEvent(body, signature, env.STRIPE_BILLING_WEBHOOK_SECRET) } catch (signatureError) { logger.error('Invalid Stripe webhook signature', { error: signatureError, diff --git a/apps/sim/lib/env.ts b/apps/sim/lib/env.ts index 7cf7257e9a..07e6b20805 100644 --- a/apps/sim/lib/env.ts +++ b/apps/sim/lib/env.ts @@ -17,6 +17,7 @@ export const env = createEnv({ POSTGRES_URL: z.string().url().optional(), STRIPE_SECRET_KEY: z.string().min(1).optional(), + STRIPE_BILLING_WEBHOOK_SECRET: z.string().min(1).optional(), STRIPE_WEBHOOK_SECRET: z.string().min(1).optional(), STRIPE_FREE_PRICE_ID: z.string().min(1).optional(), FREE_TIER_COST_LIMIT: z.number().optional(),