From 9d6e3e0d5bcae83619c8341269bc9d4517b01fff Mon Sep 17 00:00:00 2001 From: Mitchell Magro Date: Wed, 14 Jan 2026 15:45:55 +0100 Subject: [PATCH] Trying to solve cust id issue --- src/config/cashierConfig.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/config/cashierConfig.ts b/src/config/cashierConfig.ts index 700b620..2a00367 100644 --- a/src/config/cashierConfig.ts +++ b/src/config/cashierConfig.ts @@ -17,8 +17,12 @@ if (typeof window !== 'undefined' && window.parent !== window) { if (key === 'customer' && typeof value === 'object' && value !== null) { // Handle customer object separately postMessageCustomer = value as Partial; + // 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') { - postMessageParams[key] = value; + postMessageParams[key] = value.trim(); } else if (typeof value === 'number' || typeof value === 'boolean') { postMessageParams[key] = String(value); } @@ -127,7 +131,7 @@ export function getCashierConfig(): ICashierConfig { config.merchantId = merchantId; } - const userId = params.get('userId'); + const userId = params.get('userId')?.trim(); if (userId) { config.userId = userId; } else if (import.meta.env.DEV) { @@ -151,7 +155,7 @@ export function getCashierConfig(): ICashierConfig { // Start with postMessage customer if available, otherwise create new object const customer: Partial = postMessageCustomer ? { ...postMessageCustomer } : {}; - const customerId = params.get('customer_id') || userId; + const customerId = params.get('customer_id')?.trim() || userId; if (customerId) { customer.id = customerId; } else if (userId && !customer.id) {