fix(store): enforce Indian mobile prefix and ensure exact razorpay contact prefill
This commit is contained in:
parent
a0c5a2d6fc
commit
79cb96ae5e
|
|
@ -889,11 +889,9 @@ export default function App() {
|
||||||
let isPaymentCancelled = false;
|
let isPaymentCancelled = false;
|
||||||
let isPaymentCompleted = false;
|
let isPaymentCompleted = false;
|
||||||
|
|
||||||
// Sanitize contact for Razorpay: strictly digits with leading + (no spaces/dashes)
|
// Sanitize contact for Razorpay: strictly E.164 (+<dialCode><digits>)
|
||||||
const rawContactDigits = (loggedInUser?.phone_number || '').replace(/\D/g, '');
|
const parsedContact = parsePhoneNumber(loggedInUser?.phone_number, loggedInUser?.country || 'India');
|
||||||
const sanitizedContact = (loggedInUser?.phone_number || '').startsWith('+')
|
const sanitizedContact = formatE164Phone(parsedContact.dialCode, parsedContact.localDigits);
|
||||||
? `+${rawContactDigits}`
|
|
||||||
: rawContactDigits;
|
|
||||||
|
|
||||||
const rzpOptions = {
|
const rzpOptions = {
|
||||||
key: razorpayKeyId,
|
key: razorpayKeyId,
|
||||||
|
|
@ -902,7 +900,6 @@ export default function App() {
|
||||||
name: 'Acupedia',
|
name: 'Acupedia',
|
||||||
description: cart.map(c => c.name).join(', '),
|
description: cart.map(c => c.name).join(', '),
|
||||||
order_id: razorpay_order_id,
|
order_id: razorpay_order_id,
|
||||||
customer_id: loggedInUser?.external_ref || undefined,
|
|
||||||
prefill: {
|
prefill: {
|
||||||
name: loggedInUser?.display_name || '',
|
name: loggedInUser?.display_name || '',
|
||||||
email: loggedInUser?.email || '',
|
email: loggedInUser?.email || '',
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,14 @@ export const validatePhoneNumber = (
|
||||||
return `${rule.country} phone number cannot exceed ${rule.maxLength} digits.`;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue