@pisell/private-materials 6.6.61 → 6.6.63
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/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +9 -9
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +9 -9
- package/es/components/booking/components/footer/amount.js +4 -3
- package/es/components/booking/components/footer/utils.js +10 -3
- package/es/components/booking/components/voucher/index.js +1 -1
- package/es/components/booking/info2/service/editService/index.js +76 -8
- package/es/components/booking/info2/service/editService/utils.d.ts +1 -0
- package/es/components/booking/info2/service/editService/utils.js +16 -0
- package/es/components/booking/payments/index.js +1 -1
- package/es/components/eftpos/PairModal/hooks.d.ts +27 -0
- package/es/components/eftpos/PairModal/hooks.js +67 -0
- package/es/components/eftpos/PairModal/index.d.ts +11 -0
- package/es/components/eftpos/PairModal/index.js +246 -0
- package/es/components/eftpos/PairModal/index.less +70 -0
- package/es/components/eftpos/SettlementModal/Action.d.ts +7 -0
- package/es/components/eftpos/SettlementModal/Action.js +141 -0
- package/es/components/eftpos/SettlementModal/index.d.ts +7 -0
- package/es/components/eftpos/SettlementModal/index.js +135 -0
- package/es/components/eftpos/SettlementModal/index.less +33 -0
- package/es/components/eftpos/SettlementModal/serve.d.ts +8 -0
- package/es/components/eftpos/SettlementModal/serve.js +171 -0
- package/es/components/eftpos/SettlementModal/types.d.ts +138 -0
- package/es/components/eftpos/SettlementModal/types.js +35 -0
- package/es/components/eftpos/SettlementModal/utils.d.ts +18 -0
- package/es/components/eftpos/SettlementModal/utils.js +351 -0
- package/es/components/eftpos/assets/mx51SCI.svg +15 -0
- package/es/components/eftpos/const.d.ts +3 -1
- package/es/components/eftpos/const.js +2 -0
- package/es/components/eftpos/device.d.ts +3 -1
- package/es/components/eftpos/device.js +14 -3
- package/es/components/eftpos/hooks.d.ts +13 -0
- package/es/components/eftpos/hooks.js +35 -0
- package/es/components/eftpos/index.js +198 -24
- package/es/components/eftpos/index.less +32 -1
- package/es/components/eftpos/locales.d.ts +80 -0
- package/es/components/eftpos/locales.js +205 -25
- package/es/components/eftpos/table.js +47 -3
- package/es/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
- package/es/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
- package/es/components/eftposPay/aggregatePayment/hooks/usePayment.js +145 -0
- package/es/components/eftposPay/aggregatePayment/index.d.ts +2 -1
- package/es/components/eftposPay/aggregatePayment/index.js +2 -1
- package/es/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
- package/es/components/eftposPay/aggregatePayment/mock.js +567 -0
- package/es/components/eftposPay/aggregatePayment/service.js +1 -0
- package/es/components/eftposPay/aggregatePayment/types.d.ts +12 -12
- package/es/components/eftposPay/aggregatePayment/types.js +4 -8
- package/es/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
- package/es/components/eftposPay/aggregatePayment/utils/payment.js +231 -168
- package/es/components/eftposPay/amount.js +15 -1
- package/es/components/eftposPay/app.js +2 -3
- package/es/components/eftposPay/component/fail/failCustom.js +13 -4
- package/es/components/eftposPay/component/fail/index.js +12 -5
- package/es/components/eftposPay/component/fail/network.js +3 -0
- package/es/components/eftposPay/component/fail/unknow.js +8 -0
- package/es/components/eftposPay/component/manual/index.js +17 -3
- package/es/components/eftposPay/component/signature/index.js +3 -0
- package/es/components/eftposPay/const.d.ts +8 -3
- package/es/components/eftposPay/const.js +2 -0
- package/es/components/eftposPay/device.js +225 -38
- package/es/components/eftposPay/helper.d.ts +3 -0
- package/es/components/eftposPay/helper.js +2 -1
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/index.js +50 -13
- package/es/components/eftposPay/linkly/const.js +1 -1
- package/es/components/eftposPay/linkly/hooks/normal.js +21 -68
- package/es/components/eftposPay/linkly/hooks/useTimeQuery.js +20 -81
- package/es/components/eftposPay/linkly/index.js +11 -23
- package/es/components/eftposPay/locales.d.ts +15 -0
- package/es/components/eftposPay/locales.js +30 -15
- package/es/components/eftposPay/manufacturer.d.ts +1 -0
- package/es/components/eftposPay/manufacturer.js +4 -0
- package/es/components/eftposPay/mx51/Action.d.ts +6 -0
- package/es/components/eftposPay/mx51/Action.js +144 -0
- package/es/components/eftposPay/mx51/const.d.ts +5 -0
- package/es/components/eftposPay/mx51/const.js +69 -0
- package/es/components/eftposPay/mx51/index.d.ts +6 -0
- package/es/components/eftposPay/mx51/index.js +498 -0
- package/es/components/eftposPay/mx51/types.d.ts +142 -0
- package/es/components/eftposPay/mx51/types.js +35 -0
- package/es/components/eftposPay/mx51/utils.d.ts +10 -0
- package/es/components/eftposPay/mx51/utils.js +121 -0
- package/es/components/eftposPay/pay.js +21 -9
- package/es/components/eftposPay/payo/config.js +39 -5
- package/es/components/eftposPay/payo/const.js +1 -1
- package/es/components/eftposPay/payo/hooks.js +3 -12
- package/es/components/eftposPay/payo/payment.js +69 -136
- package/es/components/eftposPay/store/index.d.ts +5 -9
- package/es/components/eftposPay/tip.js +5 -0
- package/es/components/eftposPay/tyro/const.js +1 -1
- package/es/components/eftposPay/tyro/index.js +44 -11
- package/es/components/eftposPay/utils/payLog.d.ts +81 -0
- package/es/components/eftposPay/utils/payLog.js +458 -0
- package/es/components/eftposPay/windcave/const.js +1 -1
- package/es/components/eftposPay/windcave/receiptAction.js +5 -0
- package/es/components/eftposPay/windcave/windcave.js +37 -38
- package/es/components/ticketBooking/utils/formatProductMessage.js +47 -2
- package/lib/components/booking/components/footer/amount.js +3 -3
- package/lib/components/booking/components/footer/utils.js +12 -5
- package/lib/components/booking/components/voucher/index.js +1 -1
- package/lib/components/booking/info2/service/editService/index.js +56 -5
- package/lib/components/booking/info2/service/editService/utils.d.ts +1 -0
- package/lib/components/booking/info2/service/editService/utils.js +16 -0
- package/lib/components/booking/payments/index.js +1 -1
- package/lib/components/eftpos/PairModal/hooks.d.ts +27 -0
- package/lib/components/eftpos/PairModal/hooks.js +70 -0
- package/lib/components/eftpos/PairModal/index.d.ts +11 -0
- package/lib/components/eftpos/PairModal/index.js +197 -0
- package/lib/components/eftpos/PairModal/index.less +70 -0
- package/lib/components/eftpos/SettlementModal/Action.d.ts +7 -0
- package/lib/components/eftpos/SettlementModal/Action.js +153 -0
- package/lib/components/eftpos/SettlementModal/index.d.ts +7 -0
- package/lib/components/eftpos/SettlementModal/index.js +170 -0
- package/lib/components/eftpos/SettlementModal/index.less +33 -0
- package/lib/components/eftpos/SettlementModal/serve.d.ts +8 -0
- package/lib/components/eftpos/SettlementModal/serve.js +45 -0
- package/lib/components/eftpos/SettlementModal/types.d.ts +138 -0
- package/lib/components/eftpos/SettlementModal/types.js +43 -0
- package/lib/components/eftpos/SettlementModal/utils.d.ts +18 -0
- package/lib/components/eftpos/SettlementModal/utils.js +248 -0
- package/lib/components/eftpos/assets/mx51SCI.svg +15 -0
- package/lib/components/eftpos/const.d.ts +3 -1
- package/lib/components/eftpos/const.js +2 -0
- package/lib/components/eftpos/device.d.ts +3 -1
- package/lib/components/eftpos/device.js +13 -3
- package/lib/components/eftpos/hooks.d.ts +13 -0
- package/lib/components/eftpos/hooks.js +30 -0
- package/lib/components/eftpos/index.js +121 -8
- package/lib/components/eftpos/index.less +32 -1
- package/lib/components/eftpos/locales.d.ts +80 -0
- package/lib/components/eftpos/locales.js +231 -21
- package/lib/components/eftpos/table.js +30 -2
- package/lib/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
- package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
- package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.js +171 -0
- package/lib/components/eftposPay/aggregatePayment/index.d.ts +2 -1
- package/lib/components/eftposPay/aggregatePayment/index.js +5 -2
- package/lib/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
- package/lib/components/eftposPay/aggregatePayment/mock.js +679 -0
- package/lib/components/eftposPay/aggregatePayment/types.d.ts +12 -12
- package/lib/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
- package/lib/components/eftposPay/aggregatePayment/utils/payment.js +173 -123
- package/lib/components/eftposPay/amount.js +13 -1
- package/lib/components/eftposPay/app.js +4 -5
- package/lib/components/eftposPay/component/fail/failCustom.js +10 -2
- package/lib/components/eftposPay/component/fail/index.js +10 -2
- package/lib/components/eftposPay/component/fail/network.js +3 -0
- package/lib/components/eftposPay/component/fail/unknow.js +8 -0
- package/lib/components/eftposPay/component/manual/index.js +16 -2
- package/lib/components/eftposPay/component/signature/index.js +3 -0
- package/lib/components/eftposPay/const.d.ts +8 -3
- package/lib/components/eftposPay/const.js +2 -0
- package/lib/components/eftposPay/device.js +114 -25
- package/lib/components/eftposPay/helper.d.ts +3 -0
- package/lib/components/eftposPay/helper.js +2 -1
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/index.js +38 -13
- package/lib/components/eftposPay/linkly/const.js +1 -1
- package/lib/components/eftposPay/linkly/hooks/normal.js +22 -43
- package/lib/components/eftposPay/linkly/hooks/useTimeQuery.js +13 -65
- package/lib/components/eftposPay/linkly/index.js +8 -10
- package/lib/components/eftposPay/locales.d.ts +15 -0
- package/lib/components/eftposPay/locales.js +30 -15
- package/lib/components/eftposPay/manufacturer.d.ts +1 -0
- package/lib/components/eftposPay/manufacturer.js +6 -0
- package/lib/components/eftposPay/mx51/Action.d.ts +6 -0
- package/lib/components/eftposPay/mx51/Action.js +154 -0
- package/lib/components/eftposPay/mx51/const.d.ts +5 -0
- package/lib/components/eftposPay/mx51/const.js +85 -0
- package/lib/components/eftposPay/mx51/index.d.ts +6 -0
- package/lib/components/eftposPay/mx51/index.js +433 -0
- package/lib/components/eftposPay/mx51/types.d.ts +142 -0
- package/lib/components/eftposPay/mx51/types.js +43 -0
- package/lib/components/eftposPay/mx51/utils.d.ts +10 -0
- package/lib/components/eftposPay/mx51/utils.js +115 -0
- package/lib/components/eftposPay/pay.js +13 -3
- package/lib/components/eftposPay/payo/config.js +16 -8
- package/lib/components/eftposPay/payo/const.js +1 -1
- package/lib/components/eftposPay/payo/hooks.js +12 -10
- package/lib/components/eftposPay/payo/payment.js +31 -65
- package/lib/components/eftposPay/store/index.d.ts +5 -9
- package/lib/components/eftposPay/tip.js +5 -0
- package/lib/components/eftposPay/tyro/const.js +1 -1
- package/lib/components/eftposPay/tyro/index.js +21 -17
- package/lib/components/eftposPay/utils/payLog.d.ts +81 -0
- package/lib/components/eftposPay/utils/payLog.js +321 -0
- package/lib/components/eftposPay/windcave/const.js +1 -1
- package/lib/components/eftposPay/windcave/receiptAction.js +5 -0
- package/lib/components/eftposPay/windcave/windcave.js +27 -29
- package/lib/components/ticketBooking/utils/formatProductMessage.js +44 -2
- package/package.json +4 -4
- package/es/components/eftposPay/utils/log/index.d.ts +0 -110
- package/es/components/eftposPay/utils/log/index.js +0 -371
- package/lib/components/eftposPay/utils/log/index.d.ts +0 -110
- package/lib/components/eftposPay/utils/log/index.js +0 -294
|
@@ -32,11 +32,30 @@ __export(payment_exports, {
|
|
|
32
32
|
default: () => payment_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(payment_exports);
|
|
35
|
+
var import_utils = require("@pisell/utils");
|
|
35
36
|
var import_const = require("../../const");
|
|
36
|
-
var
|
|
37
|
+
var import_payLog = __toESM(require("../../utils/payLog"));
|
|
37
38
|
var import_service = require("../service");
|
|
38
39
|
var import_helper = require("../../helper");
|
|
39
40
|
var import_types = require("../types");
|
|
41
|
+
var sanitizePaymentLogContent = (content) => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
if (!content || typeof content !== "object") {
|
|
44
|
+
return content;
|
|
45
|
+
}
|
|
46
|
+
if (!((_b = (_a = content.params) == null ? void 0 : _a.eftpos) == null ? void 0 : _b.pay_param_base64)) {
|
|
47
|
+
return content;
|
|
48
|
+
}
|
|
49
|
+
const clonedContent = (0, import_helper.cloneDeep)(content);
|
|
50
|
+
delete clonedContent.params.eftpos.pay_param_base64;
|
|
51
|
+
return clonedContent;
|
|
52
|
+
};
|
|
53
|
+
var addPaymentLog = ({ title, content }) => {
|
|
54
|
+
import_payLog.default.log(title, sanitizePaymentLogContent(content));
|
|
55
|
+
};
|
|
56
|
+
var paymentLog = {
|
|
57
|
+
addLog: addPaymentLog
|
|
58
|
+
};
|
|
40
59
|
var PaymentMethod = class {
|
|
41
60
|
/** 初始化参数 */
|
|
42
61
|
initOptions;
|
|
@@ -44,8 +63,6 @@ var PaymentMethod = class {
|
|
|
44
63
|
paymentNum;
|
|
45
64
|
// 订单ID
|
|
46
65
|
orderId;
|
|
47
|
-
// 设备ID
|
|
48
|
-
deviceId;
|
|
49
66
|
// 统一回调函数
|
|
50
67
|
callback;
|
|
51
68
|
// 检查是否应该继续处理结果
|
|
@@ -80,14 +97,19 @@ var PaymentMethod = class {
|
|
|
80
97
|
this.initOptions = options;
|
|
81
98
|
this.paymentNum = options.paymentNum;
|
|
82
99
|
this.orderId = options.orderId;
|
|
83
|
-
this.deviceId = options.deviceId;
|
|
84
100
|
this.callback = options.callback;
|
|
85
101
|
this.shouldContinue = options.shouldContinue || (() => true);
|
|
86
102
|
this.config = options.config || {};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
import_payLog.default.setContext({
|
|
104
|
+
transactionNumber: this.paymentNum,
|
|
105
|
+
extra: { paymentCode: (options == null ? void 0 : options.paymentCode) || "" }
|
|
106
|
+
});
|
|
107
|
+
addPaymentLog({
|
|
108
|
+
title: "聚合支付初始化",
|
|
109
|
+
content: {
|
|
110
|
+
paymentNum: this.paymentNum,
|
|
111
|
+
paymentCode: (options == null ? void 0 : options.paymentCode) || ""
|
|
112
|
+
}
|
|
91
113
|
});
|
|
92
114
|
}
|
|
93
115
|
/**
|
|
@@ -95,8 +117,24 @@ var PaymentMethod = class {
|
|
|
95
117
|
* 1. 有明确错误code且不是超时和支付超时,则直接失败
|
|
96
118
|
* @param code 错误码
|
|
97
119
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
isBusinessFailed(res) {
|
|
121
|
+
var _a;
|
|
122
|
+
const { external_unified_status, response_code } = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.external_unified_response) || {};
|
|
123
|
+
return `${res == null ? void 0 : res.code}` === "200" && external_unified_status === import_types.EPaymentStatus.Failed && response_code !== import_const.PayStatus.Timeout && response_code !== import_const.PayStatus.PayTimeout;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 判断业务是否成功
|
|
127
|
+
*/
|
|
128
|
+
isBusinessSuccess(res) {
|
|
129
|
+
var _a;
|
|
130
|
+
const { external_unified_status } = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.external_unified_response) || {};
|
|
131
|
+
return `${res == null ? void 0 : res.code}` === "200" && external_unified_status === import_types.EPaymentStatus.Success;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 判断最外层code是否是超时错误
|
|
135
|
+
*/
|
|
136
|
+
isOuterCodeTimeout(code) {
|
|
137
|
+
return code && (`${code}` === import_const.PayStatus.Timeout || `${code}` === import_const.PayStatus.PayTimeout);
|
|
100
138
|
}
|
|
101
139
|
/**
|
|
102
140
|
* 清理定时器和请求控制器
|
|
@@ -147,7 +185,7 @@ var PaymentMethod = class {
|
|
|
147
185
|
startNewOperation(actionType) {
|
|
148
186
|
const runId = (0, import_helper.getUuid)();
|
|
149
187
|
this.currentRunId = runId;
|
|
150
|
-
|
|
188
|
+
paymentLog.addLog({
|
|
151
189
|
title: `触发新的操作:${actionType}`,
|
|
152
190
|
content: { actionType, runId }
|
|
153
191
|
});
|
|
@@ -171,7 +209,7 @@ var PaymentMethod = class {
|
|
|
171
209
|
});
|
|
172
210
|
} catch (error) {
|
|
173
211
|
console.error("⚠️ 回调执行出错:", error);
|
|
174
|
-
|
|
212
|
+
paymentLog.addLog({ title: "回调执行出错", content: error });
|
|
175
213
|
}
|
|
176
214
|
}
|
|
177
215
|
/**
|
|
@@ -179,14 +217,14 @@ var PaymentMethod = class {
|
|
|
179
217
|
*/
|
|
180
218
|
handleOperationSuccess(res) {
|
|
181
219
|
if (this.isFinished || !this.shouldContinue() || !this.currentActionType) {
|
|
182
|
-
|
|
220
|
+
paymentLog.addLog({
|
|
183
221
|
title: "操作结果:已完成或不应继续处理,忽略操作成功结果",
|
|
184
222
|
content: { actionType: this.currentActionType, res }
|
|
185
223
|
});
|
|
186
224
|
return;
|
|
187
225
|
}
|
|
188
226
|
const actionType = this.currentActionType;
|
|
189
|
-
|
|
227
|
+
paymentLog.addLog({
|
|
190
228
|
title: "操作结果:成功",
|
|
191
229
|
content: { actionType, res }
|
|
192
230
|
});
|
|
@@ -199,7 +237,7 @@ var PaymentMethod = class {
|
|
|
199
237
|
});
|
|
200
238
|
} catch (error) {
|
|
201
239
|
console.error("⚠️ 回调执行出错:", error);
|
|
202
|
-
|
|
240
|
+
paymentLog.addLog({ title: "回调执行出错", content: error });
|
|
203
241
|
}
|
|
204
242
|
}
|
|
205
243
|
/**
|
|
@@ -212,7 +250,7 @@ var PaymentMethod = class {
|
|
|
212
250
|
return;
|
|
213
251
|
}
|
|
214
252
|
const actionType = this.currentActionType;
|
|
215
|
-
|
|
253
|
+
paymentLog.addLog({
|
|
216
254
|
title: "操作结果:失败",
|
|
217
255
|
content: { actionType, error }
|
|
218
256
|
});
|
|
@@ -225,7 +263,7 @@ var PaymentMethod = class {
|
|
|
225
263
|
});
|
|
226
264
|
} catch (err) {
|
|
227
265
|
console.error("⚠️ 回调执行出错:", err);
|
|
228
|
-
|
|
266
|
+
paymentLog.addLog({ title: "回调执行出错", content: err });
|
|
229
267
|
}
|
|
230
268
|
}
|
|
231
269
|
/**
|
|
@@ -275,13 +313,13 @@ var PaymentMethod = class {
|
|
|
275
313
|
async performQuery(actionType) {
|
|
276
314
|
var _a, _b;
|
|
277
315
|
if (this.isFinished || !this.shouldContinue()) {
|
|
278
|
-
|
|
316
|
+
paymentLog.addLog({
|
|
279
317
|
title: "查询前置校验:已完成或不应继续处理,取消查询"
|
|
280
318
|
});
|
|
281
319
|
return;
|
|
282
320
|
}
|
|
283
321
|
if (!this.currentQueryApi) {
|
|
284
|
-
|
|
322
|
+
paymentLog.addLog({ title: "查询API未设置,取消查询" });
|
|
285
323
|
return;
|
|
286
324
|
}
|
|
287
325
|
if (this.queryController) {
|
|
@@ -296,7 +334,7 @@ var PaymentMethod = class {
|
|
|
296
334
|
this.currentQueryId = queryId;
|
|
297
335
|
this.queryController = new AbortController();
|
|
298
336
|
const { signal } = this.queryController;
|
|
299
|
-
|
|
337
|
+
paymentLog.addLog({ title: "查询轮询:开始单次查询" });
|
|
300
338
|
try {
|
|
301
339
|
const res = await Promise.race([
|
|
302
340
|
this.currentQueryApi(
|
|
@@ -305,13 +343,14 @@ var PaymentMethod = class {
|
|
|
305
343
|
unique_payment_number: this.paymentNum,
|
|
306
344
|
payment_code: (_a = this.initOptions) == null ? void 0 : _a.paymentCode,
|
|
307
345
|
request_version: queryId,
|
|
308
|
-
|
|
346
|
+
// TODO: MX51审核需要,后续需要删除
|
|
347
|
+
is_force_request_api: 1
|
|
309
348
|
},
|
|
310
349
|
{ signal }
|
|
311
350
|
),
|
|
312
351
|
this.createTimeoutPromise(import_types.REQUEST_TIMEOUT)
|
|
313
352
|
]);
|
|
314
|
-
|
|
353
|
+
paymentLog.addLog({
|
|
315
354
|
title: "查询轮询:单次查询返回",
|
|
316
355
|
content: { actionType, res }
|
|
317
356
|
});
|
|
@@ -320,32 +359,38 @@ var PaymentMethod = class {
|
|
|
320
359
|
this.requestTimeoutTimer = null;
|
|
321
360
|
}
|
|
322
361
|
if (((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.request_version) !== this.currentQueryId) {
|
|
323
|
-
|
|
362
|
+
paymentLog.addLog({ title: "查询轮询结果:过期的查询响应,忽略" });
|
|
324
363
|
return;
|
|
325
364
|
}
|
|
326
365
|
if (this.isFinished || !this.shouldContinue()) {
|
|
327
|
-
|
|
366
|
+
paymentLog.addLog({ title: "查询轮询结果:已完成或不应继续处理" });
|
|
328
367
|
return;
|
|
329
368
|
}
|
|
330
|
-
if (res
|
|
331
|
-
|
|
369
|
+
if (`${res == null ? void 0 : res.code}` !== "200") {
|
|
370
|
+
paymentLog.addLog({ title: "查询轮询结果:查询返回失败,code非200" });
|
|
371
|
+
this.handleOperationError(res);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (this.isBusinessSuccess(res)) {
|
|
375
|
+
paymentLog.addLog({ title: "查询轮询结果:查询成功" });
|
|
332
376
|
const needContinue = this.handleResponse(res);
|
|
333
377
|
if (needContinue) {
|
|
334
378
|
this.scheduleNextQuery(actionType);
|
|
335
379
|
}
|
|
336
380
|
return;
|
|
337
381
|
}
|
|
338
|
-
if (this.
|
|
339
|
-
|
|
382
|
+
if (this.isBusinessFailed(res)) {
|
|
383
|
+
paymentLog.addLog({
|
|
340
384
|
title: "查询轮询结果:有明确错误code,停止轮询",
|
|
341
385
|
content: res
|
|
342
386
|
});
|
|
343
387
|
this.handleOperationError(res);
|
|
344
388
|
} else {
|
|
345
|
-
|
|
346
|
-
title: "
|
|
389
|
+
paymentLog.addLog({
|
|
390
|
+
title: "查询轮询结果:交易进行中,继续轮询",
|
|
347
391
|
content: res
|
|
348
392
|
});
|
|
393
|
+
this.handleOperationProcess(res);
|
|
349
394
|
this.scheduleNextQuery(actionType);
|
|
350
395
|
}
|
|
351
396
|
} catch (error) {
|
|
@@ -354,7 +399,7 @@ var PaymentMethod = class {
|
|
|
354
399
|
this.requestTimeoutTimer = null;
|
|
355
400
|
}
|
|
356
401
|
if (queryId !== this.currentQueryId) {
|
|
357
|
-
|
|
402
|
+
paymentLog.addLog({
|
|
358
403
|
title: "查询轮询结果:error-过期的查询异常,忽略"
|
|
359
404
|
});
|
|
360
405
|
return;
|
|
@@ -363,24 +408,25 @@ var PaymentMethod = class {
|
|
|
363
408
|
return;
|
|
364
409
|
}
|
|
365
410
|
if ((error == null ? void 0 : error.name) === "AbortError" || (error == null ? void 0 : error.message) === "REQUEST_TIMEOUT") {
|
|
366
|
-
|
|
411
|
+
paymentLog.addLog({
|
|
367
412
|
title: "查询轮询结果:error-请求被取消或超时,继续轮询"
|
|
368
413
|
});
|
|
369
414
|
this.scheduleNextQuery(actionType);
|
|
370
415
|
return;
|
|
371
416
|
}
|
|
372
|
-
if (this.
|
|
373
|
-
|
|
374
|
-
title: "查询轮询结果:error
|
|
417
|
+
if (this.isOuterCodeTimeout(error == null ? void 0 : error.code)) {
|
|
418
|
+
paymentLog.addLog({
|
|
419
|
+
title: "查询轮询结果:error-code是超时错误,继续轮询",
|
|
375
420
|
content: error
|
|
376
421
|
});
|
|
377
|
-
this.
|
|
422
|
+
this.scheduleNextQuery(actionType);
|
|
423
|
+
return;
|
|
378
424
|
} else {
|
|
379
|
-
|
|
380
|
-
title: "查询轮询结果:error
|
|
425
|
+
paymentLog.addLog({
|
|
426
|
+
title: "查询轮询结果:error-有明确错误code,停止轮询",
|
|
381
427
|
content: error
|
|
382
428
|
});
|
|
383
|
-
this.
|
|
429
|
+
this.handleOperationError(error);
|
|
384
430
|
}
|
|
385
431
|
}
|
|
386
432
|
}
|
|
@@ -396,14 +442,14 @@ var PaymentMethod = class {
|
|
|
396
442
|
clearTimeout(this.queryIntervalTimer);
|
|
397
443
|
}
|
|
398
444
|
if (((_a = this.config) == null ? void 0 : _a.hasQueryInterval) === false) {
|
|
399
|
-
|
|
445
|
+
paymentLog.addLog({
|
|
400
446
|
title: "查询轮询:立即安排下一次查询",
|
|
401
447
|
content: { actionType }
|
|
402
448
|
});
|
|
403
449
|
this.performQuery(actionType);
|
|
404
450
|
} else {
|
|
405
451
|
this.queryIntervalTimer = setTimeout(() => {
|
|
406
|
-
|
|
452
|
+
paymentLog.addLog({
|
|
407
453
|
title: "查询轮询:安排下一次查询",
|
|
408
454
|
content: { actionType }
|
|
409
455
|
});
|
|
@@ -415,24 +461,33 @@ var PaymentMethod = class {
|
|
|
415
461
|
* 开始轮询
|
|
416
462
|
*/
|
|
417
463
|
startQuery(actionType) {
|
|
464
|
+
var _a;
|
|
418
465
|
if (this.isFinished || !this.shouldContinue() || this.isQuerying) {
|
|
419
466
|
return;
|
|
420
467
|
}
|
|
421
468
|
this.isQuerying = true;
|
|
422
|
-
|
|
469
|
+
paymentLog.addLog({ title: "开始轮询", content: { actionType } });
|
|
470
|
+
const _globalQueryTimeout = ((_a = this.config) == null ? void 0 : _a.globalQueryTimeout) || import_types.GLOBAL_TIMEOUT;
|
|
423
471
|
this.globalTimeoutTimer = setTimeout(() => {
|
|
472
|
+
var _a2;
|
|
424
473
|
if (this.isFinished) {
|
|
425
474
|
return;
|
|
426
475
|
}
|
|
427
|
-
|
|
428
|
-
title:
|
|
476
|
+
paymentLog.addLog({
|
|
477
|
+
title: `轮询全局超时(${_globalQueryTimeout / 1e3}秒),终止所有请求`,
|
|
429
478
|
content: { actionType }
|
|
430
479
|
});
|
|
431
480
|
this.handleOperationError({
|
|
432
|
-
code:
|
|
433
|
-
|
|
481
|
+
code: "200",
|
|
482
|
+
data: {
|
|
483
|
+
external_unified_response: {
|
|
484
|
+
external_unified_status: import_types.EPaymentStatus.Failed,
|
|
485
|
+
response_code: import_const.PayStatus.Timeout,
|
|
486
|
+
message: ((_a2 = import_utils.locales) == null ? void 0 : _a2.getText("page.eftpos-pay.text.transaction.fail.timeout")) || "Transaction timeout."
|
|
487
|
+
}
|
|
488
|
+
}
|
|
434
489
|
});
|
|
435
|
-
},
|
|
490
|
+
}, _globalQueryTimeout);
|
|
436
491
|
this.performQuery(actionType);
|
|
437
492
|
}
|
|
438
493
|
/**
|
|
@@ -480,7 +535,7 @@ var PaymentMethod = class {
|
|
|
480
535
|
return;
|
|
481
536
|
}
|
|
482
537
|
this.currentQueryApi = queryApi;
|
|
483
|
-
|
|
538
|
+
paymentLog.addLog({ title: `开始${actionType}查询轮询` });
|
|
484
539
|
this.startQuery(actionType);
|
|
485
540
|
}
|
|
486
541
|
/**
|
|
@@ -488,15 +543,12 @@ var PaymentMethod = class {
|
|
|
488
543
|
*/
|
|
489
544
|
async run(runOptions) {
|
|
490
545
|
var _a;
|
|
491
|
-
const { actionType, params } = runOptions;
|
|
546
|
+
const { actionType, params, config } = runOptions;
|
|
492
547
|
const runId = this.startNewOperation(actionType);
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
content: { params: otherParams }
|
|
498
|
-
});
|
|
499
|
-
}
|
|
548
|
+
paymentLog.addLog({
|
|
549
|
+
title: "请求参数",
|
|
550
|
+
content: { params }
|
|
551
|
+
});
|
|
500
552
|
const { actionApi, queryApi } = this.getActionApi(actionType);
|
|
501
553
|
if (!actionApi) {
|
|
502
554
|
const error = new Error(`${actionType}接口不存在`);
|
|
@@ -506,7 +558,7 @@ var PaymentMethod = class {
|
|
|
506
558
|
this.currentQueryApi = queryApi;
|
|
507
559
|
if (queryApi !== null) {
|
|
508
560
|
this.queryStartTimer = setTimeout(() => {
|
|
509
|
-
|
|
561
|
+
paymentLog.addLog({
|
|
510
562
|
title: "操作后10秒开始轮询",
|
|
511
563
|
content: { actionType }
|
|
512
564
|
});
|
|
@@ -515,89 +567,83 @@ var PaymentMethod = class {
|
|
|
515
567
|
}
|
|
516
568
|
this.controller = new AbortController();
|
|
517
569
|
const { signal } = this.controller;
|
|
570
|
+
const _query = (_status, _title, _content) => {
|
|
571
|
+
paymentLog.addLog({ title: _title, content: _content });
|
|
572
|
+
if (this.queryStartTimer) {
|
|
573
|
+
clearTimeout(this.queryStartTimer);
|
|
574
|
+
this.queryStartTimer = null;
|
|
575
|
+
}
|
|
576
|
+
this.startQuery(actionType);
|
|
577
|
+
};
|
|
518
578
|
try {
|
|
519
|
-
|
|
579
|
+
paymentLog.addLog({
|
|
520
580
|
title: `发起${actionType}请求`,
|
|
521
581
|
content: { actionType, params }
|
|
522
582
|
});
|
|
523
583
|
const res = await actionApi(
|
|
524
|
-
{ ...params, request_version: runId
|
|
584
|
+
{ ...params, request_version: runId },
|
|
525
585
|
{ signal }
|
|
526
586
|
);
|
|
527
|
-
|
|
587
|
+
paymentLog.addLog({
|
|
528
588
|
title: "请求返回",
|
|
529
589
|
content: { params, actionType, res }
|
|
530
590
|
});
|
|
531
591
|
if (runId != ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.request_version)) {
|
|
532
|
-
|
|
592
|
+
paymentLog.addLog({ title: "响应过期,忽略", content: { actionType } });
|
|
533
593
|
return;
|
|
534
594
|
}
|
|
535
595
|
if (this.isFinished || !this.shouldContinue()) {
|
|
536
|
-
|
|
596
|
+
paymentLog.addLog({
|
|
537
597
|
title: "返回时已完成或不应继续处理",
|
|
538
598
|
content: { actionType }
|
|
539
599
|
});
|
|
540
600
|
return;
|
|
541
601
|
}
|
|
542
|
-
if (res
|
|
543
|
-
|
|
602
|
+
if (`${res == null ? void 0 : res.code}` !== "200") {
|
|
603
|
+
paymentLog.addLog({ title: `${actionType}接口返回失败,code非200` });
|
|
604
|
+
this.handleOperationError(res);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (this.isBusinessSuccess(res)) {
|
|
608
|
+
paymentLog.addLog({
|
|
544
609
|
title: `${actionType}接口成功`,
|
|
545
610
|
content: { actionType, res }
|
|
546
611
|
});
|
|
547
612
|
const needContinue = this.handleResponse(res);
|
|
548
613
|
if (needContinue) {
|
|
549
|
-
|
|
550
|
-
title: `${actionType}接口返回processing,开始轮询`
|
|
551
|
-
});
|
|
552
|
-
if (this.queryStartTimer) {
|
|
553
|
-
clearTimeout(this.queryStartTimer);
|
|
554
|
-
this.queryStartTimer = null;
|
|
555
|
-
}
|
|
556
|
-
this.startQuery(actionType);
|
|
614
|
+
_query("success", `${actionType}接口返回processing,开始轮询`);
|
|
557
615
|
}
|
|
558
616
|
return;
|
|
559
617
|
}
|
|
560
|
-
if (this.
|
|
561
|
-
|
|
618
|
+
if (this.isBusinessFailed(res)) {
|
|
619
|
+
paymentLog.addLog({
|
|
562
620
|
title: `${actionType}接口返回失败`,
|
|
563
621
|
content: { actionType, res }
|
|
564
622
|
});
|
|
565
623
|
this.handleOperationError(res);
|
|
566
624
|
} else {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
625
|
+
this.handleOperationProcess(res);
|
|
626
|
+
_query("failed", `${actionType}超时或无明确错误,开始轮询`, {
|
|
627
|
+
actionType,
|
|
628
|
+
res
|
|
570
629
|
});
|
|
571
|
-
if (this.queryStartTimer) {
|
|
572
|
-
clearTimeout(this.queryStartTimer);
|
|
573
|
-
this.queryStartTimer = null;
|
|
574
|
-
}
|
|
575
|
-
this.startQuery(actionType);
|
|
576
630
|
}
|
|
577
631
|
} catch (error) {
|
|
578
632
|
if (runId !== this.currentRunId) {
|
|
579
|
-
|
|
633
|
+
paymentLog.addLog({ title: "响应过期,忽略", content: { actionType } });
|
|
580
634
|
return;
|
|
581
635
|
}
|
|
582
636
|
if (this.isFinished || !this.shouldContinue()) {
|
|
583
|
-
|
|
637
|
+
paymentLog.addLog({
|
|
584
638
|
title: "异常时已完成或不应继续处理",
|
|
585
639
|
content: { actionType }
|
|
586
640
|
});
|
|
587
641
|
return;
|
|
588
642
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
});
|
|
594
|
-
this.handleOperationError(error);
|
|
595
|
-
} else {
|
|
596
|
-
import_logs.default.addLog({
|
|
597
|
-
title: `${actionType}超时或无明确错误,等待轮询结果`,
|
|
598
|
-
content: { actionType, error }
|
|
599
|
-
});
|
|
600
|
-
}
|
|
643
|
+
_query("failed", `${actionType}接口异常,开始轮询`, {
|
|
644
|
+
actionType,
|
|
645
|
+
error
|
|
646
|
+
});
|
|
601
647
|
}
|
|
602
648
|
}
|
|
603
649
|
/**
|
|
@@ -605,15 +651,13 @@ var PaymentMethod = class {
|
|
|
605
651
|
*/
|
|
606
652
|
async runAction(actionOptions) {
|
|
607
653
|
var _a;
|
|
608
|
-
const { actionType, params } = actionOptions;
|
|
654
|
+
const { actionType, params, config } = actionOptions;
|
|
655
|
+
console.log("runAction_actionOptions", actionOptions);
|
|
609
656
|
const runActionId = this.startNewOperation(actionType);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
content: { params: otherParams }
|
|
615
|
-
});
|
|
616
|
-
}
|
|
657
|
+
paymentLog.addLog({
|
|
658
|
+
title: `${actionType}操作请求参数`,
|
|
659
|
+
content: { actionType, params }
|
|
660
|
+
});
|
|
617
661
|
const { actionApi, queryApi } = this.getActionApi(actionType);
|
|
618
662
|
if (!actionApi) {
|
|
619
663
|
const error = new Error(`${actionType}操作接口不存在`);
|
|
@@ -627,46 +671,49 @@ var PaymentMethod = class {
|
|
|
627
671
|
const res = await actionApi(
|
|
628
672
|
{
|
|
629
673
|
...params || {},
|
|
630
|
-
request_version: runActionId
|
|
631
|
-
is_outer_response_info: 1
|
|
674
|
+
request_version: runActionId
|
|
632
675
|
},
|
|
633
676
|
{ signal }
|
|
634
677
|
);
|
|
635
678
|
if (this.isFinished || !this.shouldContinue()) {
|
|
636
|
-
|
|
679
|
+
paymentLog.addLog({
|
|
637
680
|
title: "Action返回时已完成或不应继续处理,忽略",
|
|
638
681
|
content: { actionType }
|
|
639
682
|
});
|
|
640
683
|
return;
|
|
641
684
|
}
|
|
642
685
|
if (runActionId !== ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.request_version)) {
|
|
643
|
-
|
|
686
|
+
paymentLog.addLog({
|
|
644
687
|
title: "Action响应过期,忽略",
|
|
645
688
|
content: { actionType }
|
|
646
689
|
});
|
|
647
690
|
return;
|
|
648
691
|
}
|
|
649
|
-
|
|
692
|
+
if (config == null ? void 0 : config.needResponse) {
|
|
693
|
+
this.handleResponse(res);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
paymentLog.addLog({
|
|
650
697
|
title: "Action请求返回,开始轮询",
|
|
651
698
|
content: { actionType }
|
|
652
699
|
});
|
|
653
700
|
this.startQuery(actionType);
|
|
654
701
|
} catch (error) {
|
|
655
702
|
if (this.isFinished || !this.shouldContinue()) {
|
|
656
|
-
|
|
703
|
+
paymentLog.addLog({
|
|
657
704
|
title: "Action异常时已完成或不应继续处理,忽略",
|
|
658
705
|
content: { actionType }
|
|
659
706
|
});
|
|
660
707
|
return;
|
|
661
708
|
}
|
|
662
709
|
if (runActionId !== this.currentRunId) {
|
|
663
|
-
|
|
710
|
+
paymentLog.addLog({
|
|
664
711
|
title: "Action响应过期,忽略",
|
|
665
712
|
content: { actionType }
|
|
666
713
|
});
|
|
667
714
|
return;
|
|
668
715
|
}
|
|
669
|
-
|
|
716
|
+
paymentLog.addLog({
|
|
670
717
|
title: "Action请求异常,开始轮询",
|
|
671
718
|
content: { actionType, error }
|
|
672
719
|
});
|
|
@@ -677,40 +724,44 @@ var PaymentMethod = class {
|
|
|
677
724
|
* 支付
|
|
678
725
|
* @param params 支付参数
|
|
679
726
|
*/
|
|
680
|
-
pay(params) {
|
|
727
|
+
pay(params, config) {
|
|
681
728
|
this.run({
|
|
682
729
|
actionType: import_types.ActionType.Pay,
|
|
683
|
-
params
|
|
730
|
+
params,
|
|
731
|
+
config
|
|
684
732
|
});
|
|
685
733
|
}
|
|
686
734
|
/**
|
|
687
735
|
* 支付取消
|
|
688
736
|
* @param params 取消参数
|
|
689
737
|
*/
|
|
690
|
-
payAction(params) {
|
|
738
|
+
payAction(params, config) {
|
|
691
739
|
this.runAction({
|
|
692
740
|
actionType: import_types.ActionType.PayAction,
|
|
693
|
-
params
|
|
741
|
+
params,
|
|
742
|
+
config
|
|
694
743
|
});
|
|
695
744
|
}
|
|
696
745
|
/**
|
|
697
746
|
* 退款
|
|
698
747
|
* @param params 退款参数
|
|
699
748
|
*/
|
|
700
|
-
refund(params) {
|
|
749
|
+
refund(params, config) {
|
|
701
750
|
this.run({
|
|
702
751
|
actionType: import_types.ActionType.Refund,
|
|
703
|
-
params
|
|
752
|
+
params,
|
|
753
|
+
config
|
|
704
754
|
});
|
|
705
755
|
}
|
|
706
756
|
/**
|
|
707
757
|
* 退款取消
|
|
708
758
|
* @param params 取消参数
|
|
709
759
|
*/
|
|
710
|
-
refundAction(params) {
|
|
760
|
+
refundAction(params, config) {
|
|
711
761
|
this.runAction({
|
|
712
762
|
actionType: import_types.ActionType.RefundAction,
|
|
713
|
-
params
|
|
763
|
+
params,
|
|
764
|
+
config
|
|
714
765
|
});
|
|
715
766
|
}
|
|
716
767
|
/**
|
|
@@ -733,7 +784,7 @@ var PaymentMethod = class {
|
|
|
733
784
|
* 停止操作,后续依然可以重新发起操作
|
|
734
785
|
*/
|
|
735
786
|
stop() {
|
|
736
|
-
|
|
787
|
+
paymentLog.addLog({
|
|
737
788
|
title: "停止操作",
|
|
738
789
|
content: { actionType: this.currentActionType }
|
|
739
790
|
});
|
|
@@ -744,9 +795,8 @@ var PaymentMethod = class {
|
|
|
744
795
|
* 注意:销毁后实例不可再使用
|
|
745
796
|
*/
|
|
746
797
|
destroy() {
|
|
747
|
-
|
|
798
|
+
paymentLog.addLog({ title: "支付步骤结束,销毁实例" });
|
|
748
799
|
this.clean(true);
|
|
749
|
-
import_logs.default.clearLogs();
|
|
750
800
|
}
|
|
751
801
|
};
|
|
752
802
|
var payment_default = PaymentMethod;
|