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) <noreply@anthropic.com>
This commit is contained in:
parent
844cc7e11f
commit
6ed5105ae5
1 changed files with 16 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue