From 565378f8454e01f4c80212af9d83c1306efefe84 Mon Sep 17 00:00:00 2001 From: Mitchell Magro Date: Wed, 14 Jan 2026 15:29:33 +0100 Subject: [PATCH] added user it for prod test - to remove later --- src/config/cashierConfig.ts | 14 ++++++++++++-- src/features/cashier/Cashier.tsx | 9 ++++++++- src/features/cashier/PaymentForm/PaymentForm.tsx | 11 +++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/config/cashierConfig.ts b/src/config/cashierConfig.ts index c695b75..d07c339 100644 --- a/src/config/cashierConfig.ts +++ b/src/config/cashierConfig.ts @@ -129,7 +129,12 @@ export function getCashierConfig(): ICashierConfig { const userId = params.get('userId'); if (userId) { - config.userId = userId; + // Use userId from URL remove for production + config.userId = '12345'; + } else if (import.meta.env.DEV) { + // Development fallback: use a default numeric userId for testing + // The API expects customer ID to be a numeric value + config.userId = '123'; } @@ -148,7 +153,12 @@ export function getCashierConfig(): ICashierConfig { const customer: Partial = postMessageCustomer ? { ...postMessageCustomer } : {}; const customerId = params.get('customer_id') || userId; - if (customerId) customer.id = customerId; + if (customerId) { + customer.id = customerId; + } else if (userId && !customer.id) { + // Ensure userId is set on customer if available + customer.id = userId; + } // Parse additional customer fields from URL params (only if not already set from postMessage) if (!customer.first_name) { diff --git a/src/features/cashier/Cashier.tsx b/src/features/cashier/Cashier.tsx index 31356ec..c34e7aa 100644 --- a/src/features/cashier/Cashier.tsx +++ b/src/features/cashier/Cashier.tsx @@ -27,6 +27,7 @@ function Cashier() { const config = getCashierConfig(); if (!config.userId) { + console.error('User ID is required'); return; } @@ -98,13 +99,19 @@ function Cashier() { }); // Merge customer data from formData with customer data in additionalFields - const customerData = (formData.customer as IPaymentRequest['customer']) || { + const customerData: IPaymentRequest['customer'] = { id: config.userId || '', first_name: '', last_name: '', email: '', + ...(formData.customer as Partial), }; + // Always ensure customer.id is set from config.userId if available + if (config.userId) { + customerData.id = config.userId; + } + if (additionalFields.customer) { Object.assign(customerData, additionalFields.customer); delete additionalFields.customer; diff --git a/src/features/cashier/PaymentForm/PaymentForm.tsx b/src/features/cashier/PaymentForm/PaymentForm.tsx index c4afa14..57c474d 100644 --- a/src/features/cashier/PaymentForm/PaymentForm.tsx +++ b/src/features/cashier/PaymentForm/PaymentForm.tsx @@ -48,6 +48,17 @@ function PaymentForm({ if (config.customer) { initial.customer = { ...config.customer }; } + + // Ensure customer.id is set from config.userId if available + if (config.userId) { + if (!initial.customer) { + initial.customer = {}; + } + const customer = initial.customer as Record; + if (!customer.id) { + customer.id = config.userId; + } + } return initial; });