fix/standardized-phone-validation-and-billing #86

Merged
amit merged 7 commits from fix/standardized-phone-validation-and-billing into main 2026-11-12 04:38:27 +00:00
2 changed files with 11 additions and 6 deletions
Showing only changes of commit 79cb96ae5e - Show all commits

View File

@ -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 (+<dialCode><digits>)
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 || '',

View File

@ -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;
}