From 9579d74d7d3d4310da0d49dec2c72449352a95f9 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 29 May 2026 15:51:34 -0500 Subject: [PATCH] Fix Telegram notification: show actual paid amount after discount Was showing service_fee_cents ($69) instead of actual charge ($35.54). Now subtracts discount_cents and adds surcharge_cents. Also shows discount line in notification when a promo code was used. Co-Authored-By: Claude Opus 4.6 (1M context) --- api/src/routes/checkout.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/src/routes/checkout.ts b/api/src/routes/checkout.ts index 05107b4..c64eee6 100644 --- a/api/src/routes/checkout.ts +++ b/api/src/routes/checkout.ts @@ -1268,20 +1268,26 @@ export async function handlePaymentComplete( const serviceName = (order.service_slug as string) || (order.service_name as string) || order_type; - // Calculate total in dollars + // Calculate total in dollars (after discount + surcharge) const feeCents = Number(order.service_fee_cents || order.total_cents || 0); + const discountCents = Number(order.discount_cents || 0); + const surchargeCents = Number(order.surcharge_cents || 0); const formationCents = Number(order.formation_fee_cents || 0); const stateCents = Number(order.state_fee_cents || 0); const addonCents = Number(order.addon_fee_cents || 0); const pucCents = Number(order.puc_fee_cents || 0); - const totalCents = feeCents + formationCents + stateCents + addonCents + pucCents; + const totalCents = feeCents - discountCents + surchargeCents + formationCents + stateCents + addonCents + pucCents; const totalDollars = (totalCents / 100).toFixed(2); + const discountLine = discountCents > 0 + ? `Discount: -$${(discountCents / 100).toFixed(2)} (${order.discount_code || "promo"})\n` + : ""; const msg = `💰 NEW ORDER\n\n` + `Customer: ${customerName}\n` + `Email: ${customerEmail}\n` + `Service: ${serviceName}\n` + `Total: $${totalDollars}\n` + + discountLine + `Payment: ${paymentMethod}\n` + `Order: ${order_id}\n` + `Type: ${order_type}`;