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,