From cea30dc84cdfb6c570618e3e32fbd25b67c75284 Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 14 Feb 2026 21:36:55 +0000 Subject: [PATCH] Fix admin test checkout email validation - ensure valid email format is sent to Dodo Payments --- chat/server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chat/server.js b/chat/server.js index 0a2983b..9e157e3 100644 --- a/chat/server.js +++ b/chat/server.js @@ -13341,6 +13341,11 @@ async function handleAdminTopupCheckout(req, res) { const returnUrl = `${resolveBaseUrl(req)}/test-checkout`; const orderId = `admin_test_topup_${randomUUID()}`; + // Helper to validate email format + const isValidEmail = (email) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(email || '')); + const customerEmail = customer.email || ADMIN_USER || ''; + const validEmail = isValidEmail(customerEmail) ? customerEmail : 'admin@example.com'; + const checkoutBody = { product_cart: [{ product_id: pack.productId, @@ -13348,7 +13353,7 @@ async function handleAdminTopupCheckout(req, res) { amount: unitAmount, }], customer: { - email: (customer.email || ADMIN_USER || 'admin@example.com'), + email: validEmail, name: (customer.name || ADMIN_USER || 'Admin'), }, metadata: {