@pisell/private-materials 3.0.136 → 3.0.138
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 +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +12 -12
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +11 -11
- package/es/components/booking/forms/single/index.js +3 -0
- package/es/components/eftpos/const.d.ts +26 -0
- package/es/components/eftpos/const.js +40 -8
- package/es/components/eftpos/device.d.ts +3 -2
- package/es/components/eftpos/device.js +6 -5
- package/es/components/eftpos/form/index.d.ts +5 -0
- package/es/components/eftpos/form/index.js +8 -0
- package/es/components/eftpos/hooks.d.ts +34 -0
- package/es/components/{eftposPay/windcave/hook.js → eftpos/hooks.js} +96 -122
- package/es/components/eftpos/icon/apiKey.d.ts +5 -0
- package/es/components/eftpos/icon/apiKey.js +17 -0
- package/es/components/eftpos/icon/device.d.ts +5 -0
- package/es/components/eftpos/icon/device.js +19 -0
- package/es/components/eftpos/index.d.ts +10 -0
- package/es/components/eftpos/index.js +329 -46
- package/es/components/eftpos/index.less +38 -1
- package/es/components/eftpos/locales.d.ts +12 -0
- package/es/components/eftpos/locales.js +15 -3
- package/es/components/eftpos/log.d.ts +8 -0
- package/es/components/eftpos/log.js +85 -0
- package/es/components/eftpos/pos.d.ts +1 -1
- package/es/components/eftpos/pos.js +8 -5
- package/es/components/eftpos/surcharge/index.d.ts +25 -2
- package/es/components/eftpos/surcharge/index.js +100 -16
- package/es/components/eftpos/table.d.ts +4 -0
- package/es/components/eftpos/table.js +102 -10
- package/es/components/eftposPay/amount.d.ts +7 -1
- package/es/components/eftposPay/amount.js +65 -38
- package/es/components/eftposPay/component/fail/failCustom.js +65 -20
- package/es/components/eftposPay/component/fail/index.js +60 -30
- package/es/components/eftposPay/component/fail/network.d.ts +5 -0
- package/es/components/eftposPay/component/fail/network.js +13 -0
- package/es/components/eftposPay/component/fail/unknow.d.ts +6 -0
- package/es/components/eftposPay/component/fail/unknow.js +18 -3
- package/es/components/eftposPay/component/header/index.d.ts +2 -1
- package/es/components/eftposPay/component/header/index.js +4 -1
- package/es/components/eftposPay/component/header/index.less +1 -10
- package/es/components/eftposPay/component/manual/index.d.ts +6 -1
- package/es/components/eftposPay/component/manual/index.js +174 -23
- package/es/components/eftposPay/component/manual/index.less +42 -14
- package/es/components/eftposPay/component/signature/index.d.ts +5 -0
- package/es/components/eftposPay/component/signature/index.js +20 -2
- package/es/components/eftposPay/component/step/index.d.ts +7 -7
- package/es/components/eftposPay/component/step/step.d.ts +4 -4
- package/es/components/eftposPay/const.d.ts +19 -4
- package/es/components/eftposPay/const.js +4 -2
- package/es/components/eftposPay/device.d.ts +7 -0
- package/es/components/eftposPay/device.js +22 -0
- package/es/components/eftposPay/helper.d.ts +54 -0
- package/es/components/eftposPay/helper.js +93 -1
- package/es/components/eftposPay/hooks.d.ts +30 -1
- package/es/components/eftposPay/hooks.js +181 -26
- package/es/components/eftposPay/index.d.ts +2 -4
- package/es/components/eftposPay/index.js +119 -31
- package/es/components/eftposPay/index.less +27 -19
- package/es/components/eftposPay/locales.d.ts +45 -0
- package/es/components/eftposPay/locales.js +348 -3
- package/es/components/eftposPay/manufacturer.d.ts +2 -2
- package/es/components/eftposPay/manufacturer.js +9 -10
- package/es/components/eftposPay/pay.d.ts +10 -1
- package/es/components/eftposPay/pay.js +112 -34
- package/es/components/eftposPay/payo/config.js +137 -270
- package/es/components/eftposPay/payo/const.d.ts +22 -2
- package/es/components/eftposPay/payo/const.js +83 -33
- package/es/components/eftposPay/payo/hooks.d.ts +5 -0
- package/es/components/eftposPay/payo/hooks.js +19 -2
- package/es/components/eftposPay/store/index.d.ts +154 -53
- package/es/components/eftposPay/store/index.js +112 -60
- package/es/components/eftposPay/tyro/const.d.ts +17 -0
- package/es/components/eftposPay/{eftpos → tyro}/const.js +71 -90
- package/es/components/eftposPay/tyro/hooks.d.ts +14 -0
- package/es/components/eftposPay/tyro/hooks.js +40 -0
- package/es/components/eftposPay/tyro/index.d.ts +9 -0
- package/es/components/eftposPay/tyro/index.js +575 -0
- package/es/components/eftposPay/windcave/const.d.ts +24 -9
- package/es/components/eftposPay/windcave/const.js +90 -81
- package/es/components/eftposPay/windcave/helper.d.ts +16 -2
- package/es/components/eftposPay/windcave/helper.js +175 -42
- package/es/components/eftposPay/windcave/receiptAction.d.ts +12 -0
- package/es/components/eftposPay/windcave/receiptAction.js +91 -43
- package/es/components/eftposPay/windcave/timer.d.ts +13 -1
- package/es/components/eftposPay/windcave/timer.js +18 -1
- package/es/components/eftposPay/windcave/windcave.d.ts +2 -1
- package/es/components/eftposPay/windcave/windcave.js +155 -139
- package/es/utils/load.d.ts +11 -0
- package/es/utils/load.js +85 -0
- package/lib/components/booking/forms/single/index.js +1 -0
- package/lib/components/eftpos/const.d.ts +26 -0
- package/lib/components/eftpos/const.js +13 -1
- package/lib/components/eftpos/device.d.ts +3 -2
- package/lib/components/eftpos/device.js +2 -2
- package/lib/components/eftpos/form/index.d.ts +5 -0
- package/lib/components/eftpos/hooks.d.ts +34 -0
- package/lib/components/eftpos/hooks.js +106 -0
- package/lib/components/eftpos/icon/apiKey.d.ts +5 -0
- package/lib/components/eftpos/icon/apiKey.js +57 -0
- package/lib/components/eftpos/icon/device.d.ts +5 -0
- package/lib/components/eftpos/icon/device.js +57 -0
- package/lib/components/eftpos/index.d.ts +10 -0
- package/lib/components/eftpos/index.js +262 -97
- package/lib/components/eftpos/index.less +38 -1
- package/lib/components/eftpos/locales.d.ts +12 -0
- package/lib/components/eftpos/locales.js +15 -3
- package/lib/components/eftpos/log.d.ts +8 -0
- package/lib/components/eftpos/log.js +87 -0
- package/lib/components/eftpos/pos.d.ts +1 -1
- package/lib/components/eftpos/pos.js +5 -4
- package/lib/components/eftpos/surcharge/index.d.ts +25 -2
- package/lib/components/eftpos/surcharge/index.js +36 -6
- package/lib/components/eftpos/table.d.ts +4 -0
- package/lib/components/eftpos/table.js +40 -8
- package/lib/components/eftposPay/amount.d.ts +7 -1
- package/lib/components/eftposPay/amount.js +10 -33
- package/lib/components/eftposPay/component/fail/failCustom.js +27 -6
- package/lib/components/eftposPay/component/fail/index.js +39 -18
- package/lib/components/eftposPay/component/fail/network.d.ts +5 -0
- package/lib/components/eftposPay/component/fail/unknow.d.ts +6 -0
- package/lib/components/eftposPay/component/fail/unknow.js +3 -3
- package/lib/components/eftposPay/component/header/index.d.ts +2 -1
- package/lib/components/eftposPay/component/header/index.js +2 -1
- package/lib/components/eftposPay/component/header/index.less +1 -10
- package/lib/components/eftposPay/component/manual/index.d.ts +6 -1
- package/lib/components/eftposPay/component/manual/index.js +122 -31
- package/lib/components/eftposPay/component/manual/index.less +42 -14
- package/lib/components/eftposPay/component/signature/index.d.ts +5 -0
- package/lib/components/eftposPay/component/signature/index.js +2 -2
- package/lib/components/eftposPay/component/step/index.d.ts +7 -7
- package/lib/components/eftposPay/component/step/step.d.ts +4 -4
- package/lib/components/eftposPay/const.d.ts +19 -4
- package/lib/components/eftposPay/const.js +3 -1
- package/lib/components/eftposPay/device.d.ts +7 -0
- package/lib/components/eftposPay/helper.d.ts +54 -0
- package/lib/components/eftposPay/helper.js +64 -0
- package/lib/components/eftposPay/hooks.d.ts +30 -1
- package/lib/components/eftposPay/hooks.js +182 -44
- package/lib/components/eftposPay/index.d.ts +2 -4
- package/lib/components/eftposPay/index.js +74 -27
- package/lib/components/eftposPay/index.less +27 -19
- package/lib/components/eftposPay/locales.d.ts +45 -0
- package/lib/components/eftposPay/locales.js +352 -3
- package/lib/components/eftposPay/manufacturer.d.ts +2 -2
- package/lib/components/eftposPay/manufacturer.js +13 -13
- package/lib/components/eftposPay/pay.d.ts +10 -1
- package/lib/components/eftposPay/pay.js +86 -25
- package/lib/components/eftposPay/payo/config.js +121 -268
- package/lib/components/eftposPay/payo/const.d.ts +22 -2
- package/lib/components/eftposPay/payo/const.js +55 -36
- package/lib/components/eftposPay/payo/hooks.d.ts +5 -0
- package/lib/components/eftposPay/payo/hooks.js +1 -1
- package/lib/components/eftposPay/store/index.d.ts +154 -53
- package/lib/components/eftposPay/store/index.js +7 -66
- package/lib/components/eftposPay/tyro/const.d.ts +17 -0
- package/lib/components/eftposPay/tyro/const.js +114 -0
- package/lib/components/eftposPay/tyro/hooks.d.ts +14 -0
- package/lib/components/eftposPay/{eftpos/index.js → tyro/hooks.js} +31 -36
- package/lib/components/eftposPay/tyro/index.d.ts +9 -0
- package/lib/components/eftposPay/tyro/index.js +558 -0
- package/lib/components/eftposPay/windcave/const.d.ts +24 -9
- package/lib/components/eftposPay/windcave/const.js +53 -104
- package/lib/components/eftposPay/windcave/helper.d.ts +16 -2
- package/lib/components/eftposPay/windcave/helper.js +163 -48
- package/lib/components/eftposPay/windcave/receiptAction.d.ts +12 -0
- package/lib/components/eftposPay/windcave/receiptAction.js +15 -47
- package/lib/components/eftposPay/windcave/timer.d.ts +13 -1
- package/lib/components/eftposPay/windcave/timer.js +5 -0
- package/lib/components/eftposPay/windcave/windcave.d.ts +2 -1
- package/lib/components/eftposPay/windcave/windcave.js +130 -130
- package/lib/utils/load.d.ts +11 -0
- package/lib/utils/load.js +100 -0
- package/lowcode/eftpos/meta.ts +202 -160
- package/lowcode/eftpos-pay/meta.ts +45 -12
- package/package.json +4 -4
- package/es/components/eftposPay/eftpos/config.d.ts +0 -11
- package/es/components/eftposPay/eftpos/config.js +0 -178
- package/es/components/eftposPay/eftpos/const.d.ts +0 -10
- package/es/components/eftposPay/eftpos/index.d.ts +0 -7
- package/es/components/eftposPay/eftpos/index.js +0 -35
- package/es/components/eftposPay/windcave/action.d.ts +0 -8
- package/es/components/eftposPay/windcave/action.js +0 -104
- package/es/components/eftposPay/windcave/hook.d.ts +0 -14
- package/es/components/eftposPay/windcave/index.d.ts +0 -8
- package/es/components/eftposPay/windcave/index.js +0 -49
- package/es/components/eftposPay/windcave/pos.d.ts +0 -8
- package/es/components/eftposPay/windcave/pos.js +0 -180
- package/es/components/eftposPay/windcave/pwd.d.ts +0 -8
- package/es/components/eftposPay/windcave/pwd.js +0 -124
- package/es/components/eftposPay/windcave/receipet.d.ts +0 -6
- package/es/components/eftposPay/windcave/receipet.js +0 -67
- package/es/components/eftposPay/windcave/wait.d.ts +0 -12
- package/es/components/eftposPay/windcave/wait.js +0 -139
- package/lib/components/eftposPay/eftpos/config.d.ts +0 -11
- package/lib/components/eftposPay/eftpos/config.js +0 -199
- package/lib/components/eftposPay/eftpos/const.d.ts +0 -10
- package/lib/components/eftposPay/eftpos/const.js +0 -165
- package/lib/components/eftposPay/eftpos/index.d.ts +0 -7
- package/lib/components/eftposPay/windcave/action.d.ts +0 -8
- package/lib/components/eftposPay/windcave/action.js +0 -143
- package/lib/components/eftposPay/windcave/hook.d.ts +0 -14
- package/lib/components/eftposPay/windcave/hook.js +0 -139
- package/lib/components/eftposPay/windcave/index.d.ts +0 -8
- package/lib/components/eftposPay/windcave/index.js +0 -78
- package/lib/components/eftposPay/windcave/pos.d.ts +0 -8
- package/lib/components/eftposPay/windcave/pos.js +0 -197
- package/lib/components/eftposPay/windcave/pwd.d.ts +0 -8
- package/lib/components/eftposPay/windcave/pwd.js +0 -143
- package/lib/components/eftposPay/windcave/receipet.d.ts +0 -6
- package/lib/components/eftposPay/windcave/receipet.js +0 -93
- package/lib/components/eftposPay/windcave/wait.d.ts +0 -12
- package/lib/components/eftposPay/windcave/wait.js +0 -163
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
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
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/eftposPay/tyro/index.tsx
|
|
30
|
+
var tyro_exports = {};
|
|
31
|
+
__export(tyro_exports, {
|
|
32
|
+
default: () => tyro_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(tyro_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_hooks = require("./hooks");
|
|
37
|
+
var import_utils = require("@pisell/utils");
|
|
38
|
+
var import_antd = require("antd");
|
|
39
|
+
var import_store = require("../store");
|
|
40
|
+
var import_const = require("../const");
|
|
41
|
+
var import_decimal = require("decimal.js");
|
|
42
|
+
var import_helper = require("../helper");
|
|
43
|
+
var import_step = __toESM(require("../component/step/step"));
|
|
44
|
+
var import_hooks2 = require("../hooks");
|
|
45
|
+
var Minute = 1e3 * 60;
|
|
46
|
+
var tyro_default = ({
|
|
47
|
+
api,
|
|
48
|
+
onChange,
|
|
49
|
+
children,
|
|
50
|
+
url,
|
|
51
|
+
version
|
|
52
|
+
}) => {
|
|
53
|
+
const { eftpos, custom, mode, status: payStatus } = (0, import_store.useContextData)();
|
|
54
|
+
const dispatch = (0, import_store.useDispatch)();
|
|
55
|
+
const [status, setStatus] = (0, import_react.useState)(-1);
|
|
56
|
+
const [isManually, setManually] = (0, import_react.useState)(false);
|
|
57
|
+
const isCancelRef = (0, import_react.useRef)(false);
|
|
58
|
+
const { deviceRef, payRef, numRef, modeRef, orderIdRef, amountRef } = (0, import_hooks2.useStoreRef)();
|
|
59
|
+
const merchantReceiptRef = (0, import_react.useRef)({});
|
|
60
|
+
const [TyroRef, load] = (0, import_hooks.useTyro)({ url, version });
|
|
61
|
+
const requestParams = (0, import_react.useRef)(custom == null ? void 0 : custom.requestParams);
|
|
62
|
+
const listRef = (0, import_react.useRef)((custom == null ? void 0 : custom.list) || []);
|
|
63
|
+
const iClientRef = (0, import_react.useRef)();
|
|
64
|
+
const unloadRef = (0, import_react.useRef)(false);
|
|
65
|
+
const clearRef = (0, import_react.useRef)();
|
|
66
|
+
(0, import_react.useEffect)(() => {
|
|
67
|
+
listRef.current = (custom == null ? void 0 : custom.list) || [];
|
|
68
|
+
}, [custom == null ? void 0 : custom.list]);
|
|
69
|
+
(0, import_react.useEffect)(() => {
|
|
70
|
+
requestParams.current = custom == null ? void 0 : custom.requestParams;
|
|
71
|
+
}, [custom == null ? void 0 : custom.requestParams]);
|
|
72
|
+
const getTerminalInfo = (cb) => {
|
|
73
|
+
const iClient = iClientRef.current;
|
|
74
|
+
if (!iClient) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
setStatus(0);
|
|
78
|
+
const { connection } = deviceRef.current;
|
|
79
|
+
const { integrationKey, tid, mid } = connection;
|
|
80
|
+
console.log(integrationKey, tid, mid);
|
|
81
|
+
iClient.terminalInfo(
|
|
82
|
+
({ status: status2, message, terminalInfo }) => {
|
|
83
|
+
if (status2 === "success" && (terminalInfo == null ? void 0 : terminalInfo.available)) {
|
|
84
|
+
cb();
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
mid,
|
|
89
|
+
tid,
|
|
90
|
+
integrationKey
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
const refundOrder = () => {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
const iClient = iClientRef.current;
|
|
97
|
+
if (!iClient) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (isCancelRef.current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { connection } = deviceRef.current;
|
|
104
|
+
const { integrationKey, tid, mid } = connection;
|
|
105
|
+
numRef.current = (0, import_helper.getUuid)();
|
|
106
|
+
dispatch(
|
|
107
|
+
(0, import_store.updateState)({
|
|
108
|
+
number: numRef.current
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
requestParams.current = {
|
|
112
|
+
amount: new import_decimal.Decimal(amountRef.current || 0).mul(100).toFixed(0, import_decimal.Decimal.ROUND_HALF_UP),
|
|
113
|
+
// 打印小票 true 打印到系统上 false 打印到pos机上
|
|
114
|
+
integratedReceipt: !((_b = (_a = deviceRef.current) == null ? void 0 : _a.setting) == null ? void 0 : _b.receipts),
|
|
115
|
+
integrationKey,
|
|
116
|
+
transactionId: numRef.current,
|
|
117
|
+
mid,
|
|
118
|
+
tid
|
|
119
|
+
};
|
|
120
|
+
dispatch(
|
|
121
|
+
(0, import_store.updateCustom)({
|
|
122
|
+
requestParams: requestParams.current
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
setStatus(Date.now());
|
|
126
|
+
merchantReceiptRef.current = {};
|
|
127
|
+
iClient.initiateRefund(requestParams.current, {
|
|
128
|
+
receiptCallback: receiptCallbackImpl,
|
|
129
|
+
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
130
|
+
questionCallback: questionCallbackImpl,
|
|
131
|
+
statusMessageCallback: statusMessageCallbackImpl
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const payOrder = () => {
|
|
135
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
136
|
+
const iClient = iClientRef.current;
|
|
137
|
+
if (!iClient) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (isCancelRef.current) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const { connection } = deviceRef.current;
|
|
144
|
+
const { integrationKey, tid, mid } = connection;
|
|
145
|
+
numRef.current = (0, import_helper.getUuid)();
|
|
146
|
+
dispatch(
|
|
147
|
+
(0, import_store.updateState)({
|
|
148
|
+
number: numRef.current
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
console.log(
|
|
152
|
+
"deviceRef.current?.settings?.useOriginSurcharge = ",
|
|
153
|
+
(_b = (_a = deviceRef.current) == null ? void 0 : _a.setting) == null ? void 0 : _b.useOriginSurcharge
|
|
154
|
+
);
|
|
155
|
+
requestParams.current = {
|
|
156
|
+
amount: new import_decimal.Decimal((_c = payRef.current) == null ? void 0 : _c.total).mul(100).toFixed(0, import_decimal.Decimal.ROUND_HALF_UP),
|
|
157
|
+
// 手续费 true tyro 手续费, false 系统手续费
|
|
158
|
+
enableSurcharge: ((_e = (_d = deviceRef.current) == null ? void 0 : _d.setting) == null ? void 0 : _e.useOriginSurcharge) || false,
|
|
159
|
+
// 打印小票 true 打印到系统上 false 打印到pos机上
|
|
160
|
+
integratedReceipt: !((_g = (_f = deviceRef.current) == null ? void 0 : _f.setting) == null ? void 0 : _g.receipts),
|
|
161
|
+
integrationKey,
|
|
162
|
+
transactionId: numRef.current,
|
|
163
|
+
mid,
|
|
164
|
+
tid
|
|
165
|
+
};
|
|
166
|
+
dispatch(
|
|
167
|
+
(0, import_store.updateCustom)({
|
|
168
|
+
requestParams: requestParams.current
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
setStatus(Date.now());
|
|
172
|
+
merchantReceiptRef.current = {};
|
|
173
|
+
iClient.initiatePurchase(requestParams.current, {
|
|
174
|
+
receiptCallback: receiptCallbackImpl,
|
|
175
|
+
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
176
|
+
questionCallback: questionCallbackImpl,
|
|
177
|
+
statusMessageCallback: statusMessageCallbackImpl
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
const continueLastOrder = () => {
|
|
181
|
+
const iClient = iClientRef.current;
|
|
182
|
+
if (!iClient) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (isCancelRef.current) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
setStatus(Date.now());
|
|
189
|
+
merchantReceiptRef.current = {};
|
|
190
|
+
iClient.continueLastTransaction({
|
|
191
|
+
receiptCallback: receiptCallbackImpl,
|
|
192
|
+
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
193
|
+
questionCallback: questionCallbackImpl,
|
|
194
|
+
statusMessageCallback: statusMessageCallbackImpl
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
const receiptCallbackImpl = ({ signatureRequired, merchantReceipt }) => {
|
|
198
|
+
console.log("商家小票 客户端是否打印小票 = ", signatureRequired);
|
|
199
|
+
console.log("商家小票 小票内容 = \n", merchantReceipt);
|
|
200
|
+
if (signatureRequired) {
|
|
201
|
+
const receipt = [merchantReceipt].filter((item) => typeof item === "string").filter(Boolean);
|
|
202
|
+
onChange("print", receipt);
|
|
203
|
+
}
|
|
204
|
+
merchantReceiptRef.current = { signatureRequired, merchantReceipt };
|
|
205
|
+
};
|
|
206
|
+
const statusMessageCallbackImpl = (message) => {
|
|
207
|
+
var _a;
|
|
208
|
+
const translateMsg = import_utils.locales.getText("page.eftpos-pay.text.tyro")(message);
|
|
209
|
+
const msg = Array.isArray(translateMsg) ? translateMsg.reduce(
|
|
210
|
+
(accumulator, currentValue) => accumulator + " " + currentValue,
|
|
211
|
+
""
|
|
212
|
+
) : translateMsg;
|
|
213
|
+
const lastitem = listRef.current[listRef.current.length - 1];
|
|
214
|
+
const key = import_utils.locales.getText("page.eftpos-pay.text.tyro")(
|
|
215
|
+
"Connection lost. Attempting to recover"
|
|
216
|
+
);
|
|
217
|
+
if (msg === key && lastitem && lastitem.pedding === key) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
console.log("message = ", message);
|
|
221
|
+
console.log("msg = ", msg);
|
|
222
|
+
dispatch(
|
|
223
|
+
(0, import_store.updateCustom)({
|
|
224
|
+
list: [
|
|
225
|
+
...listRef.current || [],
|
|
226
|
+
{
|
|
227
|
+
status: "pendding",
|
|
228
|
+
pedding: msg,
|
|
229
|
+
resolve: msg,
|
|
230
|
+
reject: msg,
|
|
231
|
+
index: ((_a = listRef.current) == null ? void 0 : _a.length) || 0
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
const questionCallbackImpl = (question, answerCallback) => {
|
|
238
|
+
console.log("Question is " + JSON.stringify(question));
|
|
239
|
+
setStatus(-1);
|
|
240
|
+
setManually(false);
|
|
241
|
+
const msg = import_utils.locales.getText("page.eftpos-pay.text.tyro")(question.text);
|
|
242
|
+
dispatch(
|
|
243
|
+
(0, import_store.updateCustom)({
|
|
244
|
+
btnList: question.options.map((item) => {
|
|
245
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
246
|
+
import_antd.Button,
|
|
247
|
+
{
|
|
248
|
+
key: item,
|
|
249
|
+
type: item === "YES" || item === "RETRY" ? "primary" : "default",
|
|
250
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
251
|
+
onClick: () => {
|
|
252
|
+
dispatch(
|
|
253
|
+
(0, import_store.updateCustom)({
|
|
254
|
+
btnList: []
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
setManually(false);
|
|
258
|
+
dispatch(
|
|
259
|
+
(0, import_store.updateState)({
|
|
260
|
+
status: "loading",
|
|
261
|
+
title: import_utils.locales.getText("page.eftpos-pay.text.loading")(
|
|
262
|
+
modeRef.current || import_const.ModeEnum.Pay
|
|
263
|
+
),
|
|
264
|
+
subTitle: ""
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
setStatus(Date.now());
|
|
268
|
+
answerCallback(item);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
import_utils.locales.getText("page.eftpos-pay.text.tyro-btn")(item)
|
|
272
|
+
);
|
|
273
|
+
})
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
const status2 = question.isError ? "fail" : "warn";
|
|
277
|
+
dispatch(
|
|
278
|
+
(0, import_store.updateState)(
|
|
279
|
+
Array.isArray(msg) ? {
|
|
280
|
+
status: status2,
|
|
281
|
+
title: msg[0],
|
|
282
|
+
subTitle: msg[1]
|
|
283
|
+
} : {
|
|
284
|
+
status: status2,
|
|
285
|
+
title: msg
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
const transactionCompleteCallbackImpl = (response) => {
|
|
291
|
+
var _a;
|
|
292
|
+
setStatus(-1);
|
|
293
|
+
setManually(false);
|
|
294
|
+
console.log(
|
|
295
|
+
"Response = " + JSON.stringify(response),
|
|
296
|
+
", Request = ",
|
|
297
|
+
JSON.stringify(requestParams.current)
|
|
298
|
+
);
|
|
299
|
+
console.log(
|
|
300
|
+
" 客户小票 response.customerReceipt = \n",
|
|
301
|
+
response.customerReceipt
|
|
302
|
+
);
|
|
303
|
+
const receipt = [
|
|
304
|
+
// merchantReceiptRef.current?.merchantReceipt,
|
|
305
|
+
response == null ? void 0 : response.customerReceipt
|
|
306
|
+
].filter((item) => typeof item === "string").filter(Boolean);
|
|
307
|
+
api.addTransaction({
|
|
308
|
+
order_id: orderIdRef.current,
|
|
309
|
+
number: numRef.current,
|
|
310
|
+
card_reader_id: (_a = deviceRef.current) == null ? void 0 : _a.id,
|
|
311
|
+
card_reader_type: eftpos,
|
|
312
|
+
amount: requestParams.current.amount,
|
|
313
|
+
action: modeRef.current,
|
|
314
|
+
status: response.result === "APPROVED" ? "succeed" : "failed",
|
|
315
|
+
request: requestParams.current,
|
|
316
|
+
response: { ...response, merchantReceipt: merchantReceiptRef.current },
|
|
317
|
+
metadata: {
|
|
318
|
+
receipt
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
dispatch(
|
|
322
|
+
(0, import_store.updateCustom)({
|
|
323
|
+
btnList: []
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
if (response.result === "APPROVED") {
|
|
327
|
+
dispatch(
|
|
328
|
+
(0, import_store.updateState)({
|
|
329
|
+
status: "success",
|
|
330
|
+
title: import_utils.locales.getText("page.eftpos-pay.text.successful")(mode),
|
|
331
|
+
subTitle: ""
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
dispatch(
|
|
335
|
+
(0, import_store.updateCustom)({
|
|
336
|
+
card_reader_surcharge: response.surchargeAmount || 0
|
|
337
|
+
})
|
|
338
|
+
);
|
|
339
|
+
clearRef.current = setTimeout(() => {
|
|
340
|
+
var _a2;
|
|
341
|
+
const params = (0, import_helper.getPayParams)(
|
|
342
|
+
{
|
|
343
|
+
mode: modeRef.current,
|
|
344
|
+
amount: amountRef.current,
|
|
345
|
+
order_id: orderIdRef.current,
|
|
346
|
+
number: numRef.current,
|
|
347
|
+
device: deviceRef.current,
|
|
348
|
+
pay: payRef.current,
|
|
349
|
+
custom: {
|
|
350
|
+
card_reader_surcharge: response.surchargeAmount || 0
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"success"
|
|
354
|
+
);
|
|
355
|
+
onChange("success", {
|
|
356
|
+
...params,
|
|
357
|
+
receipt: ((_a2 = deviceRef.current) == null ? void 0 : _a2.setting.receipts) ? [] : receipt
|
|
358
|
+
});
|
|
359
|
+
}, 1e3);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (response.result === "UNKNOWN") {
|
|
363
|
+
dispatch(
|
|
364
|
+
(0, import_store.updateCustom)({
|
|
365
|
+
errorStatus: "unknow"
|
|
366
|
+
// unknow know unknown
|
|
367
|
+
})
|
|
368
|
+
);
|
|
369
|
+
dispatch((0, import_store.updateComponent)("UnknowFail"));
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
dispatch(
|
|
373
|
+
(0, import_store.updateState)({
|
|
374
|
+
status: "fail"
|
|
375
|
+
})
|
|
376
|
+
);
|
|
377
|
+
dispatch(
|
|
378
|
+
(0, import_store.updateCustom)({
|
|
379
|
+
failCustom: {
|
|
380
|
+
isPosNetworkError: false,
|
|
381
|
+
status: "fail",
|
|
382
|
+
fail: import_utils.locales.getText("page.eftpos-pay.text.transaction.fail"),
|
|
383
|
+
warn: null,
|
|
384
|
+
title: import_utils.locales.getText("page.eftpos-pay.text.failed")(
|
|
385
|
+
modeRef.current
|
|
386
|
+
)
|
|
387
|
+
}
|
|
388
|
+
})
|
|
389
|
+
);
|
|
390
|
+
dispatch((0, import_store.updateComponent)("FailCustom"));
|
|
391
|
+
};
|
|
392
|
+
(0, import_react.useEffect)(() => {
|
|
393
|
+
const { config } = deviceRef.current;
|
|
394
|
+
const { apiKey, posProductData } = config;
|
|
395
|
+
if (load && TyroRef.current) {
|
|
396
|
+
const IClient = TyroRef.current.IClient;
|
|
397
|
+
if (IClient) {
|
|
398
|
+
const iclient = new IClient(apiKey, posProductData);
|
|
399
|
+
iClientRef.current = iclient;
|
|
400
|
+
if (isCancelRef.current) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (!numRef.current) {
|
|
404
|
+
if (modeRef.current === import_const.ModeEnum.Pay) {
|
|
405
|
+
getTerminalInfo(payOrder);
|
|
406
|
+
} else if (modeRef.current === import_const.ModeEnum.Refund) {
|
|
407
|
+
getTerminalInfo(refundOrder);
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
getTerminalInfo(continueLastOrder);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}, [load]);
|
|
415
|
+
(0, import_react.useEffect)(() => {
|
|
416
|
+
let clear;
|
|
417
|
+
if (status === -1) {
|
|
418
|
+
return () => {
|
|
419
|
+
if (clear) {
|
|
420
|
+
clearTimeout(clear);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
if (status === 0) {
|
|
425
|
+
console.log("开始倒计时...");
|
|
426
|
+
clear = setTimeout(() => {
|
|
427
|
+
dispatch(
|
|
428
|
+
(0, import_store.updateState)({
|
|
429
|
+
status: "fail"
|
|
430
|
+
})
|
|
431
|
+
);
|
|
432
|
+
dispatch(
|
|
433
|
+
(0, import_store.updateCustom)({
|
|
434
|
+
failCustom: {
|
|
435
|
+
status: "fail",
|
|
436
|
+
fail: import_utils.locales.getText(
|
|
437
|
+
"page.eftpos-pay.text.transaction.pay.fail.timeout"
|
|
438
|
+
),
|
|
439
|
+
title: import_utils.locales.getText(
|
|
440
|
+
"page.eftpos-pay.text.transaction.fail.timeout"
|
|
441
|
+
),
|
|
442
|
+
warn: null
|
|
443
|
+
}
|
|
444
|
+
})
|
|
445
|
+
);
|
|
446
|
+
dispatch((0, import_store.updateComponent)("FailCustom"));
|
|
447
|
+
}, Minute);
|
|
448
|
+
return () => {
|
|
449
|
+
if (clear) {
|
|
450
|
+
clearTimeout(clear);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
clear = setTimeout(() => {
|
|
455
|
+
const iClient = iClientRef.current;
|
|
456
|
+
if (!iClient) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
console.log("倒计时到了");
|
|
460
|
+
setManually(true);
|
|
461
|
+
}, Minute);
|
|
462
|
+
return () => {
|
|
463
|
+
if (clear) {
|
|
464
|
+
clearTimeout(clear);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
}, [status]);
|
|
468
|
+
const onManually = () => {
|
|
469
|
+
dispatch(
|
|
470
|
+
(0, import_store.updateState)({
|
|
471
|
+
manual: {
|
|
472
|
+
title: import_utils.locales.getText("page.eftpos-pay.text.request.title")(mode),
|
|
473
|
+
text: import_utils.locales.getText("page.eftpos-pay.text.request.text")(mode)
|
|
474
|
+
}
|
|
475
|
+
})
|
|
476
|
+
);
|
|
477
|
+
dispatch((0, import_store.updateComponent)("Manual", true));
|
|
478
|
+
};
|
|
479
|
+
const onCancel = () => {
|
|
480
|
+
const iClient = iClientRef.current;
|
|
481
|
+
if (!iClient) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (status > 0) {
|
|
485
|
+
iClient.cancelCurrentTransaction();
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (isCancelRef.current) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
isCancelRef.current = true;
|
|
492
|
+
dispatch(
|
|
493
|
+
(0, import_store.updateState)({
|
|
494
|
+
status: "fail"
|
|
495
|
+
})
|
|
496
|
+
);
|
|
497
|
+
dispatch(
|
|
498
|
+
(0, import_store.updateCustom)({
|
|
499
|
+
failCustom: {
|
|
500
|
+
status: "fail",
|
|
501
|
+
fail: import_utils.locales.getText(
|
|
502
|
+
"page.eftpos-pay.text.transaction.fail.cancel"
|
|
503
|
+
),
|
|
504
|
+
title: import_utils.locales.getText(
|
|
505
|
+
"page.eftpos-pay.text.transaction.fail.cancel.title"
|
|
506
|
+
),
|
|
507
|
+
warn: null
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
);
|
|
511
|
+
dispatch((0, import_store.updateComponent)("FailCustom"));
|
|
512
|
+
};
|
|
513
|
+
(0, import_react.useEffect)(
|
|
514
|
+
() => () => {
|
|
515
|
+
unloadRef.current = true;
|
|
516
|
+
if (clearRef.current) {
|
|
517
|
+
clearTimeout(clearRef.current);
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
[]
|
|
521
|
+
);
|
|
522
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-body" }, ((custom == null ? void 0 : custom.list) || []).map((item) => /* @__PURE__ */ import_react.default.createElement(
|
|
523
|
+
import_step.default,
|
|
524
|
+
{
|
|
525
|
+
key: item.index,
|
|
526
|
+
pedding: item.pedding,
|
|
527
|
+
resolve: item.resolve,
|
|
528
|
+
reject: item.reject,
|
|
529
|
+
status: item.status
|
|
530
|
+
}
|
|
531
|
+
))), isManually ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ import_react.default.createElement(
|
|
532
|
+
import_antd.Button,
|
|
533
|
+
{
|
|
534
|
+
block: true,
|
|
535
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
536
|
+
onClick: onManually
|
|
537
|
+
},
|
|
538
|
+
import_utils.locales.getText("page.eftpos-pay.text.manual.marking")
|
|
539
|
+
)) : null, /* @__PURE__ */ import_react.default.createElement(
|
|
540
|
+
"div",
|
|
541
|
+
{
|
|
542
|
+
className: "pisell-lowcode__eft-pay-step-item-btns",
|
|
543
|
+
style: { flexWrap: "wrap" }
|
|
544
|
+
},
|
|
545
|
+
Array.isArray(custom == null ? void 0 : custom.btnList) && (custom == null ? void 0 : custom.btnList).length > 0 ? /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "100%", display: "flex", gap: "12px" } }, custom == null ? void 0 : custom.btnList) : null,
|
|
546
|
+
!(payStatus === "success" || payStatus === "fail") ? /* @__PURE__ */ import_react.default.createElement(
|
|
547
|
+
import_antd.Button,
|
|
548
|
+
{
|
|
549
|
+
block: true,
|
|
550
|
+
type: "text",
|
|
551
|
+
disabled: Array.isArray(custom == null ? void 0 : custom.btnList) && (custom == null ? void 0 : custom.btnList).length > 0,
|
|
552
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
553
|
+
onClick: onCancel
|
|
554
|
+
},
|
|
555
|
+
import_utils.locales.getText("page.eftpos-pay.text.manual.cancel")
|
|
556
|
+
) : null
|
|
557
|
+
));
|
|
558
|
+
};
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { Amount } from '../const';
|
|
3
2
|
import { State } from '../store';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @title: 初始化 windcave 数据
|
|
5
|
+
* @return store 全局数据管理
|
|
6
|
+
* @Author: hongbing.wang
|
|
7
|
+
* @Date: 2024-08-12 10:42
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: (params: any) => State;
|
|
10
|
+
export default _default;
|
|
11
|
+
/**
|
|
12
|
+
* @title: windcave 金额信息
|
|
13
|
+
* @description:
|
|
14
|
+
* @param {State} store : 全局store数据管理
|
|
15
|
+
* @return 金额信息
|
|
16
|
+
* @Author: hongbing.wang
|
|
17
|
+
* @Date: 2024-08-12 10:43
|
|
18
|
+
*/
|
|
11
19
|
export declare function getAmonunt(store: State): Amount;
|
|
12
20
|
export declare enum StepStatusEnum {
|
|
13
21
|
/** 空闲 */
|
|
@@ -33,6 +41,13 @@ export declare enum StemTypeEnum {
|
|
|
33
41
|
/** 被动提交 */
|
|
34
42
|
Passive = "passive"
|
|
35
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @title: windcave 步骤信息
|
|
46
|
+
* @description: 步骤对应配置信息
|
|
47
|
+
* @return 步骤配置信息
|
|
48
|
+
* @Author: hongbing.wang
|
|
49
|
+
* @Date: 2024-08-12 10:44
|
|
50
|
+
*/
|
|
36
51
|
export declare const getStepMapping: (type: StepStatusEnum, { money, mode }: {
|
|
37
52
|
money?: string | undefined;
|
|
38
53
|
mode?: string | undefined;
|
|
@@ -87,7 +102,7 @@ export declare const getStepMapping: (type: StepStatusEnum, { money, mode }: {
|
|
|
87
102
|
} | {
|
|
88
103
|
type: StemTypeEnum;
|
|
89
104
|
status: string;
|
|
90
|
-
pedding:
|
|
105
|
+
pedding: string;
|
|
91
106
|
resolve: any;
|
|
92
107
|
reject: any;
|
|
93
108
|
index: StepStatusEnum.Receipt;
|