Trying to solve cust id issue
This commit is contained in:
parent
841900e781
commit
9d6e3e0d5b
@ -17,8 +17,12 @@ if (typeof window !== 'undefined' && window.parent !== window) {
|
|||||||
if (key === 'customer' && typeof value === 'object' && value !== null) {
|
if (key === 'customer' && typeof value === 'object' && value !== null) {
|
||||||
// Handle customer object separately
|
// Handle customer object separately
|
||||||
postMessageCustomer = value as Partial<ICustomer>;
|
postMessageCustomer = value as Partial<ICustomer>;
|
||||||
|
// Trim customer.id if it exists
|
||||||
|
if (postMessageCustomer.id && typeof postMessageCustomer.id === 'string') {
|
||||||
|
postMessageCustomer.id = postMessageCustomer.id.trim();
|
||||||
|
}
|
||||||
} else if (key !== 'type' && typeof value === 'string') {
|
} else if (key !== 'type' && typeof value === 'string') {
|
||||||
postMessageParams[key] = value;
|
postMessageParams[key] = value.trim();
|
||||||
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
||||||
postMessageParams[key] = String(value);
|
postMessageParams[key] = String(value);
|
||||||
}
|
}
|
||||||
@ -127,7 +131,7 @@ export function getCashierConfig(): ICashierConfig {
|
|||||||
config.merchantId = merchantId;
|
config.merchantId = merchantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userId = params.get('userId');
|
const userId = params.get('userId')?.trim();
|
||||||
if (userId) {
|
if (userId) {
|
||||||
config.userId = userId;
|
config.userId = userId;
|
||||||
} else if (import.meta.env.DEV) {
|
} else if (import.meta.env.DEV) {
|
||||||
@ -151,7 +155,7 @@ export function getCashierConfig(): ICashierConfig {
|
|||||||
// Start with postMessage customer if available, otherwise create new object
|
// Start with postMessage customer if available, otherwise create new object
|
||||||
const customer: Partial<ICustomer> = postMessageCustomer ? { ...postMessageCustomer } : {};
|
const customer: Partial<ICustomer> = postMessageCustomer ? { ...postMessageCustomer } : {};
|
||||||
|
|
||||||
const customerId = params.get('customer_id') || userId;
|
const customerId = params.get('customer_id')?.trim() || userId;
|
||||||
if (customerId) {
|
if (customerId) {
|
||||||
customer.id = customerId;
|
customer.id = customerId;
|
||||||
} else if (userId && !customer.id) {
|
} else if (userId && !customer.id) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user