added user it for prod test - to remove later

This commit is contained in:
Mitchell Magro 2026-01-14 15:29:33 +01:00
parent 52e219e258
commit 565378f845
3 changed files with 31 additions and 3 deletions

View File

@ -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<ICustomer> = 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) {

View File

@ -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<IPaymentRequest['customer']>),
};
// 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;

View File

@ -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<string, unknown>;
if (!customer.id) {
customer.id = config.userId;
}
}
return initial;
});