@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
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
1
6
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
7
|
+
import { Decimal } from 'decimal.js';
|
|
8
|
+
import { ModeEnum } from "./const";
|
|
2
9
|
/* eslint-disable no-bitwise */
|
|
3
10
|
export function getUuid() {
|
|
4
11
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
@@ -7,6 +14,12 @@ export function getUuid() {
|
|
|
7
14
|
return v.toString(16);
|
|
8
15
|
});
|
|
9
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @title: Promise化 setTimeout
|
|
19
|
+
* @param {number} time
|
|
20
|
+
* @Author: hongbing.wang
|
|
21
|
+
* @Date: 2024-08-20 13:03
|
|
22
|
+
*/
|
|
10
23
|
export var sleep = function sleep(time) {
|
|
11
24
|
return new Promise(function (resove) {
|
|
12
25
|
setTimeout(function () {
|
|
@@ -14,6 +27,12 @@ export var sleep = function sleep(time) {
|
|
|
14
27
|
}, time);
|
|
15
28
|
});
|
|
16
29
|
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @title: 克隆
|
|
33
|
+
* @Author: hongbing.wang
|
|
34
|
+
* @Date: 2024-08-20 13:03
|
|
35
|
+
*/
|
|
17
36
|
export function cloneDeep(source) {
|
|
18
37
|
var hash = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
|
|
19
38
|
if (_typeof(source) !== 'object' || source === null) {
|
|
@@ -32,4 +51,77 @@ export function cloneDeep(source) {
|
|
|
32
51
|
}
|
|
33
52
|
});
|
|
34
53
|
return target;
|
|
35
|
-
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @title: 获取支付回调参数
|
|
57
|
+
* @Author: hongbing.wang
|
|
58
|
+
* @Date: 2024-08-20 20:26
|
|
59
|
+
*/
|
|
60
|
+
export var getPayParams = function getPayParams(data, statue) {
|
|
61
|
+
if (statue === 'fail') {
|
|
62
|
+
return {
|
|
63
|
+
number: data.number,
|
|
64
|
+
device: data.device,
|
|
65
|
+
order_id: data.order_id
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (data.mode === ModeEnum.Pay) {
|
|
69
|
+
var _data$custom;
|
|
70
|
+
var pay = data.pay;
|
|
71
|
+
var card_reader_surcharge = ((_data$custom = data.custom) === null || _data$custom === void 0 ? void 0 : _data$custom.card_reader_surcharge) || 0;
|
|
72
|
+
var obj = pay || {};
|
|
73
|
+
var cardReaderSurcharge = card_reader_surcharge;
|
|
74
|
+
// 卡手续费
|
|
75
|
+
var surCardDeci = new Decimal(Number(cardReaderSurcharge));
|
|
76
|
+
|
|
77
|
+
// 手续费-固定金额
|
|
78
|
+
var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
|
|
79
|
+
|
|
80
|
+
// 手续费-比例金额
|
|
81
|
+
var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
|
|
82
|
+
|
|
83
|
+
// 手续费-固定金额 + 卡手续费 = 固定金额总额
|
|
84
|
+
var surMoneyTotal = surMoneyDeci.add(surCardDeci);
|
|
85
|
+
|
|
86
|
+
// 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
|
|
87
|
+
var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
|
|
88
|
+
var amount = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.amount));
|
|
89
|
+
var total = surchargeDeci.add(amount);
|
|
90
|
+
return _objectSpread(_objectSpread({}, obj), {}, {
|
|
91
|
+
cardReaderSurcharge: cardReaderSurcharge,
|
|
92
|
+
surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
|
|
93
|
+
surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP),
|
|
94
|
+
total: total.toFixed(2, Decimal.ROUND_HALF_UP),
|
|
95
|
+
number: data.number,
|
|
96
|
+
device: data.device,
|
|
97
|
+
order_id: data.order_id
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (data.mode === ModeEnum.Refund) {
|
|
101
|
+
return {
|
|
102
|
+
amount: data.amount,
|
|
103
|
+
total: data.amount,
|
|
104
|
+
number: data.number,
|
|
105
|
+
device: data.device,
|
|
106
|
+
order_id: data.order_id
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
amount: data.amount,
|
|
111
|
+
total: data.amount,
|
|
112
|
+
number: data.number,
|
|
113
|
+
order_id: data.order_id
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// inputNumber过滤
|
|
118
|
+
export var limitDecimals = function limitDecimals(value) {
|
|
119
|
+
var reg = /^(\-)*(\d+)\.(\d\d).*$/;
|
|
120
|
+
if (typeof value === 'string') {
|
|
121
|
+
return !isNaN(Number(value)) ? value.replace(reg, '$1$2.$3') : '';
|
|
122
|
+
}
|
|
123
|
+
if (typeof value === 'number') {
|
|
124
|
+
return !isNaN(value) ? String(value).replace(reg, '$1$2.$3') : '';
|
|
125
|
+
}
|
|
126
|
+
return '';
|
|
127
|
+
};
|
|
@@ -1,4 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { PayStatus } from './const';
|
|
3
|
+
import { ModeEnum } from './const';
|
|
4
|
+
export declare const useStoreRef: <T extends {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
} = {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}, U extends {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
} = {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}>() => {
|
|
13
|
+
readonly deviceRef: React.MutableRefObject<T>;
|
|
14
|
+
readonly payRef: React.MutableRefObject<U>;
|
|
15
|
+
readonly numRef: React.MutableRefObject<string | number | undefined>;
|
|
16
|
+
readonly orderIdRef: React.MutableRefObject<string | number>;
|
|
17
|
+
readonly modeRef: React.MutableRefObject<ModeEnum>;
|
|
18
|
+
readonly statusRef: React.MutableRefObject<"loading" | "success" | "warn" | "fail" | "pedding" | "resove" | "reject" | "question">;
|
|
19
|
+
readonly netRef: React.MutableRefObject<boolean | undefined>;
|
|
20
|
+
readonly symbolRef: React.MutableRefObject<string>;
|
|
21
|
+
readonly amountRef: React.MutableRefObject<string | number>;
|
|
22
|
+
readonly eftposRef: React.MutableRefObject<"windcave" | "tyro" | "payo" | "stripe">;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* @title: 通用失败处理
|
|
26
|
+
* @description: 固定步骤 错误处理逻辑
|
|
27
|
+
* @return null
|
|
28
|
+
* @Author: hongbing.wang
|
|
29
|
+
* @Date: 2024-08-12 11:54
|
|
30
|
+
*/
|
|
2
31
|
export declare const useFail: (index: number, isMark?: boolean) => (res: {
|
|
3
|
-
code?: "200" | "4004" | "701000" | "701001" | "701003" | "701004" | "701005" | "701006" | "701007" | undefined;
|
|
32
|
+
code?: "200" | "4004" | "701000" | "701001" | "701003" | "701004" | "701005" | "701006" | "701007" | "701008" | "701009" | "701010" | undefined;
|
|
4
33
|
}) => void;
|
|
@@ -5,16 +5,111 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
6
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
import { locales } from '@pisell/utils';
|
|
8
|
-
import
|
|
8
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
9
9
|
import { PayStatus } from "./const";
|
|
10
|
-
import { useContextData, useDispatch, updateComponent, updateSteps, updateState, updateCustom,
|
|
10
|
+
import { useContextData, useDispatch, updateComponent, updateSteps, updateState, updateCustom, updateKey } from "./store";
|
|
11
11
|
var Max4004 = 1;
|
|
12
|
+
|
|
13
|
+
// 穿越 react deep
|
|
14
|
+
export var useStoreRef = function useStoreRef() {
|
|
15
|
+
var _useContextData = useContextData(),
|
|
16
|
+
order_id = _useContextData.order_id,
|
|
17
|
+
device = _useContextData.device,
|
|
18
|
+
pay = _useContextData.pay,
|
|
19
|
+
number = _useContextData.number,
|
|
20
|
+
mode = _useContextData.mode,
|
|
21
|
+
net = _useContextData.net,
|
|
22
|
+
status = _useContextData.status,
|
|
23
|
+
symbol = _useContextData.symbol,
|
|
24
|
+
amount = _useContextData.amount,
|
|
25
|
+
eftpos = _useContextData.eftpos;
|
|
26
|
+
// 设备信息
|
|
27
|
+
var deviceRef = useRef(device);
|
|
28
|
+
|
|
29
|
+
// 支付金额信息
|
|
30
|
+
var payRef = useRef(pay);
|
|
31
|
+
|
|
32
|
+
// 支付流水号
|
|
33
|
+
var numRef = useRef(number);
|
|
34
|
+
|
|
35
|
+
// 订单id
|
|
36
|
+
var orderIdRef = useRef(order_id);
|
|
37
|
+
|
|
38
|
+
// 退款 or 支付
|
|
39
|
+
var modeRef = useRef(mode);
|
|
40
|
+
|
|
41
|
+
// 页面状态 成功 or 失败 or 加载 ...
|
|
42
|
+
var statusRef = useRef(status);
|
|
43
|
+
|
|
44
|
+
// 网络状态
|
|
45
|
+
var netRef = useRef(net);
|
|
46
|
+
|
|
47
|
+
// 金额单位
|
|
48
|
+
var symbolRef = useRef(symbol);
|
|
49
|
+
|
|
50
|
+
// 原始支付金额
|
|
51
|
+
var amountRef = useRef(amount);
|
|
52
|
+
|
|
53
|
+
// 设备类型
|
|
54
|
+
var eftposRef = useRef(eftpos);
|
|
55
|
+
useEffect(function () {
|
|
56
|
+
deviceRef.current = device;
|
|
57
|
+
}, [device]);
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
payRef.current = pay;
|
|
60
|
+
}, [pay]);
|
|
61
|
+
useEffect(function () {
|
|
62
|
+
numRef.current = number;
|
|
63
|
+
}, [number]);
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
orderIdRef.current = order_id;
|
|
66
|
+
}, [order_id]);
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
modeRef.current = mode;
|
|
69
|
+
}, [mode]);
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
statusRef.current = status;
|
|
72
|
+
}, [status]);
|
|
73
|
+
useEffect(function () {
|
|
74
|
+
netRef.current = net;
|
|
75
|
+
}, [net]);
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
symbolRef.current = symbol;
|
|
78
|
+
}, [symbol]);
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
amountRef.current = amount;
|
|
81
|
+
}, [amount]);
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
eftposRef.current = eftpos;
|
|
84
|
+
}, [eftpos]);
|
|
85
|
+
return {
|
|
86
|
+
deviceRef: deviceRef,
|
|
87
|
+
payRef: payRef,
|
|
88
|
+
numRef: numRef,
|
|
89
|
+
orderIdRef: orderIdRef,
|
|
90
|
+
modeRef: modeRef,
|
|
91
|
+
statusRef: statusRef,
|
|
92
|
+
netRef: netRef,
|
|
93
|
+
symbolRef: symbolRef,
|
|
94
|
+
amountRef: amountRef,
|
|
95
|
+
eftposRef: eftposRef
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @title: 通用失败处理
|
|
101
|
+
* @description: 固定步骤 错误处理逻辑
|
|
102
|
+
* @return null
|
|
103
|
+
* @Author: hongbing.wang
|
|
104
|
+
* @Date: 2024-08-12 11:54
|
|
105
|
+
*/
|
|
12
106
|
export var useFail = function useFail(index) {
|
|
13
107
|
var isMark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
14
|
-
var
|
|
15
|
-
steps =
|
|
16
|
-
custom =
|
|
17
|
-
|
|
108
|
+
var _useContextData2 = useContextData(),
|
|
109
|
+
steps = _useContextData2.steps,
|
|
110
|
+
custom = _useContextData2.custom;
|
|
111
|
+
var _useStoreRef = useStoreRef(),
|
|
112
|
+
modeRef = _useStoreRef.modeRef;
|
|
18
113
|
var dispatch = useDispatch();
|
|
19
114
|
var ref = useRef((custom === null || custom === void 0 ? void 0 : custom.retry) || 0);
|
|
20
115
|
useEffect(function () {
|
|
@@ -22,6 +117,7 @@ export var useFail = function useFail(index) {
|
|
|
22
117
|
}, [custom === null || custom === void 0 ? void 0 : custom.retry]);
|
|
23
118
|
return useCallback(function (res) {
|
|
24
119
|
if (!res || !res.code) {
|
|
120
|
+
// 去往未知处理页面
|
|
25
121
|
dispatch(updateCustom({
|
|
26
122
|
errorStatus: 'unknow' // unknow know
|
|
27
123
|
}));
|
|
@@ -30,11 +126,9 @@ export var useFail = function useFail(index) {
|
|
|
30
126
|
return;
|
|
31
127
|
}
|
|
32
128
|
var code = "".concat(res.code);
|
|
33
|
-
dispatch(updateCustomStemItem({
|
|
34
|
-
step: index
|
|
35
|
-
}));
|
|
36
129
|
if (code === PayStatus.Unknown) {
|
|
37
|
-
|
|
130
|
+
// 前往报错页 不可标记
|
|
131
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(modeRef.current);
|
|
38
132
|
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail');
|
|
39
133
|
steps[index].status = 'fail';
|
|
40
134
|
dispatch(updateSteps(steps));
|
|
@@ -45,14 +139,28 @@ export var useFail = function useFail(index) {
|
|
|
45
139
|
|
|
46
140
|
return;
|
|
47
141
|
}
|
|
48
|
-
if (code === PayStatus.
|
|
142
|
+
if (code === PayStatus.PayTimeout) {
|
|
143
|
+
// 前往错误页 不可标记状态
|
|
144
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail.timeout');
|
|
145
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(modeRef.current);
|
|
146
|
+
steps[index].status = 'fail';
|
|
147
|
+
dispatch(updateSteps(steps));
|
|
148
|
+
dispatch(updateComponent('Fail'));
|
|
149
|
+
dispatch(updateCustom({
|
|
150
|
+
errorStatus: 'know' // unknow know
|
|
151
|
+
}));
|
|
152
|
+
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (code === PayStatus.Timeout) {
|
|
49
156
|
if (isMark) {
|
|
157
|
+
// 超时 前往标记页
|
|
50
158
|
steps[index].status = 'fail';
|
|
51
159
|
dispatch(updateSteps(steps));
|
|
52
160
|
dispatch(updateState({
|
|
53
161
|
manual: {
|
|
54
162
|
title: locales.getText('page.eftpos-pay.text.timedout.title'),
|
|
55
|
-
text: locales.getText('page.eftpos-pay.text.timedout.text')(
|
|
163
|
+
text: locales.getText('page.eftpos-pay.text.timedout.text')(modeRef.current)
|
|
56
164
|
}
|
|
57
165
|
}));
|
|
58
166
|
dispatch(updateCustom({
|
|
@@ -60,14 +168,11 @@ export var useFail = function useFail(index) {
|
|
|
60
168
|
}));
|
|
61
169
|
|
|
62
170
|
dispatch(updateComponent('Manual'));
|
|
63
|
-
dispatch(updateCustom({
|
|
64
|
-
errorStatus: 'know' // unknow know
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
171
|
return;
|
|
68
172
|
}
|
|
69
|
-
|
|
70
|
-
steps[index].
|
|
173
|
+
// 前往错误页 不可标记状态
|
|
174
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.pay.fail.timeout');
|
|
175
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(modeRef.current);
|
|
71
176
|
steps[index].status = 'fail';
|
|
72
177
|
dispatch(updateSteps(steps));
|
|
73
178
|
dispatch(updateComponent('Fail'));
|
|
@@ -78,29 +183,36 @@ export var useFail = function useFail(index) {
|
|
|
78
183
|
return;
|
|
79
184
|
}
|
|
80
185
|
if (code === PayStatus.NoPay) {
|
|
186
|
+
// 如果未查询到支付状态,则重新发起支付
|
|
81
187
|
if (ref.current > Max4004) {
|
|
188
|
+
// 前往错误页 不可标记状态
|
|
189
|
+
dispatch(updateState({
|
|
190
|
+
number: ''
|
|
191
|
+
}));
|
|
82
192
|
dispatch(updateCustom({
|
|
83
|
-
retry: ref.current
|
|
84
|
-
number: undefined
|
|
193
|
+
retry: ref.current
|
|
85
194
|
}));
|
|
86
|
-
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(
|
|
195
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(modeRef.current);
|
|
87
196
|
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail');
|
|
88
197
|
steps[index].status = 'fail';
|
|
89
198
|
dispatch(updateSteps(steps));
|
|
90
199
|
dispatch(updateComponent('Fail'));
|
|
91
200
|
return;
|
|
92
201
|
}
|
|
202
|
+
// 重新支付 最多到重新发起2次
|
|
93
203
|
ref.current += 1;
|
|
204
|
+
dispatch(updateState({
|
|
205
|
+
number: ''
|
|
206
|
+
}));
|
|
94
207
|
dispatch(updateCustom({
|
|
95
|
-
retry: ref.current
|
|
96
|
-
number: undefined
|
|
208
|
+
retry: ref.current
|
|
97
209
|
}));
|
|
98
210
|
dispatch(updateKey(Date.now()));
|
|
99
211
|
return;
|
|
100
212
|
}
|
|
101
213
|
if (code === PayStatus.PayOtherEftposFailed) {
|
|
214
|
+
// 前往错误页 不可标记状态
|
|
102
215
|
steps[index].title = locales.getText('page.eftpos-pay.text.transaction.fail.terminal.title');
|
|
103
|
-
// steps[index].title = locales.getText('page.eftpos-pay.text.failed')(mode)
|
|
104
216
|
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail.terminal');
|
|
105
217
|
steps[index].status = 'fail';
|
|
106
218
|
dispatch(updateSteps(steps));
|
|
@@ -112,6 +224,7 @@ export var useFail = function useFail(index) {
|
|
|
112
224
|
return;
|
|
113
225
|
}
|
|
114
226
|
if (code === PayStatus.PayCardErrorFailed) {
|
|
227
|
+
// 前往错误页 不可标记状态
|
|
115
228
|
steps[index].title = locales.getText('page.eftpos-pay.text.transaction.fail.cancel.title');
|
|
116
229
|
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail.cancel');
|
|
117
230
|
steps[index].status = 'fail';
|
|
@@ -124,8 +237,9 @@ export var useFail = function useFail(index) {
|
|
|
124
237
|
return;
|
|
125
238
|
}
|
|
126
239
|
if (code === PayStatus.NoNetWork || code === PayStatus.SocketError) {
|
|
240
|
+
// 前往错误页 可标记状态
|
|
127
241
|
steps[index].title = locales.getText('page.eftpos-pay.text.interrupted');
|
|
128
|
-
steps[index].warn =
|
|
242
|
+
steps[index].warn = "".concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.title'), "\n").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.power'), "\n").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.device'), "\n").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.network'), "\n").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.if')(modeRef.current));
|
|
129
243
|
steps[index].status = 'warn';
|
|
130
244
|
steps[index].custom = steps[index].custom ? _objectSpread(_objectSpread({}, steps[index].custom), {}, {
|
|
131
245
|
isPosNetworkError: true
|
|
@@ -140,7 +254,48 @@ export var useFail = function useFail(index) {
|
|
|
140
254
|
|
|
141
255
|
return;
|
|
142
256
|
}
|
|
143
|
-
|
|
257
|
+
if (code === PayStatus.PayBankRefuses) {
|
|
258
|
+
// 前往错误页 不可标记状态
|
|
259
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.back.declined.text');
|
|
260
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.transaction.back.declined.title');
|
|
261
|
+
steps[index].status = 'fail';
|
|
262
|
+
dispatch(updateSteps(steps));
|
|
263
|
+
dispatch(updateComponent('Fail'));
|
|
264
|
+
dispatch(updateCustom({
|
|
265
|
+
errorStatus: 'know' // unknow know
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (code === PayStatus.SignatureDeclined) {
|
|
271
|
+
// 前往错误页 不可标记状态
|
|
272
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.user.declined.text');
|
|
273
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.transaction.user.declined.title');
|
|
274
|
+
steps[index].status = 'fail';
|
|
275
|
+
dispatch(updateSteps(steps));
|
|
276
|
+
dispatch(updateComponent('Fail'));
|
|
277
|
+
dispatch(updateCustom({
|
|
278
|
+
errorStatus: 'know' // unknow know
|
|
279
|
+
}));
|
|
280
|
+
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (code === PayStatus.UserConfigError) {
|
|
284
|
+
// 前往错误页 不可标记状态
|
|
285
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.transaction.user.config.title');
|
|
286
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.user.config.text');
|
|
287
|
+
steps[index].status = 'fail';
|
|
288
|
+
dispatch(updateSteps(steps));
|
|
289
|
+
dispatch(updateComponent('Fail'));
|
|
290
|
+
dispatch(updateCustom({
|
|
291
|
+
errorStatus: 'know' // unknow know
|
|
292
|
+
}));
|
|
293
|
+
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// 其他场景前往未知错误页
|
|
298
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(modeRef.current);
|
|
144
299
|
steps[index].status = 'fail';
|
|
145
300
|
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail');
|
|
146
301
|
dispatch(updateSteps(steps));
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PosProps
|
|
2
|
+
import { PosProps } from './const';
|
|
3
3
|
import './index.less';
|
|
4
|
-
declare const _default: (props:
|
|
5
|
-
mode: ModeEnum;
|
|
6
|
-
}) => React.JSX.Element;
|
|
4
|
+
declare const _default: (props: PosProps) => React.JSX.Element;
|
|
7
5
|
export default _default;
|