added user it for prod test - to remove later
This commit is contained in:
parent
52e219e258
commit
565378f845
@ -129,7 +129,12 @@ export function getCashierConfig(): ICashierConfig {
|
|||||||
|
|
||||||
const userId = params.get('userId');
|
const userId = params.get('userId');
|
||||||
if (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 customer: Partial<ICustomer> = postMessageCustomer ? { ...postMessageCustomer } : {};
|
||||||
|
|
||||||
const customerId = params.get('customer_id') || userId;
|
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)
|
// Parse additional customer fields from URL params (only if not already set from postMessage)
|
||||||
if (!customer.first_name) {
|
if (!customer.first_name) {
|
||||||
|
|||||||
@ -27,6 +27,7 @@ function Cashier() {
|
|||||||
const config = getCashierConfig();
|
const config = getCashierConfig();
|
||||||
|
|
||||||
if (!config.userId) {
|
if (!config.userId) {
|
||||||
|
console.error('User ID is required');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,13 +99,19 @@ function Cashier() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Merge customer data from formData with customer data in additionalFields
|
// Merge customer data from formData with customer data in additionalFields
|
||||||
const customerData = (formData.customer as IPaymentRequest['customer']) || {
|
const customerData: IPaymentRequest['customer'] = {
|
||||||
id: config.userId || '',
|
id: config.userId || '',
|
||||||
first_name: '',
|
first_name: '',
|
||||||
last_name: '',
|
last_name: '',
|
||||||
email: '',
|
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) {
|
if (additionalFields.customer) {
|
||||||
Object.assign(customerData, additionalFields.customer);
|
Object.assign(customerData, additionalFields.customer);
|
||||||
delete additionalFields.customer;
|
delete additionalFields.customer;
|
||||||
|
|||||||
@ -49,6 +49,17 @@ function PaymentForm({
|
|||||||
initial.customer = { ...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;
|
return initial;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user