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: {