The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update comments + var name
Steven Tey897844c1a4f9
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/route.tsindex 2890642231..0d094e8aec 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts@@ -20,12 +20,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 pathname = new URL(req.url).pathname;- const testmode = pathname.endsWith("/test");+ const testConnectWebhook = pathname.endsWith("/test");const buf = await req.text();const sig = req.headers.get("Stripe-Signature");- const webhookSecret = testmode+ // @see https://github.com/dubinc/dub/blob/main/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.ts+ const webhookSecret = testConnectWebhook? 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.tsindex 821c0f2f53..7391eceb13 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.ts@@ -1,9 +1,14 @@/*+ POST /api/stripe/integration/webhook/test – listen to Stripe test mode connect webhooks (for Stripe Integration)- 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.+ We need a separate route for test webhooks because of how Stripe webhooks behave:+ - Live mode only: When a connected account is connected only in live mode to your platform,+ the live Events and test Events are sent to your live Connect webhook endpoint.+ - Test mode only: When a connected account is connected only in test mode to your platform,+ the test Events are sent to your test Connect webhook endpoint. Live Events are never sent.+ - Live mode and test mode: When a connected account is connected in live and in test mode to your platform,+ the live Events are sent to your 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*/diff --git a/apps/web/lib/middleware/utils/get-final-url.ts b/apps/web/lib/middleware/utils/get-final-url.tsindex 901882ef09..be770ad1e0 100644--- a/apps/web/lib/middleware/utils/get-final-url.ts+++ b/apps/web/lib/middleware/utils/get-final-url.ts@@ -27,7 +27,7 @@ export const getFinalUrl = (- if there is a clickId and dub_client_reference_id is 1- then set client_reference_id to dub_id_${clickId} and drop the dub_client_reference_id param- our Stripe integration will then detect `dub_id_${clickId}` as the dubClickId in the `checkout.session.completed` webhook- - @see: https://github.com/dubinc/dub/blob/main/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts+ - @see: https://github.com/dubinc/dub/blob/main/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts*/if (urlObj.searchParams.get("dub_client_reference_id") === "1") {urlObj.searchParams.set("client_reference_id", `dub_id_${clickId}`);