@pisell/private-materials 6.3.124 → 6.3.125
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 +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +0 -1
- package/es/components/eftpos/hooks.d.ts +0 -1
- package/es/components/eftposPay/amount.js +15 -1
- package/es/components/eftposPay/app.js +2 -1
- package/es/components/eftposPay/component/fail/failCustom.js +12 -4
- package/es/components/eftposPay/component/fail/index.js +14 -6
- 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 +13 -1
- package/es/components/eftposPay/component/signature/index.js +3 -0
- package/es/components/eftposPay/device.js +33 -22
- package/es/components/eftposPay/index.js +48 -11
- 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 +10 -23
- package/es/components/eftposPay/pay.js +14 -7
- package/es/components/eftposPay/payo/config.js +38 -5
- package/es/components/eftposPay/payo/hooks.js +3 -12
- package/es/components/eftposPay/payo/payment.js +69 -136
- package/es/components/eftposPay/tip.js +5 -0
- package/es/components/eftposPay/tyro/hooks.d.ts +0 -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 +430 -0
- package/es/components/eftposPay/windcave/receiptAction.js +5 -0
- package/es/components/eftposPay/windcave/windcave.js +28 -29
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +0 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +0 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +0 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +0 -1
- package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +0 -1
- package/es/components/shoppingCart/components/Empty/index.d.ts +0 -1
- package/es/hooks/usePaymentLogger.d.ts +0 -1
- package/lib/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +0 -1
- package/lib/components/eftpos/hooks.d.ts +0 -1
- package/lib/components/eftposPay/amount.js +13 -1
- package/lib/components/eftposPay/app.js +2 -1
- 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 +10 -0
- package/lib/components/eftposPay/component/signature/index.js +3 -0
- package/lib/components/eftposPay/device.js +11 -10
- package/lib/components/eftposPay/index.js +36 -11
- 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 +7 -10
- package/lib/components/eftposPay/pay.js +9 -1
- package/lib/components/eftposPay/payo/config.js +15 -8
- package/lib/components/eftposPay/payo/hooks.js +12 -10
- package/lib/components/eftposPay/payo/payment.js +31 -65
- package/lib/components/eftposPay/tip.js +5 -0
- package/lib/components/eftposPay/tyro/hooks.d.ts +0 -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 +320 -0
- package/lib/components/eftposPay/windcave/receiptAction.js +5 -0
- package/lib/components/eftposPay/windcave/windcave.js +18 -20
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +0 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +0 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +0 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +0 -1
- package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +0 -1
- package/lib/components/shoppingCart/components/Empty/index.d.ts +0 -1
- package/lib/hooks/usePaymentLogger.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/components/eftposPay/payo/hooks.tsx
|
|
@@ -25,7 +35,7 @@ module.exports = __toCommonJS(hooks_exports);
|
|
|
25
35
|
var import_react = require("react");
|
|
26
36
|
var import_const = require("../const");
|
|
27
37
|
var import_helper = require("../helper");
|
|
28
|
-
var
|
|
38
|
+
var import_payLog = __toESM(require("../utils/payLog"));
|
|
29
39
|
var useValidate = (timeout) => {
|
|
30
40
|
const controllerRef = (0, import_react.useRef)();
|
|
31
41
|
const ref = (0, import_react.useRef)(true);
|
|
@@ -79,15 +89,7 @@ var useValidate = (timeout) => {
|
|
|
79
89
|
TimeoutRef.current && clearTimeout(TimeoutRef.current);
|
|
80
90
|
TimeoutRef.current = setTimeout(() => {
|
|
81
91
|
isTimeoutCloseRef.current = true;
|
|
82
|
-
(
|
|
83
|
-
title: "支付状态查询超时",
|
|
84
|
-
content: [
|
|
85
|
-
{
|
|
86
|
-
key: "params",
|
|
87
|
-
value: JSON.stringify(params)
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
});
|
|
92
|
+
import_payLog.default.log("Payo:支付状态查询超时");
|
|
91
93
|
close();
|
|
92
94
|
}, timeout);
|
|
93
95
|
return checkApi(...params);
|
|
@@ -35,7 +35,7 @@ __export(payment_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(payment_exports);
|
|
36
36
|
var import_react = require("react");
|
|
37
37
|
var import_const = require("../const");
|
|
38
|
-
var
|
|
38
|
+
var import_payLog = __toESM(require("../utils/payLog"));
|
|
39
39
|
var QUERY_START_DELAY = 1e3 * 10;
|
|
40
40
|
var GLOBAL_TIMEOUT = 1e3 * 60 * 2;
|
|
41
41
|
var REQUEST_TIMEOUT = 1e3 * 10;
|
|
@@ -107,36 +107,32 @@ var usePayment = (options) => {
|
|
|
107
107
|
if (!isFinishedRef.current) {
|
|
108
108
|
clean();
|
|
109
109
|
isFinishedRef.current = true;
|
|
110
|
-
import_log.default.clearLogs();
|
|
111
110
|
}
|
|
112
111
|
};
|
|
113
112
|
const handleFinalSuccess = (res, type) => {
|
|
114
113
|
var _a, _b;
|
|
115
114
|
if (isFinishedRef.current || !shouldContinue()) {
|
|
116
|
-
|
|
115
|
+
import_payLog.default.log(`handleFinalSuccess: 已完成或不应继续处理,忽略${type}操作成功结果`);
|
|
117
116
|
return;
|
|
118
117
|
}
|
|
118
|
+
import_payLog.default.log("接口最终结果:支付成功", { type, res });
|
|
119
119
|
(_b = (_a = callbacksRef.current) == null ? void 0 : _a.onSuccess) == null ? void 0 : _b.call(_a, res);
|
|
120
|
-
import_log.default.addLog({ title: "最终结果:支付成功", content: { type, res } });
|
|
121
120
|
finish();
|
|
122
121
|
};
|
|
123
122
|
const handleFinalError = (error, type) => {
|
|
124
123
|
var _a, _b;
|
|
125
124
|
if (isFinishedRef.current || !shouldContinue()) {
|
|
126
|
-
|
|
125
|
+
import_payLog.default.log(`handleFinalError: 已完成或不应继续处理,忽略${type}操作错误`);
|
|
127
126
|
return;
|
|
128
127
|
}
|
|
128
|
+
import_payLog.default.log("接口最终结果:支付失败", { type, error });
|
|
129
129
|
(_b = (_a = callbacksRef.current) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error);
|
|
130
|
-
import_log.default.addLog({
|
|
131
|
-
title: "最终结果:支付失败",
|
|
132
|
-
content: { type, error }
|
|
133
|
-
});
|
|
134
130
|
finish();
|
|
135
131
|
};
|
|
136
132
|
const createTimeoutPromise = (timeoutMs) => {
|
|
137
133
|
return new Promise((_, reject) => {
|
|
138
134
|
requestTimeoutTimerRef.current = setTimeout(() => {
|
|
139
|
-
|
|
135
|
+
import_payLog.default.log(`⏱️ 单次查询超时(${timeoutMs / 1e3}秒),强制终止`);
|
|
140
136
|
isRequestTimeoutRef.current = true;
|
|
141
137
|
if (queryControllerRef.current) {
|
|
142
138
|
queryControllerRef.current.abort();
|
|
@@ -147,9 +143,7 @@ var usePayment = (options) => {
|
|
|
147
143
|
};
|
|
148
144
|
const performQuery = async (paymentNum) => {
|
|
149
145
|
if (isFinishedRef.current || !shouldContinue()) {
|
|
150
|
-
|
|
151
|
-
title: "支付轮询前置校验:支付已完成或不应继续处理,取消查询"
|
|
152
|
-
});
|
|
146
|
+
import_payLog.default.log("支付轮询前置校验:已完成或不应继续,取消查询");
|
|
153
147
|
return;
|
|
154
148
|
}
|
|
155
149
|
if (queryControllerRef.current) {
|
|
@@ -166,7 +160,7 @@ var usePayment = (options) => {
|
|
|
166
160
|
queryControllerRef.current = new AbortController();
|
|
167
161
|
const { signal } = queryControllerRef.current;
|
|
168
162
|
try {
|
|
169
|
-
|
|
163
|
+
import_payLog.default.log("支付轮询:开始单次查询");
|
|
170
164
|
const res = await Promise.race([
|
|
171
165
|
checkApi({ number: paymentNum }, { signal }),
|
|
172
166
|
createTimeoutPromise(REQUEST_TIMEOUT)
|
|
@@ -176,29 +170,23 @@ var usePayment = (options) => {
|
|
|
176
170
|
requestTimeoutTimerRef.current = null;
|
|
177
171
|
}
|
|
178
172
|
if (queryId < currentQueryIdRef.current) {
|
|
179
|
-
|
|
173
|
+
import_payLog.default.log("支付轮询结果:过期的查询响应,忽略");
|
|
180
174
|
return;
|
|
181
175
|
}
|
|
182
176
|
if (isFinishedRef.current || !shouldContinue()) {
|
|
183
|
-
|
|
177
|
+
import_payLog.default.log("支付轮询结果:已完成或不应继续处理");
|
|
184
178
|
return;
|
|
185
179
|
}
|
|
186
180
|
if (res && `${res.code}` === "200") {
|
|
187
|
-
|
|
181
|
+
import_payLog.default.log("支付轮询结果:支付成功");
|
|
188
182
|
handleFinalSuccess(res, "query" /* Query */);
|
|
189
183
|
return;
|
|
190
184
|
}
|
|
191
185
|
if (isRequestFailed(res == null ? void 0 : res.code)) {
|
|
192
|
-
|
|
193
|
-
title: "支付轮询结果:有明确错误code,停止轮询",
|
|
194
|
-
content: res
|
|
195
|
-
});
|
|
186
|
+
import_payLog.default.log("支付轮询结果:有明确错误code,停止轮询", { code: res == null ? void 0 : res.code });
|
|
196
187
|
handleFinalError(res, "query" /* Query */);
|
|
197
188
|
} else {
|
|
198
|
-
|
|
199
|
-
title: "支付轮询结果:查询返回失败但没有明确code或超时code,继续轮询",
|
|
200
|
-
content: res
|
|
201
|
-
});
|
|
189
|
+
import_payLog.default.log("支付轮询结果:无明确code,继续轮询", { code: res == null ? void 0 : res.code });
|
|
202
190
|
scheduleNextQuery(paymentNum);
|
|
203
191
|
}
|
|
204
192
|
} catch (error) {
|
|
@@ -207,32 +195,22 @@ var usePayment = (options) => {
|
|
|
207
195
|
requestTimeoutTimerRef.current = null;
|
|
208
196
|
}
|
|
209
197
|
if (queryId < currentQueryIdRef.current) {
|
|
210
|
-
|
|
211
|
-
title: "支付轮询结果:error-过期的查询异常,忽略"
|
|
212
|
-
});
|
|
198
|
+
import_payLog.default.log("支付轮询结果:error-过期的查询异常,忽略");
|
|
213
199
|
return;
|
|
214
200
|
}
|
|
215
201
|
if (isFinishedRef.current || !shouldContinue()) {
|
|
216
202
|
return;
|
|
217
203
|
}
|
|
218
204
|
if (isRequestTimeoutRef.current || (error == null ? void 0 : error.name) === "AbortError" || (error == null ? void 0 : error.message) === "REQUEST_TIMEOUT") {
|
|
219
|
-
|
|
220
|
-
title: "支付轮询结果:error-请求被取消或超时,继续轮询"
|
|
221
|
-
});
|
|
205
|
+
import_payLog.default.log("支付轮询结果:error-请求被取消或超时,继续轮询");
|
|
222
206
|
scheduleNextQuery(paymentNum);
|
|
223
207
|
return;
|
|
224
208
|
}
|
|
225
209
|
if (isRequestFailed(error == null ? void 0 : error.code)) {
|
|
226
|
-
|
|
227
|
-
title: "支付轮询结果:error-有明确错误code,停止轮询",
|
|
228
|
-
content: error
|
|
229
|
-
});
|
|
210
|
+
import_payLog.default.log("支付轮询结果:error-有明确错误code,停止轮询", { code: error == null ? void 0 : error.code });
|
|
230
211
|
handleFinalError(error, "query" /* Query */);
|
|
231
212
|
} else {
|
|
232
|
-
|
|
233
|
-
title: "支付轮询结果:error-无明确code或者code不是超时,继续轮询",
|
|
234
|
-
content: error
|
|
235
|
-
});
|
|
213
|
+
import_payLog.default.log("支付轮询结果:error-无明确code,继续轮询", { code: error == null ? void 0 : error.code });
|
|
236
214
|
scheduleNextQuery(paymentNum);
|
|
237
215
|
}
|
|
238
216
|
}
|
|
@@ -245,7 +223,7 @@ var usePayment = (options) => {
|
|
|
245
223
|
clearTimeout(queryIntervalTimerRef.current);
|
|
246
224
|
}
|
|
247
225
|
queryIntervalTimerRef.current = setTimeout(() => {
|
|
248
|
-
|
|
226
|
+
import_payLog.default.log("支付轮询:安排下一次查询");
|
|
249
227
|
performQuery(paymentNum);
|
|
250
228
|
}, QUERY_INTERVAL);
|
|
251
229
|
};
|
|
@@ -259,7 +237,7 @@ var usePayment = (options) => {
|
|
|
259
237
|
return;
|
|
260
238
|
}
|
|
261
239
|
console.log("⏱️ 轮询全局超时(2分钟),终止所有请求");
|
|
262
|
-
|
|
240
|
+
import_payLog.default.log("轮询全局超时(2分钟),终止所有请求");
|
|
263
241
|
handleFinalError(
|
|
264
242
|
{ code: import_const.PayStatus.Timeout, message: "交易超时" },
|
|
265
243
|
"query" /* Query */
|
|
@@ -277,23 +255,17 @@ var usePayment = (options) => {
|
|
|
277
255
|
const runId = Date.now();
|
|
278
256
|
currentRunIdRef.current = runId;
|
|
279
257
|
const { pay_param_base64, ...otherParams } = params || {};
|
|
280
|
-
import_log.default.init(paymentNum, {
|
|
281
|
-
orderId: options2 == null ? void 0 : options2.orderId,
|
|
282
|
-
deviceId: options2 == null ? void 0 : options2.deviceId,
|
|
283
|
-
paymentType: `PAYO_${paymentType}`,
|
|
284
|
-
params: otherParams
|
|
285
|
-
});
|
|
286
258
|
isFinishedRef.current = true;
|
|
287
259
|
clean({ clearCallbacks: false });
|
|
288
260
|
callbacksRef.current = callbacks;
|
|
289
261
|
queryStartTimerRef.current = setTimeout(() => {
|
|
290
|
-
|
|
262
|
+
import_payLog.default.log("支付后10秒开始轮询");
|
|
291
263
|
startQuery(paymentNum);
|
|
292
264
|
}, QUERY_START_DELAY);
|
|
293
265
|
payControllerRef.current = new AbortController();
|
|
294
266
|
const { signal } = payControllerRef.current;
|
|
295
267
|
try {
|
|
296
|
-
|
|
268
|
+
import_payLog.default.log("发起支付请求");
|
|
297
269
|
const resultPromise = paymentType === "pay" /* Pay */ ? payApi : refundApi;
|
|
298
270
|
if (!resultPromise) {
|
|
299
271
|
throw new Error(
|
|
@@ -302,49 +274,43 @@ var usePayment = (options) => {
|
|
|
302
274
|
}
|
|
303
275
|
const res = await (resultPromise == null ? void 0 : resultPromise(params, { signal }));
|
|
304
276
|
if (runId < currentRunIdRef.current) {
|
|
305
|
-
|
|
277
|
+
import_payLog.default.log("支付响应过期,忽略");
|
|
306
278
|
return;
|
|
307
279
|
}
|
|
308
280
|
if (isFinishedRef.current || !shouldContinue()) {
|
|
309
|
-
|
|
281
|
+
import_payLog.default.log("支付返回时已完成或不应继续处理");
|
|
310
282
|
return;
|
|
311
283
|
}
|
|
312
284
|
if (res && `${res.code}` === "200") {
|
|
313
|
-
|
|
285
|
+
import_payLog.default.log("支付接口成功");
|
|
314
286
|
handleFinalSuccess(res, paymentType);
|
|
315
287
|
return;
|
|
316
288
|
}
|
|
317
289
|
if (isRequestFailed(res == null ? void 0 : res.code)) {
|
|
318
|
-
|
|
290
|
+
import_payLog.default.log("支付接口返回失败", { code: res == null ? void 0 : res.code });
|
|
319
291
|
handleFinalError(res, "pay" /* Pay */);
|
|
320
292
|
} else {
|
|
321
|
-
|
|
322
|
-
title: "支付超时或无明确错误,等待轮询结果",
|
|
323
|
-
content: { res }
|
|
324
|
-
});
|
|
293
|
+
import_payLog.default.log("支付超时或无明确错误,等待轮询结果", { code: res == null ? void 0 : res.code });
|
|
325
294
|
}
|
|
326
295
|
} catch (error) {
|
|
327
296
|
if (runId < currentRunIdRef.current) {
|
|
328
|
-
|
|
297
|
+
import_payLog.default.log("支付异常响应过期,忽略");
|
|
329
298
|
return;
|
|
330
299
|
}
|
|
331
300
|
if (isFinishedRef.current || !shouldContinue()) {
|
|
332
|
-
|
|
301
|
+
import_payLog.default.log("支付异常时已完成或不应继续处理");
|
|
333
302
|
return;
|
|
334
303
|
}
|
|
335
304
|
if (isRequestFailed(error == null ? void 0 : error.code)) {
|
|
336
|
-
|
|
305
|
+
import_payLog.default.log("支付接口异常", { code: error == null ? void 0 : error.code });
|
|
337
306
|
handleFinalError(error, paymentType);
|
|
338
307
|
} else {
|
|
339
|
-
|
|
340
|
-
title: "支付超时或无明确错误,等待轮询结果",
|
|
341
|
-
content: { error }
|
|
342
|
-
});
|
|
308
|
+
import_payLog.default.log("支付异常超时或无明确错误,等待轮询结果", { code: error == null ? void 0 : error.code });
|
|
343
309
|
}
|
|
344
310
|
}
|
|
345
311
|
};
|
|
346
312
|
const stop = () => {
|
|
347
|
-
|
|
313
|
+
import_payLog.default.log("手动停止支付流程");
|
|
348
314
|
clean();
|
|
349
315
|
isFinishedRef.current = true;
|
|
350
316
|
};
|
|
@@ -40,6 +40,7 @@ var import_const = require("./const");
|
|
|
40
40
|
var import_dayjs = __toESM(require("dayjs"));
|
|
41
41
|
var import_store = require("./store");
|
|
42
42
|
var import_hooks = require("./hooks");
|
|
43
|
+
var import_payLog = __toESM(require("./utils/payLog"));
|
|
43
44
|
var import_tip = require("./tip.less");
|
|
44
45
|
function formatDateUtils(date, format) {
|
|
45
46
|
if (!date) {
|
|
@@ -83,7 +84,11 @@ var tip_default = ({
|
|
|
83
84
|
amountRef,
|
|
84
85
|
eftposRef
|
|
85
86
|
} = (0, import_hooks.useStoreRef)();
|
|
87
|
+
(0, import_react.useEffect)(() => {
|
|
88
|
+
import_payLog.default.log("成功确认页展示");
|
|
89
|
+
}, []);
|
|
86
90
|
const onConfirm = () => {
|
|
91
|
+
import_payLog.default.log("确认支付成功");
|
|
87
92
|
onChangeStatus("success", { ...ref.current || {} });
|
|
88
93
|
};
|
|
89
94
|
(0, import_react.useEffect)(() => {
|
|
@@ -42,6 +42,7 @@ var import_decimal = require("decimal.js");
|
|
|
42
42
|
var import_helper = require("../helper");
|
|
43
43
|
var import_step = __toESM(require("../component/step/step"));
|
|
44
44
|
var import_hooks2 = require("../hooks");
|
|
45
|
+
var import_payLog = __toESM(require("../utils/payLog"));
|
|
45
46
|
var Minute = 1e3 * 60;
|
|
46
47
|
var tyro_default = ({
|
|
47
48
|
api,
|
|
@@ -98,6 +99,7 @@ var tyro_default = ({
|
|
|
98
99
|
console.log(integrationKey, tid, mid);
|
|
99
100
|
iClient.terminalInfo(
|
|
100
101
|
({ status: status2, message, terminalInfo }) => {
|
|
102
|
+
import_payLog.default.log("Tyro:终端信息回调", { status: status2, terminalInfo, message });
|
|
101
103
|
if (status2 === "success" && (terminalInfo == null ? void 0 : terminalInfo.available)) {
|
|
102
104
|
cb();
|
|
103
105
|
}
|
|
@@ -110,7 +112,7 @@ var tyro_default = ({
|
|
|
110
112
|
);
|
|
111
113
|
};
|
|
112
114
|
const refundOrder = () => {
|
|
113
|
-
var _a, _b, _c;
|
|
115
|
+
var _a, _b, _c, _d;
|
|
114
116
|
const iClient = iClientRef.current;
|
|
115
117
|
if (!iClient) {
|
|
116
118
|
return;
|
|
@@ -167,6 +169,8 @@ var tyro_default = ({
|
|
|
167
169
|
})
|
|
168
170
|
);
|
|
169
171
|
});
|
|
172
|
+
import_payLog.default.setContext({ transactionNumber: numRef.current });
|
|
173
|
+
import_payLog.default.log("Tyro:发起退款", { number: numRef == null ? void 0 : numRef.current, amount: (_d = requestParams.current) == null ? void 0 : _d.amount });
|
|
170
174
|
iClient.initiateRefund(requestParams.current, {
|
|
171
175
|
receiptCallback: receiptCallbackImpl,
|
|
172
176
|
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
@@ -238,6 +242,8 @@ var tyro_default = ({
|
|
|
238
242
|
})
|
|
239
243
|
);
|
|
240
244
|
});
|
|
245
|
+
import_payLog.default.setContext({ transactionNumber: numRef.current });
|
|
246
|
+
import_payLog.default.log("Tyro:发起支付", { number: numRef.current, amount: requestParams.current.amount });
|
|
241
247
|
iClient.initiatePurchase(requestParams.current, {
|
|
242
248
|
receiptCallback: receiptCallbackImpl,
|
|
243
249
|
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
@@ -255,6 +261,7 @@ var tyro_default = ({
|
|
|
255
261
|
}
|
|
256
262
|
setStatus(Date.now());
|
|
257
263
|
merchantReceiptRef.current = {};
|
|
264
|
+
import_payLog.default.log("Tyro:恢复上次交易");
|
|
258
265
|
iClient.continueLastTransaction({
|
|
259
266
|
receiptCallback: receiptCallbackImpl,
|
|
260
267
|
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
@@ -263,8 +270,7 @@ var tyro_default = ({
|
|
|
263
270
|
});
|
|
264
271
|
};
|
|
265
272
|
const receiptCallbackImpl = ({ signatureRequired, merchantReceipt }) => {
|
|
266
|
-
|
|
267
|
-
console.log("商家小票 小票内容 = \n", merchantReceipt);
|
|
273
|
+
import_payLog.default.log("Tyro:小票回调", { signatureRequired, hasReceipt: !!merchantReceipt });
|
|
268
274
|
const receipt = [merchantReceipt].filter((item) => typeof item === "string").filter(Boolean);
|
|
269
275
|
merchantReceiptRef.current = { signatureRequired, merchantReceipt };
|
|
270
276
|
if (signatureRequired) {
|
|
@@ -277,6 +283,7 @@ var tyro_default = ({
|
|
|
277
283
|
};
|
|
278
284
|
const statusMessageCallbackImpl = (message) => {
|
|
279
285
|
var _a;
|
|
286
|
+
import_payLog.default.log("Tyro:状态消息", { message });
|
|
280
287
|
const translateMsg = import_utils.locales.getText("page.eftpos-pay.text.tyro")(message);
|
|
281
288
|
const msg = Array.isArray(translateMsg) ? translateMsg.reduce(
|
|
282
289
|
(accumulator, currentValue) => accumulator + " " + currentValue,
|
|
@@ -307,7 +314,7 @@ var tyro_default = ({
|
|
|
307
314
|
);
|
|
308
315
|
};
|
|
309
316
|
const questionCallbackImpl = (question, answerCallback) => {
|
|
310
|
-
|
|
317
|
+
import_payLog.default.log("Tyro:交互问题回调", { question });
|
|
311
318
|
setStatus(-1);
|
|
312
319
|
setManually(false);
|
|
313
320
|
const msg = import_utils.locales.getText("page.eftpos-pay.text.tyro")(question.text);
|
|
@@ -363,15 +370,7 @@ var tyro_default = ({
|
|
|
363
370
|
var _a, _b;
|
|
364
371
|
setStatus(-1);
|
|
365
372
|
setManually(false);
|
|
366
|
-
|
|
367
|
-
"Response = " + JSON.stringify(response),
|
|
368
|
-
", Request = ",
|
|
369
|
-
JSON.stringify(requestParams.current)
|
|
370
|
-
);
|
|
371
|
-
console.log(
|
|
372
|
-
" 客户小票 response.customerReceipt = \n",
|
|
373
|
-
response.customerReceipt
|
|
374
|
-
);
|
|
373
|
+
import_payLog.default.log("Tyro:交易完成回调", { response });
|
|
375
374
|
const receipt = [
|
|
376
375
|
// merchantReceiptRef.current?.merchantReceipt,
|
|
377
376
|
response == null ? void 0 : response.customerReceipt
|
|
@@ -476,20 +475,22 @@ var tyro_default = ({
|
|
|
476
475
|
if (load && TyroRef.current) {
|
|
477
476
|
const IClient = TyroRef.current.IClient;
|
|
478
477
|
if (IClient) {
|
|
479
|
-
console.log("apiKey = ", apiKey, "posProductData = ", posProductData);
|
|
480
478
|
const iclient = new IClient(apiKey, posProductData);
|
|
481
|
-
console.log(iclient.posProductData);
|
|
482
479
|
iClientRef.current = iclient;
|
|
480
|
+
import_payLog.default.log("Tyro:SDK 初始化完成");
|
|
483
481
|
if (isCancelRef.current) {
|
|
484
482
|
return;
|
|
485
483
|
}
|
|
486
484
|
if (!numRef.current) {
|
|
487
485
|
if (modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay) {
|
|
486
|
+
import_payLog.default.log("Tyro:支付交易,查询终端信息");
|
|
488
487
|
getTerminalInfo(payOrder);
|
|
489
488
|
} else if (modeRef.current === import_const.ModeEnum.Refund) {
|
|
489
|
+
import_payLog.default.log("Tyro:退款交易,查询终端信息");
|
|
490
490
|
getTerminalInfo(refundOrder);
|
|
491
491
|
}
|
|
492
492
|
} else {
|
|
493
|
+
import_payLog.default.log("Tyro:恢复上次交易,查询终端信息");
|
|
493
494
|
getTerminalInfo(continueLastOrder);
|
|
494
495
|
}
|
|
495
496
|
}
|
|
@@ -508,8 +509,8 @@ var tyro_default = ({
|
|
|
508
509
|
};
|
|
509
510
|
}
|
|
510
511
|
if (status === 0) {
|
|
511
|
-
console.log("开始倒计时...");
|
|
512
512
|
clear = setTimeout(() => {
|
|
513
|
+
import_payLog.default.log("Tyro:连接超时");
|
|
513
514
|
dispatch(
|
|
514
515
|
(0, import_store.updateState)({
|
|
515
516
|
status: "fail"
|
|
@@ -542,7 +543,7 @@ var tyro_default = ({
|
|
|
542
543
|
if (!iClient) {
|
|
543
544
|
return;
|
|
544
545
|
}
|
|
545
|
-
|
|
546
|
+
import_payLog.default.log("Tyro:交易超时,显示手动标记");
|
|
546
547
|
setManually(true);
|
|
547
548
|
}, Minute);
|
|
548
549
|
return () => {
|
|
@@ -552,6 +553,7 @@ var tyro_default = ({
|
|
|
552
553
|
};
|
|
553
554
|
}, [status]);
|
|
554
555
|
const onManually = () => {
|
|
556
|
+
import_payLog.default.log("Tyro:点击手动标记");
|
|
555
557
|
dispatch(
|
|
556
558
|
(0, import_store.updateState)({
|
|
557
559
|
manual: {
|
|
@@ -568,12 +570,14 @@ var tyro_default = ({
|
|
|
568
570
|
return;
|
|
569
571
|
}
|
|
570
572
|
if (status > 0) {
|
|
573
|
+
import_payLog.default.log("Tyro:取消当前交易");
|
|
571
574
|
iClient.cancelCurrentTransaction();
|
|
572
575
|
return;
|
|
573
576
|
}
|
|
574
577
|
if (isCancelRef.current) {
|
|
575
578
|
return;
|
|
576
579
|
}
|
|
580
|
+
import_payLog.default.log("Tyro:取消(交易未开始)");
|
|
577
581
|
isCancelRef.current = true;
|
|
578
582
|
dispatch(
|
|
579
583
|
(0, import_store.updateState)({
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface PayLogContext {
|
|
2
|
+
/** 渠道 */
|
|
3
|
+
channel?: string;
|
|
4
|
+
/** 订单ID */
|
|
5
|
+
orderId?: string | number;
|
|
6
|
+
/** 设备ID */
|
|
7
|
+
deviceId?: string | number;
|
|
8
|
+
/** 支付类型:PAYO / WINDCAVE / LINKLY / TYRO */
|
|
9
|
+
paymentType?: string;
|
|
10
|
+
/** 交易记录号 */
|
|
11
|
+
transactionNumber?: string;
|
|
12
|
+
/** 模式:pay / refund / query */
|
|
13
|
+
mode?: string;
|
|
14
|
+
/** 其他扩展信息 */
|
|
15
|
+
extra?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
declare class PayLog {
|
|
18
|
+
private static instance;
|
|
19
|
+
private sessionKey;
|
|
20
|
+
private context;
|
|
21
|
+
private logs;
|
|
22
|
+
private startTime;
|
|
23
|
+
private flushed;
|
|
24
|
+
private constructor();
|
|
25
|
+
static getInstance(): PayLog;
|
|
26
|
+
/**
|
|
27
|
+
* 初始化一次交易会话
|
|
28
|
+
* - 生成唯一 sessionKey
|
|
29
|
+
* - 恢复上报 localStorage 中残留的旧日志
|
|
30
|
+
* - 接受部分 context(后续可通过 setContext 补充)
|
|
31
|
+
*/
|
|
32
|
+
init(context?: Partial<PayLogContext>): void;
|
|
33
|
+
/**
|
|
34
|
+
* 补充/更新上下文信息
|
|
35
|
+
* 新值覆盖旧值,extra 做浅合并
|
|
36
|
+
*/
|
|
37
|
+
setContext(partial: Partial<PayLogContext>): void;
|
|
38
|
+
/**
|
|
39
|
+
* 记录一条日志
|
|
40
|
+
*/
|
|
41
|
+
log(title: string, data?: any): void;
|
|
42
|
+
/**
|
|
43
|
+
* 上报日志到飞书并清理 localStorage
|
|
44
|
+
*/
|
|
45
|
+
flush(customTitle?: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* flush + 重置内部状态
|
|
48
|
+
*/
|
|
49
|
+
destroy(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 构建 sendWarningLog 所需的 content 数组
|
|
52
|
+
*/
|
|
53
|
+
private buildContent;
|
|
54
|
+
/**
|
|
55
|
+
* 持久化当前会话到 localStorage
|
|
56
|
+
*/
|
|
57
|
+
private persistToStorage;
|
|
58
|
+
/**
|
|
59
|
+
* 从 localStorage 移除指定 session
|
|
60
|
+
*/
|
|
61
|
+
private removeFromStorage;
|
|
62
|
+
/**
|
|
63
|
+
* 获取 localStorage 中所有 session
|
|
64
|
+
*/
|
|
65
|
+
private getAllSessions;
|
|
66
|
+
/**
|
|
67
|
+
* 恢复上报 localStorage 中残留的旧日志(崩溃/异常退出场景)
|
|
68
|
+
*/
|
|
69
|
+
private recoverOrphanedLogs;
|
|
70
|
+
}
|
|
71
|
+
declare const payLog: PayLog;
|
|
72
|
+
export default payLog;
|
|
73
|
+
/**
|
|
74
|
+
* 在根组件中使用,管理 PayLog 生命周期
|
|
75
|
+
* - mount 时 init(+ 恢复上报残留日志)
|
|
76
|
+
* - unmount 时 flush
|
|
77
|
+
*/
|
|
78
|
+
export declare function usePayLog(context?: Partial<PayLogContext>): {
|
|
79
|
+
log: (title: string, data?: any) => void;
|
|
80
|
+
setContext: (partial: Partial<PayLogContext>) => void;
|
|
81
|
+
};
|