diff --git a/src/App.tsx b/src/App.tsx index 6b50def..f8b6c95 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -889,11 +889,9 @@ export default function App() { let isPaymentCancelled = false; let isPaymentCompleted = false; - // Sanitize contact for Razorpay: strictly digits with leading + (no spaces/dashes) - const rawContactDigits = (loggedInUser?.phone_number || '').replace(/\D/g, ''); - const sanitizedContact = (loggedInUser?.phone_number || '').startsWith('+') - ? `+${rawContactDigits}` - : rawContactDigits; + // Sanitize contact for Razorpay: strictly E.164 (+) + const parsedContact = parsePhoneNumber(loggedInUser?.phone_number, loggedInUser?.country || 'India'); + const sanitizedContact = formatE164Phone(parsedContact.dialCode, parsedContact.localDigits); const rzpOptions = { key: razorpayKeyId, @@ -902,7 +900,6 @@ export default function App() { name: 'Acupedia', description: cart.map(c => c.name).join(', '), order_id: razorpay_order_id, - customer_id: loggedInUser?.external_ref || undefined, prefill: { name: loggedInUser?.display_name || '', email: loggedInUser?.email || '', diff --git a/src/utils/validation.ts b/src/utils/validation.ts index 8c97ac3..65af684 100644 --- a/src/utils/validation.ts +++ b/src/utils/validation.ts @@ -83,6 +83,14 @@ export const validatePhoneNumber = ( return `${rule.country} phone number cannot exceed ${rule.maxLength} digits.`; } } + + // Specific country telecom prefix rules + if (dialDigits === '91' || rule.country === 'India') { + if (!/^[6-9]/.test(localDigits)) { + return 'India mobile number must begin with 6, 7, 8, or 9.'; + } + } + return null; }