The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Stripe integration test webhook
Steven Tey35432a206d27
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/route.tsindex 3647f1f6da..2890642231 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts@@ -19,11 +19,13 @@ const relevantEvents = new Set([// POST /api/stripe/integration/webhook – listen to Stripe webhooks (for Stripe Integration)export const POST = withAxiom(async (req: Request) => {- const buf = await req.text();- const { livemode } = JSON.parse(buf);+ const pathname = new URL(req.url).pathname;+ const testmode = pathname.endsWith("/test");+ const buf = await req.text();const sig = req.headers.get("Stripe-Signature");- const webhookSecret = !livemode++ const webhookSecret = testmode? process.env.STRIPE_APP_WEBHOOK_SECRET_TEST: process.env.STRIPE_APP_WEBHOOK_SECRET;diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.tsnew file mode 100644index 0000000000..821c0f2f53--- /dev/null+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.ts@@ -0,0 +1,11 @@+/*++ POST /api/stripe/integration/webhook/test – listen to Stripe test webhooks (for Stripe Integration)+ We need a separate route for test webhooks because when a connected account is connected in live and in test mode,+ the live Events are sent to our live Connect webhook endpoint+ and the test Events are sent to both the live and the test Connect webhook endpoints.++ @see https://support.stripe.com/questions/connect-account-webhook-configurations+*/++export { POST } from "../route";