From 86205c309cc64a74db65aa95915b8033546cc3ad Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 27 Apr 2026 21:20:22 -0500 Subject: [PATCH] Replace USAC email instructions with confirmation button + add API endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Intake email now has "I've completed the delegation →" button instead of "reply to this email" - Button links to order success page with action=usac_delegation - New API: POST /api/v1/compliance-orders/:id/usac-delegation Records confirmation timestamp in intake_data and logs it - Removed "reply to this email" from intake email Co-Authored-By: Claude Opus 4.6 (1M context) --- api/src/routes/checkout.ts | 18 +++++++++--- api/src/routes/compliance-orders.ts | 43 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) 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(
  • Go to Account Settings → Delegate Access
  • Add delegate email: filings@performancewest.net
  • Grant read and file permissions
  • -
  • Reply to this email to confirm delegation is complete
  • -

    +

    + + 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;