From 6ed5105ae5968250c2e09c524c7c94d1bea11929 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 22 May 2026 01:18:19 -0500 Subject: [PATCH] Send intake email for $0 free orders Free orders bypass Stripe, so the Stripe webhook never fires and the intake/confirmation email never gets sent. Now trigger sendComplianceIntakeEmail directly in the $0 bypass flow. Co-Authored-By: Claude Opus 4.6 (1M context) --- api/src/routes/checkout.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/src/routes/checkout.ts b/api/src/routes/checkout.ts index c36617e..ce3ed0a 100644 --- a/api/src/routes/checkout.ts +++ b/api/src/routes/checkout.ts @@ -929,6 +929,22 @@ router.post("/api/v1/checkout/create-session", async (req, res) => { ); } console.log(`[checkout] $0 order — skipping payment for ${order_type} ${order_id} (discount ${discount_cents} >= base ${base_cents})`); + + // Send intake/confirmation email for free compliance orders (normally triggered by Stripe webhook) + if (order_type === "compliance_batch" || order_type === "compliance") { + try { + const { rows: updatedOrders } = await pool.query( + `SELECT * FROM compliance_orders WHERE ${order_type === "compliance_batch" ? "batch_id" : "order_number"} = $1`, + [order_id], + ); + if (updatedOrders.length > 0) { + await sendComplianceIntakeEmail(order_id, order_type, updatedOrders); + } + } catch (emailErr) { + console.error("[checkout] Free order intake email failed (non-fatal):", emailErr); + } + } + res.json({ checkout_url: `${DOMAIN}/order/success?order_id=${order_id}&order_type=${order_type}&free=1`, session_id: null,