@final-commerce/command-frame 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -7
- package/dist/CommonTypes.d.ts +469 -0
- package/dist/CommonTypes.js +21 -0
- package/dist/actions/add-cart-discount/mock.d.ts +2 -0
- package/dist/actions/add-cart-discount/mock.js +27 -0
- package/dist/actions/add-cart-fee/mock.d.ts +2 -0
- package/dist/actions/add-cart-fee/mock.js +31 -0
- package/dist/actions/add-custom-sale/mock.d.ts +2 -0
- package/dist/actions/add-custom-sale/mock.js +12 -0
- package/dist/actions/add-customer/mock.d.ts +2 -0
- package/dist/actions/add-customer/mock.js +23 -0
- package/dist/actions/add-customer/types.d.ts +3 -2
- package/dist/actions/add-customer-note/mock.d.ts +2 -0
- package/dist/actions/add-customer-note/mock.js +9 -0
- package/dist/actions/add-order-note/mock.d.ts +2 -0
- package/dist/actions/add-order-note/mock.js +8 -0
- package/dist/actions/add-product-discount/mock.d.ts +2 -0
- package/dist/actions/add-product-discount/mock.js +10 -0
- package/dist/actions/add-product-fee/mock.d.ts +2 -0
- package/dist/actions/add-product-fee/mock.js +11 -0
- package/dist/actions/add-product-note/mock.d.ts +2 -0
- package/dist/actions/add-product-note/mock.js +8 -0
- package/dist/actions/add-product-to-cart/mock.d.ts +2 -0
- package/dist/actions/add-product-to-cart/mock.js +56 -0
- package/dist/actions/add-product-to-cart/types.d.ts +2 -0
- package/dist/actions/adjust-inventory/mock.d.ts +2 -0
- package/dist/actions/adjust-inventory/mock.js +18 -0
- package/dist/actions/assign-customer/mock.d.ts +2 -0
- package/dist/actions/assign-customer/mock.js +14 -0
- package/dist/actions/assign-customer/types.d.ts +2 -1
- package/dist/actions/authenticate-user/mock.d.ts +2 -0
- package/dist/actions/authenticate-user/mock.js +8 -0
- package/dist/actions/calculate-refund-total/mock.d.ts +2 -0
- package/dist/actions/calculate-refund-total/mock.js +14 -0
- package/dist/actions/calculate-refund-total/types.d.ts +3 -2
- package/dist/actions/cash-payment/mock.d.ts +2 -0
- package/dist/actions/cash-payment/mock.js +14 -0
- package/dist/actions/cash-payment/types.d.ts +2 -1
- package/dist/actions/clear-cart/mock.d.ts +2 -0
- package/dist/actions/clear-cart/mock.js +9 -0
- package/dist/actions/delete-parked-order/mock.d.ts +2 -0
- package/dist/actions/delete-parked-order/mock.js +8 -0
- package/dist/actions/example-function/mock.d.ts +2 -0
- package/dist/actions/example-function/mock.js +13 -0
- package/dist/actions/get-categories/mock.d.ts +2 -0
- package/dist/actions/get-categories/mock.js +20 -0
- package/dist/actions/get-categories/types.d.ts +2 -1
- package/dist/actions/get-context/mock.d.ts +2 -0
- package/dist/actions/get-context/mock.js +24 -0
- package/dist/actions/get-context/types.d.ts +2 -20
- package/dist/actions/get-current-cart/mock.d.ts +2 -0
- package/dist/actions/get-current-cart/mock.js +9 -0
- package/dist/actions/get-current-cart/types.d.ts +2 -1
- package/dist/actions/get-customers/mock.d.ts +2 -0
- package/dist/actions/get-customers/mock.js +17 -0
- package/dist/actions/get-customers/types.d.ts +2 -1
- package/dist/actions/get-final-context/action.d.ts +6 -0
- package/dist/actions/get-final-context/action.js +8 -0
- package/dist/actions/get-final-context/types.d.ts +4 -0
- package/dist/actions/get-final-context/types.js +1 -0
- package/dist/actions/get-line-items-by-order/mock.d.ts +2 -0
- package/dist/actions/get-line-items-by-order/mock.js +12 -0
- package/dist/actions/get-line-items-by-order/types.d.ts +3 -2
- package/dist/actions/get-orders/mock.d.ts +2 -0
- package/dist/actions/get-orders/mock.js +104 -0
- package/dist/actions/get-orders/types.d.ts +2 -1
- package/dist/actions/get-product-variants/mock.d.ts +2 -0
- package/dist/actions/get-product-variants/mock.js +14 -0
- package/dist/actions/get-product-variants/types.d.ts +2 -1
- package/dist/actions/get-products/mock.d.ts +2 -0
- package/dist/actions/get-products/mock.js +31 -0
- package/dist/actions/get-products/types.d.ts +2 -1
- package/dist/actions/get-refunds/mock.d.ts +2 -0
- package/dist/actions/get-refunds/mock.js +9 -0
- package/dist/actions/get-refunds/types.d.ts +2 -1
- package/dist/actions/get-remaining-refundable-quantities/mock.d.ts +2 -0
- package/dist/actions/get-remaining-refundable-quantities/mock.js +9 -0
- package/dist/actions/go-to-page/mock.d.ts +2 -0
- package/dist/actions/go-to-page/mock.js +8 -0
- package/dist/actions/go-to-station-home/mock.d.ts +2 -0
- package/dist/actions/go-to-station-home/mock.js +7 -0
- package/dist/actions/initiate-refund/mock.d.ts +2 -0
- package/dist/actions/initiate-refund/mock.js +8 -0
- package/dist/actions/open-cash-drawer/mock.d.ts +2 -0
- package/dist/actions/open-cash-drawer/mock.js +7 -0
- package/dist/actions/open-popup/mock.d.ts +2 -0
- package/dist/actions/open-popup/mock.js +8 -0
- package/dist/actions/park-order/mock.d.ts +2 -0
- package/dist/actions/park-order/mock.js +9 -0
- package/dist/actions/park-order/types.d.ts +2 -1
- package/dist/actions/partial-payment/mock.d.ts +2 -0
- package/dist/actions/partial-payment/mock.js +12 -0
- package/dist/actions/partial-payment/types.d.ts +2 -1
- package/dist/actions/process-partial-refund/mock.d.ts +2 -0
- package/dist/actions/process-partial-refund/mock.js +8 -0
- package/dist/actions/remove-customer-from-cart/mock.d.ts +2 -0
- package/dist/actions/remove-customer-from-cart/mock.js +9 -0
- package/dist/actions/reset-refund-details/mock.d.ts +2 -0
- package/dist/actions/reset-refund-details/mock.js +7 -0
- package/dist/actions/resume-parked-order/mock.d.ts +2 -0
- package/dist/actions/resume-parked-order/mock.js +9 -0
- package/dist/actions/resume-parked-order/types.d.ts +2 -1
- package/dist/actions/select-all-refund-items/mock.d.ts +2 -0
- package/dist/actions/select-all-refund-items/mock.js +8 -0
- package/dist/actions/set-product-active/mock.d.ts +2 -0
- package/dist/actions/set-product-active/mock.js +8 -0
- package/dist/actions/set-refund-stock-action/mock.d.ts +2 -0
- package/dist/actions/set-refund-stock-action/mock.js +9 -0
- package/dist/actions/show-confirmation/mock.d.ts +2 -0
- package/dist/actions/show-confirmation/mock.js +9 -0
- package/dist/actions/show-notification/mock.d.ts +2 -0
- package/dist/actions/show-notification/mock.js +8 -0
- package/dist/actions/switch-user/mock.d.ts +2 -0
- package/dist/actions/switch-user/mock.js +10 -0
- package/dist/actions/tap-to-pay-payment/mock.d.ts +2 -0
- package/dist/actions/tap-to-pay-payment/mock.js +11 -0
- package/dist/actions/tap-to-pay-payment/types.d.ts +2 -1
- package/dist/actions/terminal-payment/mock.d.ts +2 -0
- package/dist/actions/terminal-payment/mock.js +14 -0
- package/dist/actions/terminal-payment/types.d.ts +2 -1
- package/dist/actions/toggle-slide-out/mock.d.ts +2 -0
- package/dist/actions/toggle-slide-out/mock.js +8 -0
- package/dist/actions/trigger-webhook/mock.d.ts +2 -0
- package/dist/actions/trigger-webhook/mock.js +8 -0
- package/dist/actions/trigger-zapier-webhook/mock.d.ts +2 -0
- package/dist/actions/trigger-zapier-webhook/mock.js +8 -0
- package/dist/actions/update-customer-facing-display/mock.d.ts +2 -0
- package/dist/actions/update-customer-facing-display/mock.js +8 -0
- package/dist/actions/vendara-payment/mock.d.ts +2 -0
- package/dist/actions/vendara-payment/mock.js +11 -0
- package/dist/actions/vendara-payment/types.d.ts +2 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.js +62 -1
- package/dist/demo/database.d.ts +45 -0
- package/dist/demo/database.js +515 -0
- package/dist/demo/registry.d.ts +5 -0
- package/dist/demo/registry.js +106 -0
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +6 -5
- package/package.json +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { MOCK_ORDERS, MOCK_USERS, MOCK_STATIONS, MOCK_OUTLETS, safeSerialize } from "../../demo/database";
|
|
2
|
+
export const mockGetOrders = async (params) => {
|
|
3
|
+
console.log("[Mock] getOrders called", params);
|
|
4
|
+
// Start with a safe copy of mock orders
|
|
5
|
+
let orders = safeSerialize(MOCK_ORDERS);
|
|
6
|
+
// Filter simulation
|
|
7
|
+
if (params) {
|
|
8
|
+
const { customerId, status, sessionId, searchValue, limit, offset, sortBy, sortDirection } = params;
|
|
9
|
+
// 1. Filtering
|
|
10
|
+
if (customerId) {
|
|
11
|
+
orders = orders.filter(o => o.customer &&
|
|
12
|
+
'_id' in o.customer &&
|
|
13
|
+
o.customer._id === customerId);
|
|
14
|
+
}
|
|
15
|
+
if (status) {
|
|
16
|
+
orders = orders.filter(o => o.status === status);
|
|
17
|
+
}
|
|
18
|
+
if (sessionId) {
|
|
19
|
+
orders = orders.filter(o => o.sessionId === sessionId);
|
|
20
|
+
}
|
|
21
|
+
if (searchValue) {
|
|
22
|
+
const searchLower = String(searchValue).toLowerCase();
|
|
23
|
+
orders = orders.filter(o => {
|
|
24
|
+
const receiptMatch = o.receiptId?.toLowerCase().includes(searchLower);
|
|
25
|
+
const customerNameMatch = o.customer && 'firstName' in o.customer
|
|
26
|
+
? `${o.customer.firstName} ${o.customer.lastName}`.toLowerCase().includes(searchLower)
|
|
27
|
+
: false;
|
|
28
|
+
const customerEmailMatch = o.customer && 'email' in o.customer && o.customer.email
|
|
29
|
+
? o.customer.email.toLowerCase().includes(searchLower)
|
|
30
|
+
: false;
|
|
31
|
+
return receiptMatch || customerNameMatch || customerEmailMatch;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// 2. Sorting
|
|
35
|
+
if (sortBy) {
|
|
36
|
+
orders.sort((a, b) => {
|
|
37
|
+
let valA = a[sortBy];
|
|
38
|
+
let valB = b[sortBy];
|
|
39
|
+
// Handle nested sort fields if necessary, basic support for now
|
|
40
|
+
if (!valA && sortBy === 'createdAt')
|
|
41
|
+
valA = a.createdAt || '';
|
|
42
|
+
if (!valB && sortBy === 'createdAt')
|
|
43
|
+
valB = b.createdAt || '';
|
|
44
|
+
if (typeof valA === 'string' && typeof valB === 'string') {
|
|
45
|
+
return sortDirection === 'descending'
|
|
46
|
+
? valB.localeCompare(valA)
|
|
47
|
+
: valA.localeCompare(valB);
|
|
48
|
+
}
|
|
49
|
+
// Number comparison
|
|
50
|
+
return sortDirection === 'descending'
|
|
51
|
+
? (valB || 0) - (valA || 0)
|
|
52
|
+
: (valA || 0) - (valB || 0);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Default sort by createdAt descending
|
|
57
|
+
orders.sort((a, b) => {
|
|
58
|
+
const dateA = new Date(a.createdAt || 0).getTime();
|
|
59
|
+
const dateB = new Date(b.createdAt || 0).getTime();
|
|
60
|
+
return dateB - dateA;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// 3. Pagination
|
|
64
|
+
if (offset !== undefined || limit !== undefined) {
|
|
65
|
+
const start = offset || 0;
|
|
66
|
+
const end = limit ? start + limit : orders.length;
|
|
67
|
+
orders = orders.slice(start, end);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Simulate Worker Enrichment (populating posData references with actual objects)
|
|
71
|
+
const enrichedOrders = orders.map((order) => {
|
|
72
|
+
const enrichedOrder = { ...order };
|
|
73
|
+
if (enrichedOrder.posData) {
|
|
74
|
+
// Enrich Employee
|
|
75
|
+
if (typeof enrichedOrder.posData.employee === 'string') {
|
|
76
|
+
const employee = MOCK_USERS.find(u => u.id === enrichedOrder.posData.employee);
|
|
77
|
+
if (employee) {
|
|
78
|
+
enrichedOrder.posData.employee = employee;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Enrich Station
|
|
82
|
+
if (typeof enrichedOrder.posData.station === 'string') {
|
|
83
|
+
const station = MOCK_STATIONS.find(s => s._id === enrichedOrder.posData.station);
|
|
84
|
+
if (station) {
|
|
85
|
+
enrichedOrder.posData.station = station;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Enrich Outlet
|
|
89
|
+
if (typeof enrichedOrder.posData.outlet === 'string') {
|
|
90
|
+
const outlet = MOCK_OUTLETS.find(o => o.id === enrichedOrder.posData.outlet);
|
|
91
|
+
if (outlet) {
|
|
92
|
+
enrichedOrder.posData.outlet = outlet;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return enrichedOrder;
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
orders: enrichedOrders,
|
|
101
|
+
total: MOCK_ORDERS.length, // Total before pagination
|
|
102
|
+
timestamp: new Date().toISOString()
|
|
103
|
+
};
|
|
104
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFOrder } from "../../CommonTypes";
|
|
1
2
|
export interface GetOrdersParams {
|
|
2
3
|
status?: string;
|
|
3
4
|
customerId?: string;
|
|
@@ -10,7 +11,7 @@ export interface GetOrdersParams {
|
|
|
10
11
|
}
|
|
11
12
|
export interface GetOrdersResponse {
|
|
12
13
|
success: boolean;
|
|
13
|
-
orders:
|
|
14
|
+
orders: CFOrder[];
|
|
14
15
|
total: number;
|
|
15
16
|
timestamp: string;
|
|
16
17
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MOCK_PRODUCTS, safeSerialize } from "../../demo/database";
|
|
2
|
+
export const mockGetProductVariants = async (params) => {
|
|
3
|
+
console.log("[Mock] getProductVariants called", params);
|
|
4
|
+
if (!params?.productId) {
|
|
5
|
+
throw new Error("productId is required");
|
|
6
|
+
}
|
|
7
|
+
const product = MOCK_PRODUCTS.find(p => p._id === params.productId);
|
|
8
|
+
const variants = product ? product.variants : [];
|
|
9
|
+
return {
|
|
10
|
+
variants: safeSerialize(variants),
|
|
11
|
+
productId: params.productId,
|
|
12
|
+
timestamp: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { CFProductVariant } from "../../CommonTypes";
|
|
1
2
|
export interface GetProductVariantsParams {
|
|
2
3
|
productId: string;
|
|
3
4
|
}
|
|
4
5
|
export interface GetProductVariantsResponse {
|
|
5
|
-
variants:
|
|
6
|
+
variants: CFProductVariant[];
|
|
6
7
|
productId: string;
|
|
7
8
|
timestamp: string;
|
|
8
9
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MOCK_PRODUCTS, safeSerialize } from "../../demo/database";
|
|
2
|
+
export const mockGetProducts = async (params) => {
|
|
3
|
+
console.log("[Mock] getProducts called", params);
|
|
4
|
+
// Simple filter simulation
|
|
5
|
+
let products = MOCK_PRODUCTS;
|
|
6
|
+
const query = params?.query || {};
|
|
7
|
+
if (query.searchValue) {
|
|
8
|
+
const search = String(query.searchValue).toLowerCase();
|
|
9
|
+
products = products.filter(p => p.name.toLowerCase().includes(search) ||
|
|
10
|
+
p.sku?.toLowerCase().includes(search));
|
|
11
|
+
}
|
|
12
|
+
if (query.categories) {
|
|
13
|
+
// Handle categories filter: { $in: [...] } or direct string
|
|
14
|
+
const catFilter = query.categories;
|
|
15
|
+
if (typeof catFilter === 'string') {
|
|
16
|
+
products = products.filter(p => p.categories?.externalId === catFilter);
|
|
17
|
+
}
|
|
18
|
+
else if (typeof catFilter === 'object' && '$in' in catFilter) {
|
|
19
|
+
const inList = catFilter.$in;
|
|
20
|
+
products = products.filter(p => inList.includes(p.categories?.externalId));
|
|
21
|
+
}
|
|
22
|
+
else if (typeof catFilter === 'object' && '$contains' in catFilter) {
|
|
23
|
+
const containsVal = catFilter.$contains;
|
|
24
|
+
products = products.filter(p => p.categories?.externalId === containsVal);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
products: safeSerialize(products),
|
|
29
|
+
timestamp: new Date().toISOString()
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFProduct } from "../../CommonTypes";
|
|
1
2
|
export interface GetProductsParams {
|
|
2
3
|
query?: {
|
|
3
4
|
name?: string | {
|
|
@@ -22,7 +23,7 @@ export interface GetProductsParams {
|
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
export interface GetProductsResponse {
|
|
25
|
-
products:
|
|
26
|
+
products: CFProduct[];
|
|
26
27
|
timestamp: string;
|
|
27
28
|
}
|
|
28
29
|
export type GetProducts = (params?: GetProductsParams) => Promise<GetProductsResponse>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFRefundItem } from "../../CommonTypes";
|
|
1
2
|
export interface GetRefundsParams {
|
|
2
3
|
orderId?: string;
|
|
3
4
|
sessionId?: string;
|
|
@@ -9,7 +10,7 @@ export interface GetRefundsParams {
|
|
|
9
10
|
}
|
|
10
11
|
export interface GetRefundsResponse {
|
|
11
12
|
success: boolean;
|
|
12
|
-
refunds:
|
|
13
|
+
refunds: CFRefundItem[];
|
|
13
14
|
total: number;
|
|
14
15
|
timestamp: string;
|
|
15
16
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MOCK_ORDERS } from "../../demo/database";
|
|
2
|
+
export const mockPartialPayment = async (params) => {
|
|
3
|
+
console.log("[Mock] partialPayment called", params);
|
|
4
|
+
return {
|
|
5
|
+
success: true,
|
|
6
|
+
amount: params?.amount,
|
|
7
|
+
isPercent: params?.isPercent || false,
|
|
8
|
+
openUI: params?.openUI || false,
|
|
9
|
+
order: params?.openUI ? null : MOCK_ORDERS[0],
|
|
10
|
+
timestamp: new Date().toISOString()
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFOrder } from "../../CommonTypes";
|
|
1
2
|
export interface PartialPaymentParams {
|
|
2
3
|
amount?: number;
|
|
3
4
|
isPercent?: boolean;
|
|
@@ -8,7 +9,7 @@ export interface PartialPaymentResponse {
|
|
|
8
9
|
amount?: number;
|
|
9
10
|
isPercent?: boolean;
|
|
10
11
|
openUI: boolean;
|
|
11
|
-
order:
|
|
12
|
+
order: CFOrder | null;
|
|
12
13
|
timestamp: string;
|
|
13
14
|
}
|
|
14
15
|
export type PartialPayment = (params?: PartialPaymentParams) => Promise<PartialPaymentResponse>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MOCK_CART } from "../../demo/database";
|
|
2
|
+
export const mockRemoveCustomerFromCart = async () => {
|
|
3
|
+
console.log("[Mock] removeCustomerFromCart called");
|
|
4
|
+
MOCK_CART.customer = null;
|
|
5
|
+
return {
|
|
6
|
+
success: true,
|
|
7
|
+
timestamp: new Date().toISOString()
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MOCK_ORDERS } from "../../demo/database";
|
|
2
|
+
export const mockResumeParkedOrder = async (params) => {
|
|
3
|
+
console.log("[Mock] resumeParkedOrder called", params);
|
|
4
|
+
return {
|
|
5
|
+
success: true,
|
|
6
|
+
order: MOCK_ORDERS[0],
|
|
7
|
+
timestamp: new Date().toISOString()
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { CFOrder } from "../../CommonTypes";
|
|
1
2
|
export interface ResumeParkedOrderParams {
|
|
2
3
|
orderId: string;
|
|
3
4
|
}
|
|
4
5
|
export interface ResumeParkedOrderResponse {
|
|
5
6
|
success: boolean;
|
|
6
|
-
order:
|
|
7
|
+
order: CFOrder;
|
|
7
8
|
timestamp: string;
|
|
8
9
|
}
|
|
9
10
|
export type ResumeParkedOrder = (params?: ResumeParkedOrderParams) => Promise<ResumeParkedOrderResponse>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const mockSetRefundStockAction = async (params) => {
|
|
2
|
+
console.log("[Mock] setRefundStockAction called", params);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
itemKey: params?.itemKey || "",
|
|
6
|
+
action: params?.action || "RESTOCK",
|
|
7
|
+
timestamp: new Date().toISOString()
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const mockSwitchUser = async (params) => {
|
|
2
|
+
console.log("[Mock] switchUser called", params);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
mode: params?.mode || 'dialog',
|
|
6
|
+
roleIds: params?.roleIds,
|
|
7
|
+
userId: params?.userId,
|
|
8
|
+
timestamp: new Date().toISOString()
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MOCK_ORDERS } from "../../demo/database";
|
|
2
|
+
export const mockTapToPayPayment = async (params) => {
|
|
3
|
+
console.log("[Mock] tapToPayPayment called", params);
|
|
4
|
+
return {
|
|
5
|
+
success: true,
|
|
6
|
+
amount: params?.amount || null,
|
|
7
|
+
paymentType: "tapToPay",
|
|
8
|
+
order: MOCK_ORDERS[0],
|
|
9
|
+
timestamp: new Date().toISOString()
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFOrder } from "../../CommonTypes";
|
|
1
2
|
export interface TapToPayPaymentParams {
|
|
2
3
|
amount?: number;
|
|
3
4
|
}
|
|
@@ -5,7 +6,7 @@ export interface TapToPayPaymentResponse {
|
|
|
5
6
|
success: boolean;
|
|
6
7
|
amount: number | null;
|
|
7
8
|
paymentType: string;
|
|
8
|
-
order:
|
|
9
|
+
order: CFOrder | null;
|
|
9
10
|
timestamp: string;
|
|
10
11
|
}
|
|
11
12
|
export type TapToPayPayment = (params?: TapToPayPaymentParams) => Promise<TapToPayPaymentResponse>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createOrderFromCart } from "../../demo/database";
|
|
2
|
+
export const mockTerminalPayment = async (params) => {
|
|
3
|
+
console.log("[Mock] terminalPayment called", params);
|
|
4
|
+
const amount = params?.amount || 0;
|
|
5
|
+
// Mocking terminal payment success immediately
|
|
6
|
+
const order = createOrderFromCart("card", amount, "stripe_terminal");
|
|
7
|
+
return {
|
|
8
|
+
success: true,
|
|
9
|
+
amount: amount,
|
|
10
|
+
paymentType: "terminal",
|
|
11
|
+
order,
|
|
12
|
+
timestamp: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFOrder } from "../../CommonTypes";
|
|
1
2
|
export interface TerminalPaymentParams {
|
|
2
3
|
amount?: number;
|
|
3
4
|
}
|
|
@@ -5,7 +6,7 @@ export interface TerminalPaymentResponse {
|
|
|
5
6
|
success: boolean;
|
|
6
7
|
amount: number | null;
|
|
7
8
|
paymentType: string;
|
|
8
|
-
order:
|
|
9
|
+
order: CFOrder | null;
|
|
9
10
|
timestamp: string;
|
|
10
11
|
}
|
|
11
12
|
export type TerminalPayment = (params?: TerminalPaymentParams) => Promise<TerminalPaymentResponse>;
|