diff --git a/api/src/routes/checkout.ts b/api/src/routes/checkout.ts index 401816e..6b3a31e 100644 --- a/api/src/routes/checkout.ts +++ b/api/src/routes/checkout.ts @@ -1752,6 +1752,9 @@ async function sendComplianceIntakeEmail( ((o.service_name as string) || "").toLowerCase().includes("499"), ); + const SITE_DOMAIN = process.env.DOMAIN ? `https://${process.env.DOMAIN}` : "https://performancewest.net"; + const confirmUrl = `${SITE_DOMAIN}/order/success?action=usac_delegation&order_id=${orderId}`; + const usacSection = has499 ? `
Action Required: USAC E-File Delegation
@@ -1764,9 +1767,16 @@ async function sendComplianceIntakeEmail(+
+ + I've completed the delegation → + +
++ Clicking this button notifies our team that delegation is complete so we can begin your filing. +
+If you have multiple years of missed filings, each year must be filed separately. We will review your history and contact you with pricing for any additional years.
@@ -1812,10 +1822,10 @@ async function sendComplianceIntakeEmail(1. We will review your compliance status within 1 business day.
2. If we need any additional information, we will email you.
3. You will receive a confirmation for each filing as it is completed.
- ${has499 ? `4. For 499-A filings, please complete the USAC delegation above so we can begin.
` : ""} + ${has499 ? `4. For 499-A filings, complete the USAC delegation above and click the confirmation button.
` : ""}- Questions? Reply to this email or contact us at + Questions? Contact us at info@performancewest.net or 1-888-411-0383.
diff --git a/api/src/routes/compliance-orders.ts b/api/src/routes/compliance-orders.ts index 80f0722..e2b7431 100644 --- a/api/src/routes/compliance-orders.ts +++ b/api/src/routes/compliance-orders.ts @@ -1453,5 +1453,48 @@ router.post( }, ); +/** + * POST /api/v1/compliance-orders/:id/usac-delegation + * Customer confirms they've completed USAC E-File delegation. + * Updates order status and notifies the team to begin filing. + */ +router.post("/api/v1/compliance-orders/:id/usac-delegation", async (req, res) => { + const id = req.params.id; + + try { + // Support both batch ID (CB-) and order number (CO-) + const whereCol = id.startsWith("CB-") ? "batch_id" : "order_number"; + const result = await pool.query( + `UPDATE compliance_orders + SET intake_data = jsonb_set( + COALESCE(intake_data, '{}'::jsonb), + '{usac_delegation_confirmed}', + to_jsonb(now()::text) + ), + updated_at = NOW() + WHERE ${whereCol} = $1 + AND service_slug IN ('fcc-499a', 'fcc-499a-499q') + RETURNING order_number, service_slug, customer_email`, + [id], + ); + + if (result.rows.length === 0) { + res.status(404).json({ error: "No 499-A order found for this ID." }); + return; + } + + console.log(`[compliance-orders] USAC delegation confirmed for ${id} (${result.rows.length} orders)`); + + res.json({ + success: true, + message: "Thank you! We've been notified that delegation is complete and will begin your filing within 1 business day.", + orders_updated: result.rows.length, + }); + } catch (err) { + console.error("[compliance-orders] USAC delegation error:", err); + res.status(500).json({ error: "Could not record delegation confirmation." }); + } +}); + export { COMPLIANCE_SERVICES, REQUIRED_FIELDS }; export default router;