@pisell/private-materials 6.12.170 → 6.12.172
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +18 -18
- package/build/lowcode/view.js +18 -18
- package/es/components/HDLKiosk/app/workflow/predicates.js +1 -1
- package/es/components/HDLKiosk/runtime/operations/coordinator.js +2 -1
- package/es/components/HDLKiosk/runtime/operations/session.js +3 -2
- package/es/components/HDLKiosk/runtime/session/createSession.js +26 -3
- package/es/components/HDLKiosk/runtime/session/transitionRunner.js +6 -2
- package/es/components/HDLKiosk/slices/payment/view.js +13 -4
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +1 -0
- package/es/components/bigSale/components/TimeBar/index.js +1 -0
- package/es/components/bigSale/dialog.js +1 -0
- package/es/components/bigSale/hooks/useBigSaleContext.js +1 -0
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +1 -0
- package/es/components/bigSale/index.js +1 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/host/projection.js +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +7 -2
- package/es/components/bigSale/templates/HDLKiosk/runtime/HDLKioskPaymentRuntime.js +95 -148
- package/es/components/bigSale/templates/HDLKiosk/runtime/eftposPayment.js +110 -0
- package/es/components/bigSale/templates/HDLKiosk/runtime/staffPaymentAuthorization.js +183 -0
- package/es/components/bigSale/templates/Kiosk/index.js +1 -0
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +1 -0
- package/es/index.js +2 -0
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/pisellReservation/index.js +17 -0
- package/es/plus/saleDetail/Base.js +1 -0
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +1 -0
- package/es/plus/saleDetail/components/DetailActions/index.js +1 -0
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +1 -0
- package/es/plus/saleDetail/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/index.js +1 -0
- package/es/plus/salesSdk/index.js +52 -0
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +2 -1
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/HDLKiosk/app/workflow/predicates.js +1 -1
- package/lib/components/HDLKiosk/runtime/operations/coordinator.js +2 -1
- package/lib/components/HDLKiosk/runtime/operations/session.js +3 -2
- package/lib/components/HDLKiosk/runtime/session/createSession.js +26 -3
- package/lib/components/HDLKiosk/runtime/session/transitionRunner.js +6 -2
- package/lib/components/HDLKiosk/slices/payment/view.js +13 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/host/projection.js +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +7 -2
- package/lib/components/bigSale/templates/HDLKiosk/runtime/HDLKioskPaymentRuntime.js +92 -145
- package/lib/components/bigSale/templates/HDLKiosk/runtime/eftposPayment.js +110 -0
- package/lib/components/bigSale/templates/HDLKiosk/runtime/staffPaymentAuthorization.js +186 -0
- package/package.json +4 -4
- package/es/private-materials/lowcode/authmodal/meta.d.ts +0 -1
|
@@ -70,27 +70,49 @@ function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
|
70
70
|
});
|
|
71
71
|
actorRef = workflowActor;
|
|
72
72
|
let paymentProjectionObservationId;
|
|
73
|
+
let staffPaymentPending = false;
|
|
74
|
+
let staffPaymentOutcome;
|
|
73
75
|
const advanceConfirmedPayment = () => {
|
|
74
|
-
var _definition$nodes$sna;
|
|
76
|
+
var _staffPaymentOutcome, _definition$nodes$sna;
|
|
75
77
|
const snapshot = workflowActor.getSnapshot();
|
|
76
78
|
const projection = host.sales.getObservedSnapshot();
|
|
77
|
-
|
|
79
|
+
const projectionOutcome = projection.payment.status === "succeeded" ? Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
|
|
80
|
+
orderId: projection.payment.orderId,
|
|
81
|
+
amount: projection.payment.amount
|
|
82
|
+
}, projection.summary.status === "ready" && projection.summary.currencySymbol ? { currencySymbol: projection.summary.currencySymbol } : {}), projection.pickupNumber ? { pickupNumber: projection.pickupNumber } : {}), projection.customer ? { member: projection.customer.member === true } : {})) : void 0;
|
|
83
|
+
const outcome = (_staffPaymentOutcome = staffPaymentOutcome) !== null && _staffPaymentOutcome !== void 0 ? _staffPaymentOutcome : projectionOutcome;
|
|
84
|
+
if (snapshot.status !== "idle" || ((_definition$nodes$sna = definition.nodes[snapshot.nodeId]) === null || _definition$nodes$sna === void 0 ? void 0 : _definition$nodes$sna.activity) !== "paymentMethod" || staffPaymentPending && !staffPaymentOutcome || !outcome || !staffPaymentOutcome && paymentProjectionObservationId === projection.observationId) return;
|
|
78
85
|
paymentProjectionObservationId = projection.observationId;
|
|
79
86
|
workflowActor.send({
|
|
80
87
|
type: "ACTIVITY_INTENT",
|
|
81
88
|
stepId: snapshot.nodeId,
|
|
82
89
|
activityId: "paymentMethod",
|
|
83
90
|
intent: "complete",
|
|
84
|
-
intentId: `projection:payment:${snapshot.sessionEpoch}:${projection.observationId}
|
|
91
|
+
intentId: staffPaymentOutcome ? `staff-payment:${snapshot.sessionEpoch}:${projection.observationId}` : `projection:payment:${snapshot.sessionEpoch}:${projection.observationId}`,
|
|
92
|
+
receipt: outcome
|
|
85
93
|
});
|
|
86
94
|
};
|
|
87
95
|
let unsubscribePaymentProjection = () => void 0;
|
|
88
96
|
let unsubscribePaymentWorkflow = () => void 0;
|
|
97
|
+
let unsubscribeStaffPayment = () => void 0;
|
|
89
98
|
try {
|
|
90
99
|
unsubscribePaymentProjection = host.sales.subscribe(advanceConfirmedPayment);
|
|
91
100
|
unsubscribePaymentWorkflow = workflowActor.subscribe(advanceConfirmedPayment);
|
|
101
|
+
unsubscribeStaffPayment = host.sales.subscribeStaffPaymentAuthorizationResult((result) => {
|
|
102
|
+
if (result.status === "pending") {
|
|
103
|
+
staffPaymentPending = true;
|
|
104
|
+
staffPaymentOutcome = void 0;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
staffPaymentPending = false;
|
|
108
|
+
staffPaymentOutcome = result.status === "succeeded" ? result.data : void 0;
|
|
109
|
+
if (staffPaymentOutcome) coordinator.confirmPaymentSucceeded();
|
|
110
|
+
advanceConfirmedPayment();
|
|
111
|
+
});
|
|
92
112
|
} catch (error) {
|
|
93
113
|
unsubscribePaymentProjection();
|
|
114
|
+
unsubscribePaymentWorkflow();
|
|
115
|
+
unsubscribeStaffPayment();
|
|
94
116
|
workflowActor.dispose();
|
|
95
117
|
throw error;
|
|
96
118
|
}
|
|
@@ -121,6 +143,7 @@ function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
|
121
143
|
disposed = true;
|
|
122
144
|
unsubscribePaymentProjection();
|
|
123
145
|
unsubscribePaymentWorkflow();
|
|
146
|
+
unsubscribeStaffPayment();
|
|
124
147
|
workflowActor.dispose();
|
|
125
148
|
};
|
|
126
149
|
const publicActor = Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, workflowActor), {}, { dispose: disposeSession }));
|
|
@@ -39,7 +39,8 @@ function createHDLKioskTransitionRunner({ host, coordinator, predicates, now = D
|
|
|
39
39
|
if (exitPolicy === null || exitPolicy === void 0 ? void 0 : exitPolicy.precondition) try {
|
|
40
40
|
if (!predicates.evaluate(exitPolicy.precondition, {
|
|
41
41
|
workflow: context,
|
|
42
|
-
sales: host.sales.getObservedSnapshot()
|
|
42
|
+
sales: host.sales.getObservedSnapshot(),
|
|
43
|
+
receipt: "receipt" in event ? event.receipt : void 0
|
|
43
44
|
})) return { status: "stay" };
|
|
44
45
|
} catch (cause) {
|
|
45
46
|
const error = createDomainWorkflowError("workflowPredicateEvaluationFailed", "staff", cause);
|
|
@@ -51,7 +52,10 @@ function createHDLKioskTransitionRunner({ host, coordinator, predicates, now = D
|
|
|
51
52
|
}
|
|
52
53
|
const operationInput = "operationInput" in event ? event.operationInput : void 0;
|
|
53
54
|
const command = exitPolicy === null || exitPolicy === void 0 ? void 0 : exitPolicy.command;
|
|
54
|
-
if (!command) return {
|
|
55
|
+
if (!command) return {
|
|
56
|
+
status: "advance",
|
|
57
|
+
receipt: "receipt" in event ? event.receipt : void 0
|
|
58
|
+
};
|
|
55
59
|
const result = yield coordinator.execute(command.id, {
|
|
56
60
|
operationId: executionId,
|
|
57
61
|
intentId: event.intentId,
|
|
@@ -53,7 +53,16 @@ function createPaymentFeedback(snapshot, sales) {
|
|
|
53
53
|
message: _pisell_utils.locales.getText("pisell2.hdl-kiosk.payment-failed-retry")
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
+
function readPaymentResultReceipt(snapshot) {
|
|
57
|
+
const receipt = snapshot.receipt;
|
|
58
|
+
if (!receipt || typeof receipt !== "object") return void 0;
|
|
59
|
+
const candidate = receipt;
|
|
60
|
+
if (typeof candidate.orderId !== "string" || !candidate.orderId.trim() || candidate.amount === void 0 || candidate.amount === null || !Number.isFinite(Number(candidate.amount))) return;
|
|
61
|
+
return candidate;
|
|
62
|
+
}
|
|
56
63
|
function createCheckoutScreenModel(snapshot, sales, payment, completed = false, resetting = false) {
|
|
64
|
+
var _paymentResultReceipt, _paymentResultReceipt2;
|
|
65
|
+
const paymentResultReceipt = completed ? readPaymentResultReceipt(snapshot) : void 0;
|
|
57
66
|
const paymentSafeToChange = sales.payment.status === "idle" || sales.payment.status === "failed";
|
|
58
67
|
const interactionAvailable = !completed && !resetting && snapshot.status === "idle" && paymentSafeToChange;
|
|
59
68
|
const totalText = sales.summary.status === "ready" ? require_utils.formatCurrencyAmount(sales.summary.due, sales.summary.currencySymbol) : void 0;
|
|
@@ -74,12 +83,12 @@ function createCheckoutScreenModel(snapshot, sales, payment, completed = false,
|
|
|
74
83
|
paymentResult: completed ? require_resolve.resolvePaymentResultToastV2ViewModel({
|
|
75
84
|
status: "success",
|
|
76
85
|
paymentStatus: "paid",
|
|
77
|
-
currencySymbol: sales.summary.status === "ready" ? sales.summary.currencySymbol : void 0,
|
|
78
|
-
orderTotalAmount: sales.payment.status === "succeeded" ? sales.payment.amount : sales.summary.status === "ready" ? sales.summary.total : void 0,
|
|
86
|
+
currencySymbol: (_paymentResultReceipt = paymentResultReceipt === null || paymentResultReceipt === void 0 ? void 0 : paymentResultReceipt.currencySymbol) !== null && _paymentResultReceipt !== void 0 ? _paymentResultReceipt : sales.summary.status === "ready" ? sales.summary.currencySymbol : void 0,
|
|
87
|
+
orderTotalAmount: (_paymentResultReceipt2 = paymentResultReceipt === null || paymentResultReceipt === void 0 ? void 0 : paymentResultReceipt.amount) !== null && _paymentResultReceipt2 !== void 0 ? _paymentResultReceipt2 : sales.payment.status === "succeeded" ? sales.payment.amount : sales.summary.status === "ready" ? sales.summary.total : void 0,
|
|
79
88
|
prominentReference: {
|
|
80
89
|
label: _pisell_utils.locales.getText("pisell2.hdl-kiosk.pickup-number"),
|
|
81
|
-
value: sales.pickupNumber || _pisell_utils.locales.getText("pisell2.hdl-kiosk.pickup-number-pending"),
|
|
82
|
-
pending: !sales.pickupNumber
|
|
90
|
+
value: (paymentResultReceipt === null || paymentResultReceipt === void 0 ? void 0 : paymentResultReceipt.pickupNumber) || sales.pickupNumber || _pisell_utils.locales.getText("pisell2.hdl-kiosk.pickup-number-pending"),
|
|
91
|
+
pending: !((paymentResultReceipt === null || paymentResultReceipt === void 0 ? void 0 : paymentResultReceipt.pickupNumber) || sales.pickupNumber)
|
|
83
92
|
},
|
|
84
93
|
disableDetail: true
|
|
85
94
|
}) : void 0,
|
|
@@ -144,7 +144,7 @@ function buildSnapshot(context, observationId, pickupReferenceMode) {
|
|
|
144
144
|
currency: String((_context$sales$tempOr2 = (_context$sales$tempOr3 = context.sales.tempOrder) === null || _context$sales$tempOr3 === void 0 ? void 0 : _context$sales$tempOr3.currency_code) !== null && _context$sales$tempOr2 !== void 0 ? _context$sales$tempOr2 : ""),
|
|
145
145
|
currencySymbol: String((_context$sales$tempOr4 = (_context$sales$tempOr5 = context.sales.tempOrder) === null || _context$sales$tempOr5 === void 0 ? void 0 : _context$sales$tempOr5.currency_symbol) !== null && _context$sales$tempOr4 !== void 0 ? _context$sales$tempOr4 : ""),
|
|
146
146
|
total: String(summary.total_amount),
|
|
147
|
-
due: String(summary.
|
|
147
|
+
due: String(summary.amount_gap)
|
|
148
148
|
}) : context.sales.status === "loading" ? Object.freeze({ status: "calculating" }) : Object.freeze({ status: "missing" });
|
|
149
149
|
const avatarUrl = typeof ((_context$customer$sel = context.customer.selected) === null || _context$customer$sel === void 0 ? void 0 : _context$customer$sel.avatar) === "string" && context.customer.selected.avatar.trim() ? context.customer.selected.avatar.trim() : void 0;
|
|
150
150
|
const customer = context.customer.selected ? Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
|
|
@@ -28,7 +28,9 @@ function createBigSaleSessionOperations({ getContext }) {
|
|
|
28
28
|
data: void 0
|
|
29
29
|
};
|
|
30
30
|
try {
|
|
31
|
-
const
|
|
31
|
+
const resetPaidOrder = isCommittedPaidOrder(currentOrder);
|
|
32
|
+
const createdOrder = resetPaidOrder ? yield context.sales.clearCartAndReset() : yield context.sales.createNew();
|
|
33
|
+
if (resetPaidOrder) yield context.cart.recalcSummary();
|
|
32
34
|
if (signal.aborted) return require_normalize.unknown("ensureSessionAbortedAfterDispatch");
|
|
33
35
|
const liveCreatedOrder = require_projection.resolveBigSaleLiveTempOrder(getContext());
|
|
34
36
|
const createdPaymentStatus = readPaymentStatus(liveCreatedOrder !== null && liveCreatedOrder !== void 0 ? liveCreatedOrder : createdOrder);
|
|
@@ -50,9 +52,12 @@ function createBigSaleSessionOperations({ getContext }) {
|
|
|
50
52
|
if (signal.aborted) return { status: "cancelled" };
|
|
51
53
|
try {
|
|
52
54
|
var _resetOrder$products$, _resetOrder$products, _resetOrder$bookings$, _resetOrder$bookings;
|
|
53
|
-
const
|
|
55
|
+
const context = getContext();
|
|
56
|
+
const resetOrder = yield context.sales.clearCartAndReset();
|
|
54
57
|
if (signal.aborted) return require_normalize.unknown("resetAbortedAfterDispatch");
|
|
55
58
|
if (!(((_resetOrder$products$ = (_resetOrder$products = resetOrder.products) === null || _resetOrder$products === void 0 ? void 0 : _resetOrder$products.length) !== null && _resetOrder$products$ !== void 0 ? _resetOrder$products$ : 0) === 0 && ((_resetOrder$bookings$ = (_resetOrder$bookings = resetOrder.bookings) === null || _resetOrder$bookings === void 0 ? void 0 : _resetOrder$bookings.length) !== null && _resetOrder$bookings$ !== void 0 ? _resetOrder$bookings$ : 0) === 0)) return require_normalize.unknown("resetHostResultNotEmpty");
|
|
59
|
+
yield context.cart.recalcSummary();
|
|
60
|
+
if (signal.aborted) return require_normalize.unknown("resetAbortedAfterRecalculation");
|
|
56
61
|
return {
|
|
57
62
|
status: "succeeded",
|
|
58
63
|
data: { cartEmpty: true }
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
|
|
2
2
|
const require_asyncToGenerator = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
-
const require_objectWithoutProperties = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
|
|
4
3
|
const require_useEngineContext = require("../../../../../hooks/useEngineContext.js");
|
|
5
4
|
const require_constants = require("../../../../checkout/constants.js");
|
|
6
5
|
const require_PaymentMethodRuntime = require("../../../../checkout/paymentRuntime/PaymentMethodRuntime.js");
|
|
7
|
-
const require_pendingEftposLifecycle = require("../../../../checkout/paymentRuntime/pendingEftposLifecycle.js");
|
|
8
6
|
const require_utils = require("../../../../checkout/utils.js");
|
|
9
7
|
const require_normalize = require("../adapter/normalize.js");
|
|
8
|
+
const require_eftposPayment = require("./eftposPayment.js");
|
|
9
|
+
const require_staffPaymentAuthorization = require("./staffPaymentAuthorization.js");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
react = require_runtime.__toESM(react);
|
|
12
12
|
//#region src/components/bigSale/templates/HDLKiosk/runtime/HDLKioskPaymentRuntime.tsx
|
|
@@ -14,7 +14,6 @@ react = require_runtime.__toESM(react);
|
|
|
14
14
|
* BigSale 模板内的 Kiosk 支付桥。它持有需要 React/设备 UI 的 PaymentMethodRuntime,
|
|
15
15
|
* 再把窄命令交给独立 HDLKiosk Host;Core 不感知 BigSale、PiPayment 或 window.app。
|
|
16
16
|
*/
|
|
17
|
-
const _excluded = ["unique_payment_number"];
|
|
18
17
|
function asKioskMethod(method) {
|
|
19
18
|
var _raw$channel_applicat;
|
|
20
19
|
const raw = method;
|
|
@@ -37,45 +36,26 @@ function currentAmount(context) {
|
|
|
37
36
|
const amount = Number((_ref = (_summary$expect_amoun = summary === null || summary === void 0 ? void 0 : summary.expect_amount) !== null && _summary$expect_amoun !== void 0 ? _summary$expect_amoun : summary === null || summary === void 0 ? void 0 : summary.product_expect_amount) !== null && _ref !== void 0 ? _ref : summary === null || summary === void 0 ? void 0 : summary.total_amount);
|
|
38
37
|
return Number.isFinite(amount) && amount > 0 ? amount : 0;
|
|
39
38
|
}
|
|
40
|
-
function isStaffPaymentAuthorizationCancelled(result) {
|
|
41
|
-
var _record$status, _record$reason;
|
|
42
|
-
if (!result || typeof result !== "object") return false;
|
|
43
|
-
const record = result;
|
|
44
|
-
return [
|
|
45
|
-
"cancelled",
|
|
46
|
-
"canceled",
|
|
47
|
-
"closed"
|
|
48
|
-
].includes(String((_record$status = record.status) !== null && _record$status !== void 0 ? _record$status : "").toLowerCase()) || [
|
|
49
|
-
"cancelled",
|
|
50
|
-
"canceled",
|
|
51
|
-
"cancel"
|
|
52
|
-
].includes(String((_record$reason = record.reason) !== null && _record$reason !== void 0 ? _record$reason : "").toLowerCase());
|
|
53
|
-
}
|
|
54
|
-
function checkoutSuccess(baseSales) {
|
|
55
|
-
var _baseSales$getTempOrd, _baseSales$getOrderId, _ref2, _baseSales$getOrderAm, _baseSales$getOrderAm2;
|
|
56
|
-
const order = (baseSales === null || baseSales === void 0 || (_baseSales$getTempOrd = baseSales.getTempOrder) === null || _baseSales$getTempOrd === void 0 ? void 0 : _baseSales$getTempOrd.call(baseSales)) || {};
|
|
57
|
-
const orderId = ((baseSales === null || baseSales === void 0 || (_baseSales$getOrderId = baseSales.getOrderIdentity) === null || _baseSales$getOrderId === void 0 ? void 0 : _baseSales$getOrderId.call(baseSales)) || {}).orderId || order.order_id;
|
|
58
|
-
if (!orderId) return require_normalize.unknown("eftposSuccessMissingOrderId");
|
|
59
|
-
return {
|
|
60
|
-
status: "succeeded",
|
|
61
|
-
data: {
|
|
62
|
-
orderId: String(orderId),
|
|
63
|
-
amount: String((_ref2 = (_baseSales$getOrderAm = baseSales === null || baseSales === void 0 || (_baseSales$getOrderAm2 = baseSales.getOrderAmountSnapshot) === null || _baseSales$getOrderAm2 === void 0 || (_baseSales$getOrderAm2 = _baseSales$getOrderAm2.call(baseSales)) === null || _baseSales$getOrderAm2 === void 0 ? void 0 : _baseSales$getOrderAm2.expectAmount) !== null && _baseSales$getOrderAm !== void 0 ? _baseSales$getOrderAm : order.expect_amount) !== null && _ref2 !== void 0 ? _ref2 : 0)
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
39
|
function HDLKioskPaymentRuntime({ context, controllerRef }) {
|
|
68
40
|
var _context$sales$tempOr, _engineContext$appHel5;
|
|
69
41
|
const engineContext = require_useEngineContext.default();
|
|
70
42
|
const runtimeRef = (0, react.useRef)(null);
|
|
71
43
|
const methodsRef = (0, react.useRef)([]);
|
|
72
44
|
const rawMethodsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
73
|
-
const
|
|
45
|
+
const authorizationStore = (0, react.useMemo)(() => require_staffPaymentAuthorization.createStaffPaymentAuthorizationStore(), []);
|
|
74
46
|
const baseSales = context.sales.bookingTicket;
|
|
75
47
|
const currencySymbol = ((_context$sales$tempOr = context.sales.tempOrder) === null || _context$sales$tempOr === void 0 ? void 0 : _context$sales$tempOr.currency_symbol) || "$";
|
|
48
|
+
const staffPaymentOutcomeContextRef = (0, react.useRef)({
|
|
49
|
+
baseSales,
|
|
50
|
+
loadDetail: context.sales.loadDetail
|
|
51
|
+
});
|
|
52
|
+
staffPaymentOutcomeContextRef.current = {
|
|
53
|
+
baseSales,
|
|
54
|
+
loadDetail: context.sales.loadDetail
|
|
55
|
+
};
|
|
76
56
|
const controller = (0, react.useMemo)(() => ({
|
|
77
57
|
loadPaymentMethods: function() {
|
|
78
|
-
var
|
|
58
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
79
59
|
if (!(baseSales === null || baseSales === void 0 ? void 0 : baseSales.getPaymentMethodsAsync)) return require_normalize.failed("paymentMethodsUnavailable", "staff");
|
|
80
60
|
try {
|
|
81
61
|
var _engineContext$appHel;
|
|
@@ -94,12 +74,12 @@ function HDLKioskPaymentRuntime({ context, controllerRef }) {
|
|
|
94
74
|
}
|
|
95
75
|
});
|
|
96
76
|
return function loadPaymentMethods() {
|
|
97
|
-
return
|
|
77
|
+
return _ref2.apply(this, arguments);
|
|
98
78
|
};
|
|
99
79
|
}(),
|
|
100
80
|
payEftpos: function() {
|
|
101
|
-
var
|
|
102
|
-
var _engineContext$appHel2, _engineContext$appHel3;
|
|
81
|
+
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* ({ paymentMethodId }) {
|
|
82
|
+
var _engineContext$appHel2, _engineContext$appHel3, _engineContext$appHel4;
|
|
103
83
|
const method = methodsRef.current.find((item) => item.id === paymentMethodId);
|
|
104
84
|
if (!(method === null || method === void 0 ? void 0 : method.eftpos)) return require_normalize.failed("eftposMethodUnavailable", "back");
|
|
105
85
|
const rawMethod = rawMethodsRef.current.get(paymentMethodId);
|
|
@@ -108,103 +88,39 @@ function HDLKioskPaymentRuntime({ context, controllerRef }) {
|
|
|
108
88
|
if (amount <= 0) return require_normalize.failed("paymentAmountInvalid", "back");
|
|
109
89
|
const runtime = runtimeRef.current;
|
|
110
90
|
if (!runtime) return require_normalize.failed("paymentRuntimeUnavailable", "retry");
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
shouldDiscardPrepared = true;
|
|
123
|
-
if (!prepared.salesId) throw new Error("Unable to resolve sales id before opening PiPayment.");
|
|
124
|
-
}
|
|
125
|
-
const deviceNumber = yield require_utils.getCurrentDeviceNumber((_engineContext$appHel4 = engineContext.appHelper) === null || _engineContext$appHel4 === void 0 || (_engineContext$appHel4 = _engineContext$appHel4.utils) === null || _engineContext$appHel4 === void 0 ? void 0 : _engineContext$appHel4.interaction);
|
|
126
|
-
const result = yield runtime.execute({
|
|
127
|
-
method: rawMethod,
|
|
128
|
-
amount,
|
|
129
|
-
currencySymbol,
|
|
130
|
-
deviceNumber,
|
|
131
|
-
preparedPayment: prepared ? {
|
|
132
|
-
paymentNumber: prepared.paymentNumber,
|
|
133
|
-
salesId: prepared.salesId
|
|
134
|
-
} : void 0
|
|
135
|
-
});
|
|
136
|
-
if (result.preservePendingPayment) shouldDiscardPrepared = false;
|
|
137
|
-
if (prepared && result.preservePendingPayment && result.status !== "success") return require_normalize.unknown("eftposPendingPaymentUnresolved", result);
|
|
138
|
-
if (result.status === "cancelled" || result.status === "provider-handled") {
|
|
139
|
-
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
140
|
-
return {
|
|
141
|
-
status: "cancelled",
|
|
142
|
-
reason: result.status
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
if (result.status === "cancel-order") {
|
|
146
|
-
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
147
|
-
return {
|
|
148
|
-
status: "cancelled",
|
|
149
|
-
reason: "cancelOrder"
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
if (result.status !== "success") {
|
|
153
|
-
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
154
|
-
return require_normalize.failed("eftposPaymentFailed", "retry", result.message);
|
|
155
|
-
}
|
|
156
|
-
if (prepared) {
|
|
157
|
-
shouldDiscardPrepared = false;
|
|
158
|
-
const _ref4 = result.metadata || {}, { unique_payment_number: transactionNumber } = _ref4, metadata = require_objectWithoutProperties._objectWithoutProperties(_ref4, _excluded);
|
|
159
|
-
yield require_pendingEftposLifecycle.completePendingEftposPayment({
|
|
160
|
-
amount: result.amount,
|
|
161
|
-
baseSales,
|
|
162
|
-
paymentNumber: prepared.paymentNumber,
|
|
163
|
-
transactionNumber,
|
|
164
|
-
serviceCharge: result.serviceCharge,
|
|
165
|
-
updates: { metadata }
|
|
166
|
-
});
|
|
167
|
-
} else if (typeof (baseSales === null || baseSales === void 0 ? void 0 : baseSales.commitPaymentMethodPayment) === "function") yield baseSales.commitPaymentMethodPayment({
|
|
168
|
-
paymentMethodId: method.id,
|
|
169
|
-
paymentMethodCode: method.code,
|
|
170
|
-
amount: result.amount,
|
|
171
|
-
serviceCharge: result.serviceCharge,
|
|
172
|
-
metadata: result.metadata
|
|
173
|
-
});
|
|
174
|
-
else return require_normalize.failed("paymentCommitUnavailable", "staff");
|
|
175
|
-
const orderId = (baseSales === null || baseSales === void 0 || (_baseSales$getOrderId2 = baseSales.getOrderIdentity) === null || _baseSales$getOrderId2 === void 0 || (_baseSales$getOrderId2 = _baseSales$getOrderId2.call(baseSales)) === null || _baseSales$getOrderId2 === void 0 ? void 0 : _baseSales$getOrderId2.orderId) || (baseSales === null || baseSales === void 0 || (_baseSales$getTempOrd2 = baseSales.getTempOrder) === null || _baseSales$getTempOrd2 === void 0 || (_baseSales$getTempOrd2 = _baseSales$getTempOrd2.call(baseSales)) === null || _baseSales$getTempOrd2 === void 0 ? void 0 : _baseSales$getTempOrd2.order_id);
|
|
176
|
-
if (orderId && typeof context.sales.loadDetail === "function") yield context.sales.loadDetail({
|
|
177
|
-
orderId,
|
|
178
|
-
forceRemote: true
|
|
179
|
-
});
|
|
180
|
-
return checkoutSuccess(baseSales);
|
|
181
|
-
} catch (error) {
|
|
182
|
-
try {
|
|
183
|
-
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
184
|
-
} catch (discardError) {
|
|
185
|
-
return require_normalize.unknown("eftposPendingRollbackFailed", discardError);
|
|
186
|
-
}
|
|
187
|
-
if (prepared && !shouldDiscardPrepared) return require_normalize.unknown("eftposPaymentFinalizationUnresolved", error);
|
|
188
|
-
return require_normalize.failed("eftposPaymentFailed", "retry", error);
|
|
189
|
-
}
|
|
91
|
+
return require_eftposPayment.executeEftposPayment({
|
|
92
|
+
amount,
|
|
93
|
+
baseSales,
|
|
94
|
+
currencySymbol,
|
|
95
|
+
interaction: (_engineContext$appHel2 = engineContext.appHelper) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel2 = _engineContext$appHel2.utils) === null || _engineContext$appHel2 === void 0 ? void 0 : _engineContext$appHel2.interaction,
|
|
96
|
+
isPiPaymentEnabled: Boolean((_engineContext$appHel3 = engineContext.appHelper) === null || _engineContext$appHel3 === void 0 || (_engineContext$appHel3 = _engineContext$appHel3.utils) === null || _engineContext$appHel3 === void 0 || (_engineContext$appHel3 = _engineContext$appHel3.businessUtils) === null || _engineContext$appHel3 === void 0 || (_engineContext$appHel4 = _engineContext$appHel3.isPiPaymentEnabled) === null || _engineContext$appHel4 === void 0 ? void 0 : _engineContext$appHel4.call(_engineContext$appHel3)),
|
|
97
|
+
loadDetail: context.sales.loadDetail,
|
|
98
|
+
method,
|
|
99
|
+
rawMethod,
|
|
100
|
+
runtime
|
|
101
|
+
});
|
|
190
102
|
});
|
|
191
103
|
return function payEftpos(_x) {
|
|
192
|
-
return
|
|
104
|
+
return _ref3.apply(this, arguments);
|
|
193
105
|
};
|
|
194
106
|
}(),
|
|
195
107
|
requestStaffPaymentApproval: function() {
|
|
196
|
-
var
|
|
108
|
+
var _ref4 = require_asyncToGenerator._asyncToGenerator(function* ({ paymentMethodId }) {
|
|
109
|
+
var _window;
|
|
197
110
|
const method = methodsRef.current.find((item) => item.id === paymentMethodId);
|
|
198
111
|
const amount = currentAmount(context);
|
|
199
112
|
if (!method || method.eftpos || amount <= 0) return require_normalize.failed("staffPaymentAuthorizationInvalid", "back");
|
|
113
|
+
const globalApp = (_window = window) === null || _window === void 0 || (_window = _window.app) === null || _window === void 0 || (_window = _window.applicationManager) === null || _window === void 0 ? void 0 : _window.get("global");
|
|
114
|
+
if (typeof (globalApp === null || globalApp === void 0 ? void 0 : globalApp.runFunction) !== "function") return require_normalize.failed("staffPaymentAuthorizationUnavailable", "staff");
|
|
115
|
+
const authorization = authorizationStore.begin({
|
|
116
|
+
amount,
|
|
117
|
+
currencySymbol,
|
|
118
|
+
member: context.customer.selected != null
|
|
119
|
+
});
|
|
120
|
+
if (!authorization) return require_normalize.failed("staffPaymentAuthorizationInProgress", "retry");
|
|
200
121
|
try {
|
|
201
|
-
var _baseSales$getOtherPa
|
|
122
|
+
var _baseSales$getOtherPa;
|
|
202
123
|
const otherParams = (yield baseSales === null || baseSales === void 0 || (_baseSales$getOtherPa = baseSales.getOtherParams) === null || _baseSales$getOtherPa === void 0 ? void 0 : _baseSales$getOtherPa.call(baseSales)) || (baseSales === null || baseSales === void 0 ? void 0 : baseSales.otherParams) || {};
|
|
203
|
-
const globalApp = (_window = window) === null || _window === void 0 || (_window = _window.app) === null || _window === void 0 || (_window = _window.applicationManager) === null || _window === void 0 ? void 0 : _window.get("global");
|
|
204
|
-
if (typeof (globalApp === null || globalApp === void 0 ? void 0 : globalApp.runFunction) !== "function") return require_normalize.failed("staffPaymentAuthorizationUnavailable", "staff");
|
|
205
|
-
const notifyClosed = () => {
|
|
206
|
-
authorizationListenersRef.current.forEach((listener) => listener({ status: "cancelled" }));
|
|
207
|
-
};
|
|
208
124
|
const result = yield globalApp.runFunction("authorizeAction", {
|
|
209
125
|
params: {
|
|
210
126
|
action: "pay",
|
|
@@ -213,27 +129,40 @@ function HDLKioskPaymentRuntime({ context, controllerRef }) {
|
|
|
213
129
|
paymentMethodType: method.type,
|
|
214
130
|
amount
|
|
215
131
|
},
|
|
216
|
-
onClose:
|
|
132
|
+
onClose: () => authorizationStore.cancel(authorization)
|
|
217
133
|
});
|
|
218
|
-
if (
|
|
219
|
-
|
|
134
|
+
if (authorizationStore.isSettling(authorization)) return {
|
|
135
|
+
status: "succeeded",
|
|
136
|
+
data: void 0
|
|
137
|
+
};
|
|
138
|
+
if (require_staffPaymentAuthorization.isStaffPaymentAuthorizationCancelled(result)) {
|
|
139
|
+
authorizationStore.cancel(authorization);
|
|
140
|
+
return require_normalize.failed("staffPaymentAuthorizationCancelled", "retry");
|
|
141
|
+
}
|
|
142
|
+
if ((result === null || result === void 0 ? void 0 : result.status) !== "success") {
|
|
143
|
+
authorizationStore.fail(authorization);
|
|
144
|
+
return require_normalize.failed("staffPaymentAuthorizationDispatchFailed", "retry", result.msg);
|
|
145
|
+
}
|
|
220
146
|
return {
|
|
221
147
|
status: "succeeded",
|
|
222
148
|
data: void 0
|
|
223
149
|
};
|
|
224
150
|
} catch (error) {
|
|
151
|
+
if (authorizationStore.isSettling(authorization)) return {
|
|
152
|
+
status: "succeeded",
|
|
153
|
+
data: void 0
|
|
154
|
+
};
|
|
155
|
+
authorizationStore.fail(authorization);
|
|
225
156
|
return require_normalize.failed("staffPaymentAuthorizationDispatchFailed", "retry", error);
|
|
226
157
|
}
|
|
227
158
|
});
|
|
228
159
|
return function requestStaffPaymentApproval(_x2) {
|
|
229
|
-
return
|
|
160
|
+
return _ref4.apply(this, arguments);
|
|
230
161
|
};
|
|
231
162
|
}(),
|
|
232
|
-
subscribeStaffPaymentAuthorizationResult:
|
|
233
|
-
authorizationListenersRef.current.add(listener);
|
|
234
|
-
return () => authorizationListenersRef.current.delete(listener);
|
|
235
|
-
}
|
|
163
|
+
subscribeStaffPaymentAuthorizationResult: authorizationStore.subscribe
|
|
236
164
|
}), [
|
|
165
|
+
authorizationStore,
|
|
237
166
|
baseSales,
|
|
238
167
|
context,
|
|
239
168
|
currencySymbol,
|
|
@@ -241,32 +170,50 @@ function HDLKioskPaymentRuntime({ context, controllerRef }) {
|
|
|
241
170
|
]);
|
|
242
171
|
(0, react.useEffect)(() => {
|
|
243
172
|
let cleanup;
|
|
173
|
+
let globalApp;
|
|
244
174
|
try {
|
|
245
175
|
var _window2, _app$applicationManag, _globalApp$runFunctio;
|
|
246
176
|
const app = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.app;
|
|
247
|
-
|
|
177
|
+
globalApp = app === null || app === void 0 || (_app$applicationManag = app.applicationManager) === null || _app$applicationManag === void 0 ? void 0 : _app$applicationManag.get("global");
|
|
248
178
|
cleanup = globalApp === null || globalApp === void 0 || (_globalApp$runFunctio = globalApp.runFunction) === null || _globalApp$runFunctio === void 0 ? void 0 : _globalApp$runFunctio.call(globalApp, "listenExternalCommand", {
|
|
249
179
|
app,
|
|
250
|
-
handler: (
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
180
|
+
handler: function() {
|
|
181
|
+
var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (command) {
|
|
182
|
+
if (command.command !== "payment_result") return;
|
|
183
|
+
const authorization = authorizationStore.beginSettlement();
|
|
184
|
+
if (!authorization) return;
|
|
185
|
+
const outcomeContext = staffPaymentOutcomeContextRef.current;
|
|
186
|
+
const result = yield require_staffPaymentAuthorization.resolveStaffPaymentResult({
|
|
187
|
+
params: command.params || {},
|
|
188
|
+
closeAuthorization: () => {
|
|
189
|
+
var _globalApp$runFunctio2;
|
|
190
|
+
return globalApp === null || globalApp === void 0 || (_globalApp$runFunctio2 = globalApp.runFunction) === null || _globalApp$runFunctio2 === void 0 ? void 0 : _globalApp$runFunctio2.call(globalApp, "closeAuthorization");
|
|
191
|
+
},
|
|
192
|
+
finalizeOutcome: () => require_staffPaymentAuthorization.finalizeStaffPaymentOutcome({
|
|
193
|
+
params: command.params || {},
|
|
194
|
+
baseSales: outcomeContext.baseSales,
|
|
195
|
+
loadDetail: outcomeContext.loadDetail,
|
|
196
|
+
fallbackAmount: authorization.amount,
|
|
197
|
+
currencySymbol: authorization.currencySymbol,
|
|
198
|
+
member: authorization.member
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
authorizationStore.complete(authorization, result);
|
|
262
202
|
});
|
|
263
|
-
|
|
203
|
+
return function handler(_x3) {
|
|
204
|
+
return _ref5.apply(this, arguments);
|
|
205
|
+
};
|
|
206
|
+
}()
|
|
264
207
|
});
|
|
265
208
|
} catch (_unused) {}
|
|
266
209
|
return () => {
|
|
267
210
|
if (typeof cleanup === "function") cleanup();
|
|
211
|
+
if (authorizationStore.dispose()) try {
|
|
212
|
+
var _globalApp$runFunctio3;
|
|
213
|
+
globalApp === null || globalApp === void 0 || (_globalApp$runFunctio3 = globalApp.runFunction) === null || _globalApp$runFunctio3 === void 0 || _globalApp$runFunctio3.call(globalApp, "closeAuthorization");
|
|
214
|
+
} catch (_unused2) {}
|
|
268
215
|
};
|
|
269
|
-
}, []);
|
|
216
|
+
}, [authorizationStore]);
|
|
270
217
|
(0, react.useEffect)(() => {
|
|
271
218
|
controllerRef.current = controller;
|
|
272
219
|
return () => {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const require_asyncToGenerator = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
const require_objectWithoutProperties = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
|
|
3
|
+
const require_constants = require("../../../../checkout/constants.js");
|
|
4
|
+
const require_pendingEftposLifecycle = require("../../../../checkout/paymentRuntime/pendingEftposLifecycle.js");
|
|
5
|
+
const require_utils = require("../../../../checkout/utils.js");
|
|
6
|
+
const require_normalize = require("../adapter/normalize.js");
|
|
7
|
+
//#region src/components/bigSale/templates/HDLKiosk/runtime/eftposPayment.ts
|
|
8
|
+
const _excluded = ["unique_payment_number"];
|
|
9
|
+
function checkoutSuccess(baseSales) {
|
|
10
|
+
var _baseSales$getTempOrd, _baseSales$getOrderId, _ref, _baseSales$getOrderAm, _baseSales$getOrderAm2;
|
|
11
|
+
const order = (baseSales === null || baseSales === void 0 || (_baseSales$getTempOrd = baseSales.getTempOrder) === null || _baseSales$getTempOrd === void 0 ? void 0 : _baseSales$getTempOrd.call(baseSales)) || {};
|
|
12
|
+
const orderId = ((baseSales === null || baseSales === void 0 || (_baseSales$getOrderId = baseSales.getOrderIdentity) === null || _baseSales$getOrderId === void 0 ? void 0 : _baseSales$getOrderId.call(baseSales)) || {}).orderId || order.order_id;
|
|
13
|
+
if (!orderId) return require_normalize.unknown("eftposSuccessMissingOrderId");
|
|
14
|
+
return {
|
|
15
|
+
status: "succeeded",
|
|
16
|
+
data: {
|
|
17
|
+
orderId: String(orderId),
|
|
18
|
+
amount: String((_ref = (_baseSales$getOrderAm = baseSales === null || baseSales === void 0 || (_baseSales$getOrderAm2 = baseSales.getOrderAmountSnapshot) === null || _baseSales$getOrderAm2 === void 0 || (_baseSales$getOrderAm2 = _baseSales$getOrderAm2.call(baseSales)) === null || _baseSales$getOrderAm2 === void 0 ? void 0 : _baseSales$getOrderAm2.expectAmount) !== null && _baseSales$getOrderAm !== void 0 ? _baseSales$getOrderAm : order.expect_amount) !== null && _ref !== void 0 ? _ref : 0)
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function executeEftposPayment(_x) {
|
|
23
|
+
return _executeEftposPayment.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
function _executeEftposPayment() {
|
|
26
|
+
_executeEftposPayment = require_asyncToGenerator._asyncToGenerator(function* ({ amount, baseSales, currencySymbol, interaction, isPiPaymentEnabled, loadDetail, method, rawMethod, runtime }) {
|
|
27
|
+
const piProvider = require_constants.resolvePiPaymentProvider(method.code, isPiPaymentEnabled);
|
|
28
|
+
let prepared;
|
|
29
|
+
let shouldDiscardPrepared = false;
|
|
30
|
+
try {
|
|
31
|
+
var _baseSales$getOrderId2, _baseSales$getTempOrd2;
|
|
32
|
+
if (piProvider) {
|
|
33
|
+
prepared = yield require_pendingEftposLifecycle.preparePendingEftposPayment({
|
|
34
|
+
amount,
|
|
35
|
+
baseSales,
|
|
36
|
+
method: rawMethod
|
|
37
|
+
});
|
|
38
|
+
shouldDiscardPrepared = true;
|
|
39
|
+
if (!prepared.salesId) throw new Error("Unable to resolve sales id before opening PiPayment.");
|
|
40
|
+
}
|
|
41
|
+
const deviceNumber = yield require_utils.getCurrentDeviceNumber(interaction);
|
|
42
|
+
const result = yield runtime.execute({
|
|
43
|
+
method: rawMethod,
|
|
44
|
+
amount,
|
|
45
|
+
currencySymbol,
|
|
46
|
+
deviceNumber,
|
|
47
|
+
preparedPayment: prepared ? {
|
|
48
|
+
paymentNumber: prepared.paymentNumber,
|
|
49
|
+
salesId: prepared.salesId
|
|
50
|
+
} : void 0
|
|
51
|
+
});
|
|
52
|
+
if (result.preservePendingPayment) shouldDiscardPrepared = false;
|
|
53
|
+
if (prepared && result.preservePendingPayment && result.status !== "success") return require_normalize.unknown("eftposPendingPaymentUnresolved", result);
|
|
54
|
+
if (result.status === "cancelled" || result.status === "provider-handled") {
|
|
55
|
+
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
56
|
+
return {
|
|
57
|
+
status: "cancelled",
|
|
58
|
+
reason: result.status
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (result.status === "cancel-order") {
|
|
62
|
+
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
63
|
+
return {
|
|
64
|
+
status: "cancelled",
|
|
65
|
+
reason: "cancelOrder"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (result.status !== "success") {
|
|
69
|
+
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
70
|
+
return require_normalize.failed("eftposPaymentFailed", "retry", result.message);
|
|
71
|
+
}
|
|
72
|
+
if (prepared) {
|
|
73
|
+
shouldDiscardPrepared = false;
|
|
74
|
+
const _ref2 = result.metadata || {}, { unique_payment_number: transactionNumber } = _ref2, metadata = require_objectWithoutProperties._objectWithoutProperties(_ref2, _excluded);
|
|
75
|
+
yield require_pendingEftposLifecycle.completePendingEftposPayment({
|
|
76
|
+
amount: result.amount,
|
|
77
|
+
baseSales,
|
|
78
|
+
paymentNumber: prepared.paymentNumber,
|
|
79
|
+
transactionNumber,
|
|
80
|
+
serviceCharge: result.serviceCharge,
|
|
81
|
+
updates: { metadata }
|
|
82
|
+
});
|
|
83
|
+
} else if (typeof (baseSales === null || baseSales === void 0 ? void 0 : baseSales.commitPaymentMethodPayment) === "function") yield baseSales.commitPaymentMethodPayment({
|
|
84
|
+
paymentMethodId: method.id,
|
|
85
|
+
paymentMethodCode: method.code,
|
|
86
|
+
amount: result.amount,
|
|
87
|
+
serviceCharge: result.serviceCharge,
|
|
88
|
+
metadata: result.metadata
|
|
89
|
+
});
|
|
90
|
+
else return require_normalize.failed("paymentCommitUnavailable", "staff");
|
|
91
|
+
const orderId = (baseSales === null || baseSales === void 0 || (_baseSales$getOrderId2 = baseSales.getOrderIdentity) === null || _baseSales$getOrderId2 === void 0 || (_baseSales$getOrderId2 = _baseSales$getOrderId2.call(baseSales)) === null || _baseSales$getOrderId2 === void 0 ? void 0 : _baseSales$getOrderId2.orderId) || (baseSales === null || baseSales === void 0 || (_baseSales$getTempOrd2 = baseSales.getTempOrder) === null || _baseSales$getTempOrd2 === void 0 || (_baseSales$getTempOrd2 = _baseSales$getTempOrd2.call(baseSales)) === null || _baseSales$getTempOrd2 === void 0 ? void 0 : _baseSales$getTempOrd2.order_id);
|
|
92
|
+
if (orderId && typeof loadDetail === "function") yield loadDetail({
|
|
93
|
+
orderId,
|
|
94
|
+
forceRemote: true
|
|
95
|
+
});
|
|
96
|
+
return checkoutSuccess(baseSales);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
try {
|
|
99
|
+
if (prepared && shouldDiscardPrepared) yield require_pendingEftposLifecycle.discardPendingEftposPayment(baseSales, prepared.paymentNumber);
|
|
100
|
+
} catch (discardError) {
|
|
101
|
+
return require_normalize.unknown("eftposPendingRollbackFailed", discardError);
|
|
102
|
+
}
|
|
103
|
+
if (prepared && !shouldDiscardPrepared) return require_normalize.unknown("eftposPaymentFinalizationUnresolved", error);
|
|
104
|
+
return require_normalize.failed("eftposPaymentFailed", "retry", error);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return _executeEftposPayment.apply(this, arguments);
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
exports.executeEftposPayment = executeEftposPayment;
|