Skip to content

Commit b208039

Browse files
committed
fix(appmax): Fix handling/debugging customer and order creation on Appmax API
1 parent a339bb6 commit b208039

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/apps/appmax/lib-mjs/lib/appmax/create-order.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { logger } from '@cloudcommerce/firebase/lib/config';
12
import axios from 'axios';
23

34
export const createOrder = async (items, amount, appmaxCustomerId, token) => {
@@ -29,9 +30,11 @@ export const createOrder = async (items, amount, appmaxCustomerId, token) => {
2930
headers: { 'User-Agent': 'SEC07-Lintfr-VA3' },
3031
data: body,
3132
});
32-
if (data && data.status === 200) {
33-
return data.data && data.data.id;
33+
if (data?.status === 200) {
34+
const orderId = data.order_id || data.data?.order_id || data.data?.id;
35+
return orderId;
3436
}
37+
logger.warn('Unexpected response from Appmax create order', { body, data });
3538
return null;
3639
};
3740

packages/apps/appmax/lib-mjs/lib/appmax/get-customer.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { logger } from '@cloudcommerce/firebase/lib/config';
12
import axios from 'axios';
23

34
export const createOrUpdateCustomer = async (
@@ -49,9 +50,11 @@ export const createOrUpdateCustomer = async (
4950
headers: { 'User-Agent': 'SEC07-Lintfr-VA3' },
5051
data: body,
5152
});
52-
if (data && data.status === 200) {
53-
return data.data && data.data.id;
53+
if (data?.status === 200) {
54+
const customerId = data.customer_id || data.data?.customer_id || data.data?.id;
55+
if (customerId) return customerId;
5456
}
57+
logger.warn('Unexpected response from Appmax create customer', { body, data });
5558
return null;
5659
};
5760

0 commit comments

Comments
 (0)