@pisell/private-materials 6.6.61 → 6.6.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +9 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +9 -9
  11. package/es/components/booking/components/footer/amount.js +4 -3
  12. package/es/components/booking/components/footer/utils.js +10 -3
  13. package/es/components/booking/components/voucher/index.js +1 -1
  14. package/es/components/booking/info2/service/editService/index.js +76 -8
  15. package/es/components/booking/info2/service/editService/utils.d.ts +1 -0
  16. package/es/components/booking/info2/service/editService/utils.js +16 -0
  17. package/es/components/booking/payments/index.js +1 -1
  18. package/es/components/eftpos/PairModal/hooks.d.ts +27 -0
  19. package/es/components/eftpos/PairModal/hooks.js +67 -0
  20. package/es/components/eftpos/PairModal/index.d.ts +11 -0
  21. package/es/components/eftpos/PairModal/index.js +246 -0
  22. package/es/components/eftpos/PairModal/index.less +70 -0
  23. package/es/components/eftpos/SettlementModal/Action.d.ts +7 -0
  24. package/es/components/eftpos/SettlementModal/Action.js +141 -0
  25. package/es/components/eftpos/SettlementModal/index.d.ts +7 -0
  26. package/es/components/eftpos/SettlementModal/index.js +135 -0
  27. package/es/components/eftpos/SettlementModal/index.less +33 -0
  28. package/es/components/eftpos/SettlementModal/serve.d.ts +8 -0
  29. package/es/components/eftpos/SettlementModal/serve.js +171 -0
  30. package/es/components/eftpos/SettlementModal/types.d.ts +138 -0
  31. package/es/components/eftpos/SettlementModal/types.js +35 -0
  32. package/es/components/eftpos/SettlementModal/utils.d.ts +18 -0
  33. package/es/components/eftpos/SettlementModal/utils.js +351 -0
  34. package/es/components/eftpos/assets/mx51SCI.svg +15 -0
  35. package/es/components/eftpos/const.d.ts +3 -1
  36. package/es/components/eftpos/const.js +2 -0
  37. package/es/components/eftpos/device.d.ts +3 -1
  38. package/es/components/eftpos/device.js +14 -3
  39. package/es/components/eftpos/hooks.d.ts +13 -0
  40. package/es/components/eftpos/hooks.js +35 -0
  41. package/es/components/eftpos/index.js +198 -24
  42. package/es/components/eftpos/index.less +32 -1
  43. package/es/components/eftpos/locales.d.ts +80 -0
  44. package/es/components/eftpos/locales.js +205 -25
  45. package/es/components/eftpos/table.js +47 -3
  46. package/es/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
  47. package/es/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
  48. package/es/components/eftposPay/aggregatePayment/hooks/usePayment.js +145 -0
  49. package/es/components/eftposPay/aggregatePayment/index.d.ts +2 -1
  50. package/es/components/eftposPay/aggregatePayment/index.js +2 -1
  51. package/es/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
  52. package/es/components/eftposPay/aggregatePayment/mock.js +567 -0
  53. package/es/components/eftposPay/aggregatePayment/service.js +1 -0
  54. package/es/components/eftposPay/aggregatePayment/types.d.ts +12 -12
  55. package/es/components/eftposPay/aggregatePayment/types.js +4 -8
  56. package/es/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
  57. package/es/components/eftposPay/aggregatePayment/utils/payment.js +231 -168
  58. package/es/components/eftposPay/amount.js +15 -1
  59. package/es/components/eftposPay/app.js +2 -3
  60. package/es/components/eftposPay/component/fail/failCustom.js +13 -4
  61. package/es/components/eftposPay/component/fail/index.js +12 -5
  62. package/es/components/eftposPay/component/fail/network.js +3 -0
  63. package/es/components/eftposPay/component/fail/unknow.js +8 -0
  64. package/es/components/eftposPay/component/manual/index.js +17 -3
  65. package/es/components/eftposPay/component/signature/index.js +3 -0
  66. package/es/components/eftposPay/const.d.ts +8 -3
  67. package/es/components/eftposPay/const.js +2 -0
  68. package/es/components/eftposPay/device.js +225 -38
  69. package/es/components/eftposPay/helper.d.ts +3 -0
  70. package/es/components/eftposPay/helper.js +2 -1
  71. package/es/components/eftposPay/hooks.d.ts +1 -1
  72. package/es/components/eftposPay/index.js +50 -13
  73. package/es/components/eftposPay/linkly/const.js +1 -1
  74. package/es/components/eftposPay/linkly/hooks/normal.js +21 -68
  75. package/es/components/eftposPay/linkly/hooks/useTimeQuery.js +20 -81
  76. package/es/components/eftposPay/linkly/index.js +11 -23
  77. package/es/components/eftposPay/locales.d.ts +15 -0
  78. package/es/components/eftposPay/locales.js +30 -15
  79. package/es/components/eftposPay/manufacturer.d.ts +1 -0
  80. package/es/components/eftposPay/manufacturer.js +4 -0
  81. package/es/components/eftposPay/mx51/Action.d.ts +6 -0
  82. package/es/components/eftposPay/mx51/Action.js +144 -0
  83. package/es/components/eftposPay/mx51/const.d.ts +5 -0
  84. package/es/components/eftposPay/mx51/const.js +69 -0
  85. package/es/components/eftposPay/mx51/index.d.ts +6 -0
  86. package/es/components/eftposPay/mx51/index.js +498 -0
  87. package/es/components/eftposPay/mx51/types.d.ts +142 -0
  88. package/es/components/eftposPay/mx51/types.js +35 -0
  89. package/es/components/eftposPay/mx51/utils.d.ts +10 -0
  90. package/es/components/eftposPay/mx51/utils.js +121 -0
  91. package/es/components/eftposPay/pay.js +21 -9
  92. package/es/components/eftposPay/payo/config.js +39 -5
  93. package/es/components/eftposPay/payo/const.js +1 -1
  94. package/es/components/eftposPay/payo/hooks.js +3 -12
  95. package/es/components/eftposPay/payo/payment.js +69 -136
  96. package/es/components/eftposPay/store/index.d.ts +5 -9
  97. package/es/components/eftposPay/tip.js +5 -0
  98. package/es/components/eftposPay/tyro/const.js +1 -1
  99. package/es/components/eftposPay/tyro/index.js +44 -11
  100. package/es/components/eftposPay/utils/payLog.d.ts +81 -0
  101. package/es/components/eftposPay/utils/payLog.js +458 -0
  102. package/es/components/eftposPay/windcave/const.js +1 -1
  103. package/es/components/eftposPay/windcave/receiptAction.js +5 -0
  104. package/es/components/eftposPay/windcave/windcave.js +37 -38
  105. package/es/components/ticketBooking/utils/formatProductMessage.js +47 -2
  106. package/lib/components/booking/components/footer/amount.js +3 -3
  107. package/lib/components/booking/components/footer/utils.js +12 -5
  108. package/lib/components/booking/components/voucher/index.js +1 -1
  109. package/lib/components/booking/info2/service/editService/index.js +56 -5
  110. package/lib/components/booking/info2/service/editService/utils.d.ts +1 -0
  111. package/lib/components/booking/info2/service/editService/utils.js +16 -0
  112. package/lib/components/booking/payments/index.js +1 -1
  113. package/lib/components/eftpos/PairModal/hooks.d.ts +27 -0
  114. package/lib/components/eftpos/PairModal/hooks.js +70 -0
  115. package/lib/components/eftpos/PairModal/index.d.ts +11 -0
  116. package/lib/components/eftpos/PairModal/index.js +197 -0
  117. package/lib/components/eftpos/PairModal/index.less +70 -0
  118. package/lib/components/eftpos/SettlementModal/Action.d.ts +7 -0
  119. package/lib/components/eftpos/SettlementModal/Action.js +153 -0
  120. package/lib/components/eftpos/SettlementModal/index.d.ts +7 -0
  121. package/lib/components/eftpos/SettlementModal/index.js +170 -0
  122. package/lib/components/eftpos/SettlementModal/index.less +33 -0
  123. package/lib/components/eftpos/SettlementModal/serve.d.ts +8 -0
  124. package/lib/components/eftpos/SettlementModal/serve.js +45 -0
  125. package/lib/components/eftpos/SettlementModal/types.d.ts +138 -0
  126. package/lib/components/eftpos/SettlementModal/types.js +43 -0
  127. package/lib/components/eftpos/SettlementModal/utils.d.ts +18 -0
  128. package/lib/components/eftpos/SettlementModal/utils.js +248 -0
  129. package/lib/components/eftpos/assets/mx51SCI.svg +15 -0
  130. package/lib/components/eftpos/const.d.ts +3 -1
  131. package/lib/components/eftpos/const.js +2 -0
  132. package/lib/components/eftpos/device.d.ts +3 -1
  133. package/lib/components/eftpos/device.js +13 -3
  134. package/lib/components/eftpos/hooks.d.ts +13 -0
  135. package/lib/components/eftpos/hooks.js +30 -0
  136. package/lib/components/eftpos/index.js +121 -8
  137. package/lib/components/eftpos/index.less +32 -1
  138. package/lib/components/eftpos/locales.d.ts +80 -0
  139. package/lib/components/eftpos/locales.js +231 -21
  140. package/lib/components/eftpos/table.js +30 -2
  141. package/lib/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
  142. package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
  143. package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.js +171 -0
  144. package/lib/components/eftposPay/aggregatePayment/index.d.ts +2 -1
  145. package/lib/components/eftposPay/aggregatePayment/index.js +5 -2
  146. package/lib/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
  147. package/lib/components/eftposPay/aggregatePayment/mock.js +679 -0
  148. package/lib/components/eftposPay/aggregatePayment/types.d.ts +12 -12
  149. package/lib/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
  150. package/lib/components/eftposPay/aggregatePayment/utils/payment.js +173 -123
  151. package/lib/components/eftposPay/amount.js +13 -1
  152. package/lib/components/eftposPay/app.js +4 -5
  153. package/lib/components/eftposPay/component/fail/failCustom.js +10 -2
  154. package/lib/components/eftposPay/component/fail/index.js +10 -2
  155. package/lib/components/eftposPay/component/fail/network.js +3 -0
  156. package/lib/components/eftposPay/component/fail/unknow.js +8 -0
  157. package/lib/components/eftposPay/component/manual/index.js +16 -2
  158. package/lib/components/eftposPay/component/signature/index.js +3 -0
  159. package/lib/components/eftposPay/const.d.ts +8 -3
  160. package/lib/components/eftposPay/const.js +2 -0
  161. package/lib/components/eftposPay/device.js +114 -25
  162. package/lib/components/eftposPay/helper.d.ts +3 -0
  163. package/lib/components/eftposPay/helper.js +2 -1
  164. package/lib/components/eftposPay/hooks.d.ts +1 -1
  165. package/lib/components/eftposPay/index.js +38 -13
  166. package/lib/components/eftposPay/linkly/const.js +1 -1
  167. package/lib/components/eftposPay/linkly/hooks/normal.js +22 -43
  168. package/lib/components/eftposPay/linkly/hooks/useTimeQuery.js +13 -65
  169. package/lib/components/eftposPay/linkly/index.js +8 -10
  170. package/lib/components/eftposPay/locales.d.ts +15 -0
  171. package/lib/components/eftposPay/locales.js +30 -15
  172. package/lib/components/eftposPay/manufacturer.d.ts +1 -0
  173. package/lib/components/eftposPay/manufacturer.js +6 -0
  174. package/lib/components/eftposPay/mx51/Action.d.ts +6 -0
  175. package/lib/components/eftposPay/mx51/Action.js +154 -0
  176. package/lib/components/eftposPay/mx51/const.d.ts +5 -0
  177. package/lib/components/eftposPay/mx51/const.js +85 -0
  178. package/lib/components/eftposPay/mx51/index.d.ts +6 -0
  179. package/lib/components/eftposPay/mx51/index.js +433 -0
  180. package/lib/components/eftposPay/mx51/types.d.ts +142 -0
  181. package/lib/components/eftposPay/mx51/types.js +43 -0
  182. package/lib/components/eftposPay/mx51/utils.d.ts +10 -0
  183. package/lib/components/eftposPay/mx51/utils.js +115 -0
  184. package/lib/components/eftposPay/pay.js +13 -3
  185. package/lib/components/eftposPay/payo/config.js +16 -8
  186. package/lib/components/eftposPay/payo/const.js +1 -1
  187. package/lib/components/eftposPay/payo/hooks.js +12 -10
  188. package/lib/components/eftposPay/payo/payment.js +31 -65
  189. package/lib/components/eftposPay/store/index.d.ts +5 -9
  190. package/lib/components/eftposPay/tip.js +5 -0
  191. package/lib/components/eftposPay/tyro/const.js +1 -1
  192. package/lib/components/eftposPay/tyro/index.js +21 -17
  193. package/lib/components/eftposPay/utils/payLog.d.ts +81 -0
  194. package/lib/components/eftposPay/utils/payLog.js +321 -0
  195. package/lib/components/eftposPay/windcave/const.js +1 -1
  196. package/lib/components/eftposPay/windcave/receiptAction.js +5 -0
  197. package/lib/components/eftposPay/windcave/windcave.js +27 -29
  198. package/lib/components/ticketBooking/utils/formatProductMessage.js +44 -2
  199. package/package.json +4 -4
  200. package/es/components/eftposPay/utils/log/index.d.ts +0 -110
  201. package/es/components/eftposPay/utils/log/index.js +0 -371
  202. package/lib/components/eftposPay/utils/log/index.d.ts +0 -110
  203. package/lib/components/eftposPay/utils/log/index.js +0 -294
@@ -0,0 +1,498 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import React, { useEffect, useRef, useState } from 'react';
14
+ import { locales } from '@pisell/utils';
15
+ import { PisellModal, PisellToast } from '@pisell/materials';
16
+ import useEngineContext from "../../../hooks/useEngineContext";
17
+ import { request } from "../../../utils";
18
+ import { updateNextStep, useContextData } from "../store";
19
+ import { PayStatus, StatusEnum } from "../const";
20
+ import { useStoreRef } from "../hooks";
21
+ import { usePayment } from "../aggregatePayment";
22
+ import payLog from "../utils/payLog";
23
+ import { EPaymentStatus } from "../aggregatePayment/types";
24
+ import { parseMX51Params } from "./utils";
25
+ import { CANCEL_ACTION_TIMEOUT, EButtonKeyType } from "./types";
26
+ import Action from "./Action";
27
+ import { useDispatch, updateStatus, updateCustom, updateState } from "../store";
28
+ import { useFail } from "../hooks";
29
+ import { getInitState } from "../manufacturer";
30
+ import { getPayParams } from "../helper";
31
+ var AggregatePayment = function AggregatePayment(_ref) {
32
+ var onChange = _ref.onChange;
33
+ // 设置request
34
+ var context = useEngineContext();
35
+ var utils = context.appHelper.utils || {};
36
+ request.setRequest(utils === null || utils === void 0 ? void 0 : utils.request);
37
+
38
+ // 数据源
39
+ var _useContextData = useContextData(),
40
+ title = _useContextData.title,
41
+ custom = _useContextData.custom,
42
+ status = _useContextData.status,
43
+ eftpos = _useContextData.eftpos,
44
+ mode = _useContextData.mode,
45
+ name = _useContextData.name,
46
+ symbol = _useContextData.symbol,
47
+ amount = _useContextData.amount,
48
+ order_id = _useContextData.order_id;
49
+ var _useStoreRef = useStoreRef(),
50
+ statusRef = _useStoreRef.statusRef,
51
+ numRef = _useStoreRef.numRef,
52
+ netRef = _useStoreRef.netRef,
53
+ modeRef = _useStoreRef.modeRef,
54
+ deviceRef = _useStoreRef.deviceRef,
55
+ orderIdRef = _useStoreRef.orderIdRef,
56
+ amountRef = _useStoreRef.amountRef,
57
+ payRef = _useStoreRef.payRef;
58
+ var dispatch = useDispatch();
59
+ var fail = useFail(0);
60
+ var failRef = useRef(fail);
61
+ var _useState = useState(false),
62
+ _useState2 = _slicedToArray(_useState, 2),
63
+ receiptModalShow = _useState2[0],
64
+ setReceiptModalShow = _useState2[1];
65
+ var _useState3 = useState(null),
66
+ _useState4 = _slicedToArray(_useState3, 2),
67
+ receiptModalData = _useState4[0],
68
+ setReceiptModalData = _useState4[1];
69
+ // 取消按钮点击后需要禁用
70
+ var _useState5 = useState(false),
71
+ _useState6 = _slicedToArray(_useState5, 2),
72
+ cancelDisabled = _useState6[0],
73
+ setCancelDisabled = _useState6[1];
74
+ // 操作行为超时
75
+ var actionTimeoutRef = useRef(null);
76
+ var clearRef = useRef(null);
77
+ useEffect(function () {
78
+ failRef.current = fail;
79
+ }, [fail]);
80
+
81
+ // 当前组件数据
82
+ var initRef = useRef(false);
83
+ var unloadRef = useRef(false);
84
+
85
+ /**
86
+ * 更新到加载状态
87
+ */
88
+ var updateToLoading = function updateToLoading(title) {
89
+ dispatch(updateStatus(StatusEnum.Loading));
90
+ dispatch(updateState({
91
+ title: title || locales.getText('page.eftpos-pay.text.loading')(modeRef.current)
92
+ }));
93
+ };
94
+ var payment = usePayment({
95
+ paymentCode: 'EFTPOS_MX51',
96
+ paymentNum: numRef.current || '',
97
+ shouldContinue: function shouldContinue() {
98
+ return !(unloadRef.current || !netRef.current);
99
+ },
100
+ config: {
101
+ hasQueryInterval: false,
102
+ // 不开启轮询间隔
103
+ globalQueryTimeout: 1000 * 60 * 2,
104
+ // 全局轮询超时时间2分钟
105
+ requestDelaySeconds: 130 // 接口兜底查询时间130秒
106
+ },
107
+ callback: function callback(_instance, response) {
108
+ var _data$data;
109
+ console.log('callback =>>>>>> ', response);
110
+ var _ref2 = response || {},
111
+ status = _ref2.status,
112
+ data = _ref2.data;
113
+ var _ref3 = (data === null || data === void 0 || (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.external_unified_response) || {},
114
+ transaction = _ref3.transaction,
115
+ action = _ref3.action;
116
+ var transformedData = parseMX51Params(transaction, status, data);
117
+ console.log('event_transformedData =>>>>>> ', transformedData);
118
+ dispatch(updateCustom({
119
+ customAction: transformedData
120
+ }));
121
+ // 是否需要清除操作行为超时定时器:非loading态都需要清除
122
+ var needClearActionTimeout = true;
123
+ if (status === EPaymentStatus.Processing) {
124
+ if (action === 'signature') {
125
+ var _transformedData$auto;
126
+ // 签名,需要停止轮询
127
+ dispatch(updateStatus(StatusEnum.Question));
128
+ // 更新标题
129
+ dispatch(updateState({
130
+ title: (transformedData === null || transformedData === void 0 ? void 0 : transformedData.message) || ''
131
+ }));
132
+ _instance.stop();
133
+ // 如果存在签名票自动打印,需要触发打印
134
+ if (transformedData !== null && transformedData !== void 0 && (_transformedData$auto = transformedData.autoAction) !== null && _transformedData$auto !== void 0 && _transformedData$auto.includes('PRINT_MERCHANT_RECEIPT')) {
135
+ var merchantReceipt = (transformedData === null || transformedData === void 0 ? void 0 : transformedData.merchantReceipt) || '';
136
+ onChange('print', merchantReceipt ? [merchantReceipt] : []);
137
+ }
138
+ } else {
139
+ needClearActionTimeout = false;
140
+ updateToLoading();
141
+ }
142
+ } else if (status === EPaymentStatus.Success) {
143
+ handleSuccess(data);
144
+ } else if (status === EPaymentStatus.Failed) {
145
+ // 失败分为两种情况:MX51返回失败信息 和 后端返回失败信息
146
+ if (transformedData) {
147
+ // 渲染需要走自定义
148
+ dispatch(updateStatus('fail'));
149
+ dispatch(updateState({
150
+ title: (transformedData === null || transformedData === void 0 ? void 0 : transformedData.message) || ''
151
+ }));
152
+ } else {
153
+ handleFail(data);
154
+ }
155
+ }
156
+ if (needClearActionTimeout) {
157
+ if (actionTimeoutRef.current) {
158
+ payLog.log('清除操作行为超时定时器');
159
+ clearTimeout(actionTimeoutRef.current);
160
+ actionTimeoutRef.current = null;
161
+ }
162
+ }
163
+ }
164
+ });
165
+
166
+ // 页面初始化处理
167
+ useEffect(function () {
168
+ // 支付检测
169
+ console.log('mx51页面初始化', statusRef.current);
170
+ if (statusRef.current === StatusEnum.Success || statusRef.current === StatusEnum.Fail || statusRef.current === StatusEnum.Question) {
171
+ return;
172
+ }
173
+ if (initRef.current) {
174
+ return;
175
+ }
176
+ initRef.current = true;
177
+
178
+ // 存在支付流水号
179
+ if (numRef.current) {
180
+ console.log('payment.query');
181
+ payment.query();
182
+ return;
183
+ }
184
+ payment.run();
185
+ }, []);
186
+
187
+ // 页面卸载处理
188
+ useEffect(function () {
189
+ return function () {
190
+ console.log('页面卸载');
191
+ unloadRef.current = true;
192
+ // 清除操作行为超时定时器
193
+ if (actionTimeoutRef.current) {
194
+ clearTimeout(actionTimeoutRef.current);
195
+ actionTimeoutRef.current = null;
196
+ }
197
+ if (clearRef.current) {
198
+ clearTimeout(clearRef.current);
199
+ clearRef.current = null;
200
+ }
201
+ };
202
+ }, []);
203
+
204
+ /**
205
+ * 触发支付失败流程:交由 useFail 统一处理失败/重试逻辑
206
+ */
207
+ var handleFail = function handleFail(errorData) {
208
+ var _errorData$data, _failRef$current;
209
+ var _ref4 = (errorData === null || errorData === void 0 || (_errorData$data = errorData.data) === null || _errorData$data === void 0 ? void 0 : _errorData$data.external_unified_response) || {},
210
+ message = _ref4.message,
211
+ response_code = _ref4.response_code;
212
+ var _code = "".concat(response_code || '') || PayStatus.PaymentFailed;
213
+ var _message = message || (errorData === null || errorData === void 0 ? void 0 : errorData.message) || '';
214
+ console.log('handleFail =>>>> ', errorData, _code, _message);
215
+ (_failRef$current = failRef.current) === null || _failRef$current === void 0 || _failRef$current.call(failRef, {
216
+ code: _code,
217
+ message: _message
218
+ }, true);
219
+ };
220
+
221
+ /**
222
+ * 处理支付成功流程
223
+ * 1. 判定设置中是否需要打印商户收据和客户收据,如果需要则自动打印
224
+ * 2. 展示success页面,构建成功参数,并在1秒触发成功回调
225
+ */
226
+ var handleSuccess = function handleSuccess(res) {
227
+ var _res$data, _deviceRef$current;
228
+ var receipt = [];
229
+ var _ref5 = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.external_unified_response) || {},
230
+ transaction = _ref5.transaction,
231
+ external_service_fee = _ref5.external_service_fee;
232
+ var _ref6 = transaction || {},
233
+ merchant_receipt = _ref6.merchant_receipt,
234
+ customer_receipt = _ref6.customer_receipt;
235
+ // 刷卡机的手续费
236
+ var card_reader_surcharge = external_service_fee || 0;
237
+ var deviceSetting = (_deviceRef$current = deviceRef.current) === null || _deviceRef$current === void 0 ? void 0 : _deviceRef$current.setting;
238
+ // 设备是否打印商家小票
239
+ var isEftposPrintMerchantReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.print_merchant_receipt;
240
+ // 设备是否打印客户小票
241
+ var isEftposPrintCustomerReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.prompt_customer_receipt;
242
+ if (!isEftposPrintMerchantReceipt && merchant_receipt) {
243
+ receipt.push(merchant_receipt);
244
+ }
245
+ if (!isEftposPrintCustomerReceipt && customer_receipt) {
246
+ receipt.push(customer_receipt);
247
+ }
248
+ dispatch(updateNextStep());
249
+ dispatch(updateCustom({
250
+ card_reader_surcharge: card_reader_surcharge,
251
+ receipt: receipt
252
+ }));
253
+
254
+ // 更新支付状态与文案
255
+ dispatch(updateState({
256
+ status: 'success',
257
+ title: locales.getText('page.eftpos-pay.text.successful')(modeRef.current)
258
+ }));
259
+ clearRef.current = setTimeout(function () {
260
+ var params = getPayParams({
261
+ mode: modeRef.current,
262
+ amount: amountRef.current,
263
+ order_id: orderIdRef.current,
264
+ number: numRef.current,
265
+ device: deviceRef.current,
266
+ pay: payRef.current,
267
+ custom: {
268
+ card_reader_surcharge: card_reader_surcharge,
269
+ receipt: receipt
270
+ }
271
+ }, 'success');
272
+ onChange('success', _objectSpread(_objectSpread({}, params), {}, {
273
+ receipt: receipt
274
+ }));
275
+ }, 1000);
276
+ };
277
+
278
+ // 取消支付
279
+ var onCancel = function onCancel(element) {
280
+ console.log('onCancel', element);
281
+ setCancelDisabled(true);
282
+ payment.action({
283
+ submit_url: element === null || element === void 0 ? void 0 : element.submitUrl
284
+ });
285
+ // 取消操作超时后自动停止,并构建Timeout失败
286
+ actionTimeoutRef.current = setTimeout(function () {
287
+ var _payment$_instance, _payment$_instance$st, _failRef$current2;
288
+ payLog.log('取消操作超时,前往标记支付');
289
+ payment === null || payment === void 0 || (_payment$_instance = payment._instance) === null || _payment$_instance === void 0 || (_payment$_instance$st = _payment$_instance.stop) === null || _payment$_instance$st === void 0 || _payment$_instance$st.call(_payment$_instance);
290
+ // 构建Timeout失败,允许标记状态
291
+ (_failRef$current2 = failRef.current) === null || _failRef$current2 === void 0 || _failRef$current2.call(failRef, {
292
+ code: PayStatus.Timeout
293
+ }, true);
294
+ }, CANCEL_ACTION_TIMEOUT);
295
+ };
296
+
297
+ // 拒绝签名
298
+ var onDecline = function onDecline(element) {
299
+ console.log('onDecline', element);
300
+ updateToLoading();
301
+ payment.action({
302
+ submit_url: element === null || element === void 0 ? void 0 : element.submitUrl
303
+ });
304
+ };
305
+
306
+ // 接受签名
307
+ var onAccept = function onAccept(element) {
308
+ console.log('onAccept', element);
309
+ updateToLoading();
310
+ payment.action({
311
+ submit_url: element === null || element === void 0 ? void 0 : element.submitUrl
312
+ });
313
+ };
314
+
315
+ // 打印商户收据
316
+ var onPrintMerchantReceipt = function onPrintMerchantReceipt(element) {
317
+ console.log('onPrintMerchantReceipt', element);
318
+ onChange('print', element !== null && element !== void 0 && element.receipt ? [element === null || element === void 0 ? void 0 : element.receipt] : []);
319
+ setReceiptModalShow(true);
320
+ setReceiptModalData(element === null || element === void 0 ? void 0 : element.receipt);
321
+ };
322
+
323
+ // 打印客户收据
324
+ var onPrintCustomerReceipt = function onPrintCustomerReceipt(element) {
325
+ console.log('onPrintCustomerReceipt', element);
326
+ onChange('print', element !== null && element !== void 0 && element.receipt ? [element === null || element === void 0 ? void 0 : element.receipt] : []);
327
+ setReceiptModalShow(true);
328
+ setReceiptModalData(element === null || element === void 0 ? void 0 : element.receipt);
329
+ };
330
+
331
+ // 重试交易
332
+ var onRetry = function onRetry(element) {
333
+ console.log('onRetry', element);
334
+ onChange('page', 'pay');
335
+ var _params = _objectSpread(_objectSpread({}, custom || {}), {}, {
336
+ // 自定义参数需要重新传递
337
+ mode: mode,
338
+ name: name,
339
+ symbol: symbol,
340
+ amount: amount,
341
+ order_id: order_id,
342
+ number: ''
343
+ });
344
+ dispatch(updateState(getInitState(eftpos, _params)));
345
+ };
346
+
347
+ // 交易完成
348
+ var onTransactionComplete = function onTransactionComplete(element) {
349
+ console.log('onTransactionComplete', element);
350
+ var _ref7 = element._extra || {},
351
+ paymentStatus = _ref7.paymentStatus,
352
+ response = _ref7.response,
353
+ merchantReceipt = _ref7.merchantReceipt,
354
+ customerReceipt = _ref7.customerReceipt;
355
+ if (paymentStatus === EPaymentStatus.Success) {
356
+ var _response$data, _deviceRef$current2;
357
+ var receipt = [];
358
+ // 刷卡机的手续费
359
+ var card_reader_surcharge = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.external_unified_response) === null || _response$data === void 0 ? void 0 : _response$data.external_service_fee) || 0;
360
+ var deviceSetting = (_deviceRef$current2 = deviceRef.current) === null || _deviceRef$current2 === void 0 ? void 0 : _deviceRef$current2.setting;
361
+ // 设备是否打印商家小票
362
+ var isEftposPrintMerchantReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.print_merchant_receipt;
363
+ // 设备是否打印客户小票
364
+ var isEftposPrintCustomerReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.prompt_customer_receipt;
365
+ if (!isEftposPrintMerchantReceipt && merchantReceipt) {
366
+ receipt.push(merchantReceipt);
367
+ }
368
+ if (!isEftposPrintCustomerReceipt && customerReceipt) {
369
+ receipt.push(customerReceipt);
370
+ }
371
+ var _params2 = getPayParams({
372
+ mode: modeRef.current,
373
+ amount: amountRef.current,
374
+ order_id: orderIdRef.current,
375
+ number: numRef.current,
376
+ device: deviceRef.current,
377
+ pay: payRef.current,
378
+ custom: {
379
+ card_reader_surcharge: card_reader_surcharge,
380
+ receipt: receipt
381
+ }
382
+ }, 'success');
383
+ onChange('success', _objectSpread(_objectSpread({}, _params2), {}, {
384
+ receipt: receipt
385
+ }));
386
+ } else {
387
+ onChange('fail', {
388
+ order_id: orderIdRef.current,
389
+ number: numRef.current,
390
+ uniquePaymentNumber: numRef.current,
391
+ device: deviceRef.current
392
+ });
393
+ }
394
+ };
395
+
396
+ // 提交到API
397
+ var onSubmitToAPI = function onSubmitToAPI(element, extra) {
398
+ updateToLoading();
399
+ var inputValues = (extra === null || extra === void 0 ? void 0 : extra.inputValues) || {};
400
+ payment.action({
401
+ submit_url: element === null || element === void 0 ? void 0 : element.submitUrl,
402
+ payload: _objectSpread({}, inputValues)
403
+ }, {
404
+ needResponse: true
405
+ });
406
+ };
407
+ var onNormalClick = function onNormalClick(element, config) {
408
+ // 如果存在submit_url,则提交到API
409
+ if (element !== null && element !== void 0 && element.submitUrl) {
410
+ console.log('onNormalClick_submit_url', element === null || element === void 0 ? void 0 : element.submitUrl);
411
+ updateToLoading();
412
+ payment.action({
413
+ submit_url: element === null || element === void 0 ? void 0 : element.submitUrl
414
+ }, config);
415
+ } else {
416
+ console.log('onNormalClick_no_submit_url', element);
417
+ }
418
+ };
419
+
420
+ // 点击元素
421
+ var onElementClick = function onElementClick(element, extra) {
422
+ console.log('onElementClick', element, extra);
423
+ payLog.log("\u70B9\u51FB".concat((element === null || element === void 0 ? void 0 : element.key) || '未知', "\u6309\u94AE"));
424
+ switch (element.key) {
425
+ case EButtonKeyType.CancelTransaction:
426
+ onCancel(element);
427
+ break;
428
+ case EButtonKeyType.DeclineSignature:
429
+ onDecline(element);
430
+ break;
431
+ case EButtonKeyType.ApproveSignature:
432
+ onAccept(element);
433
+ break;
434
+ case EButtonKeyType.PrintMerchantReceipt:
435
+ onPrintMerchantReceipt(element);
436
+ break;
437
+ case EButtonKeyType.PrintCustomerReceipt:
438
+ onPrintCustomerReceipt(element);
439
+ break;
440
+ case EButtonKeyType.RetryTransaction:
441
+ onRetry(element);
442
+ break;
443
+ case EButtonKeyType.TransactionComplete:
444
+ onTransactionComplete(element);
445
+ break;
446
+ case EButtonKeyType.SubmitToAPI:
447
+ // MX51审核,需要返回结果
448
+ onSubmitToAPI(element, extra);
449
+ break;
450
+ case EButtonKeyType.CallTestFunction:
451
+ // MX51审核,需要直接弹一个toast
452
+ PisellToast({
453
+ content: 'Test'
454
+ });
455
+ break;
456
+ default:
457
+ onNormalClick(element);
458
+ break;
459
+ }
460
+ };
461
+ var onCloseReceiptModal = function onCloseReceiptModal() {
462
+ setReceiptModalShow(false);
463
+ setReceiptModalData(null);
464
+ };
465
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
466
+ className: "pisell-lowcode__eft-pay-body"
467
+ }, status === StatusEnum.Question ? /*#__PURE__*/React.createElement("div", {
468
+ className: "pisell-lowcode__eft-pay-title",
469
+ style: {
470
+ textAlign: 'center'
471
+ }
472
+ }, title) : null, status !== StatusEnum.Success ? /*#__PURE__*/React.createElement(Action, {
473
+ data: custom === null || custom === void 0 ? void 0 : custom.customAction,
474
+ showMessage: status === StatusEnum.Loading,
475
+ onClick: onElementClick,
476
+ cancelDisabled: cancelDisabled
477
+ }) : null), receiptModalShow ? /*#__PURE__*/React.createElement(PisellModal, {
478
+ open: receiptModalShow,
479
+ onCancel: onCloseReceiptModal,
480
+ maskClosable: true,
481
+ footer: null
482
+ }, /*#__PURE__*/React.createElement("div", {
483
+ style: {
484
+ padding: '16px',
485
+ display: 'flex',
486
+ alignItems: 'center',
487
+ justifyContent: 'center'
488
+ }
489
+ }, /*#__PURE__*/React.createElement("span", {
490
+ style: {
491
+ display: 'inline-block',
492
+ whiteSpace: 'pre-wrap',
493
+ fontFamily: 'monospace',
494
+ backgroundColor: '#fff'
495
+ }
496
+ }, receiptModalData))) : null);
497
+ };
498
+ export default AggregatePayment;
@@ -0,0 +1,142 @@
1
+ import { EPaymentStatus } from '../aggregatePayment/types';
2
+ /** 元素类型定义 */
3
+ export interface ElementType {
4
+ label: string;
5
+ key: string;
6
+ }
7
+ /** 布局类型定义 */
8
+ export interface LayoutType {
9
+ type: string;
10
+ elements: ElementType[];
11
+ }
12
+ /** 元素属性定义 */
13
+ export interface ElementProperty {
14
+ type: 'button' | 'text' | 'image' | 'input';
15
+ submit_url: string;
16
+ action: string | null;
17
+ text?: string | null;
18
+ name?: string | null;
19
+ data?: string | null;
20
+ encoding?: string | null;
21
+ }
22
+ /** Action Form 定义 */
23
+ export interface ActionFormType {
24
+ layout: LayoutType[];
25
+ properties: {
26
+ [key: string]: ElementProperty;
27
+ };
28
+ details: {
29
+ [key: string]: string;
30
+ };
31
+ }
32
+ /** POS 指令定义 */
33
+ export interface PosInstructions {
34
+ auto_actions: any;
35
+ action_form: ActionFormType | null;
36
+ }
37
+ /** MX51 参数定义 */
38
+ export interface MX51Params {
39
+ id: string;
40
+ version: number;
41
+ status: string;
42
+ message: string;
43
+ merchant_receipt: string | null;
44
+ customer_receipt: string | null;
45
+ result_amounts: any;
46
+ result_financial_status: string | null;
47
+ pos_instructions: PosInstructions | null;
48
+ }
49
+ /** 解析后的按钮配置 */
50
+ export interface ParsedElement {
51
+ /** 元素键 */
52
+ key: string;
53
+ /** 元素标签 */
54
+ label: string;
55
+ /** 提交URL */
56
+ submitUrl: string;
57
+ /** 按钮动作 */
58
+ action: string | null;
59
+ /** 元素类型 */
60
+ type: 'button' | 'text';
61
+ /** 文本信息 */
62
+ text?: string | null;
63
+ /** 小票信息 */
64
+ receipt?: string | null;
65
+ /** 额外信息 */
66
+ _extra?: {
67
+ /** 商户收据 */
68
+ merchantReceipt?: string | null;
69
+ /** 客户收据 */
70
+ customerReceipt?: string | null;
71
+ /** 支付状态 */
72
+ paymentStatus: EPaymentStatus;
73
+ /** 接口返回的原始数据 */
74
+ response: any;
75
+ };
76
+ /** 图片信息 */
77
+ image?: {
78
+ name?: string | null;
79
+ data?: string | null;
80
+ encoding?: string | null;
81
+ };
82
+ }
83
+ /** 解析后的布局配置 */
84
+ export interface ParsedLayout {
85
+ /** 布局类型,如 horizontal_layout */
86
+ layoutType: string;
87
+ /** 该布局中的按钮列表 */
88
+ elements: ParsedElement[];
89
+ }
90
+ /** 解析后的结果 */
91
+ export interface ParsedMX51Result {
92
+ /** 交易ID */
93
+ transactionId: string;
94
+ /** 版本号 */
95
+ version: number;
96
+ /** 状态 */
97
+ status: string;
98
+ /** 提示信息 */
99
+ message: string;
100
+ /** 商户收据 */
101
+ merchantReceipt: string | null;
102
+ /** 客户收据 */
103
+ customerReceipt: string | null;
104
+ /** 结果金额 */
105
+ resultAmounts: any;
106
+ /** 结果财务状态 */
107
+ resultFinancialStatus: string | null;
108
+ /** 布局列表,每个布局包含其类型和按钮 */
109
+ layouts: ParsedLayout[];
110
+ /** 详情信息 */
111
+ details: {
112
+ [key: string]: string;
113
+ };
114
+ /** 详情信息 text */
115
+ detailsText: string;
116
+ /** 自动操作 */
117
+ autoAction: Array<string> | null;
118
+ }
119
+ export declare enum EButtonKeyType {
120
+ /** 取消交易 */
121
+ CancelTransaction = "cancel_transaction",
122
+ /** 交易完成 */
123
+ TransactionComplete = "transaction_complete",
124
+ /** 重试交易 */
125
+ RetryTransaction = "retry_transaction",
126
+ /** 打印商户收据 */
127
+ PrintMerchantReceipt = "print_merchant_receipt",
128
+ /** 打印客户收据 */
129
+ PrintCustomerReceipt = "print_customer_receipt",
130
+ /** 批准签名 */
131
+ ApproveSignature = "approve_signature",
132
+ /** 拒绝签名 */
133
+ DeclineSignature = "decline_signature",
134
+ /** 提交到API */
135
+ SubmitToAPI = "submit_to_api",
136
+ /** 测试 */
137
+ CallTestFunction = "call_test_function"
138
+ }
139
+ /**
140
+ * 操作行为超时时间
141
+ */
142
+ export declare const CANCEL_ACTION_TIMEOUT: number;
@@ -0,0 +1,35 @@
1
+ /** 元素类型定义 */
2
+
3
+ /** 布局类型定义 */
4
+
5
+ /** 元素属性定义 */
6
+
7
+ /** Action Form 定义 */
8
+
9
+ /** POS 指令定义 */
10
+
11
+ /** MX51 参数定义 */
12
+
13
+ /** 解析后的按钮配置 */
14
+
15
+ /** 解析后的布局配置 */
16
+
17
+ /** 解析后的结果 */
18
+
19
+ export var EButtonKeyType = /*#__PURE__*/function (EButtonKeyType) {
20
+ EButtonKeyType["CancelTransaction"] = "cancel_transaction";
21
+ EButtonKeyType["TransactionComplete"] = "transaction_complete";
22
+ EButtonKeyType["RetryTransaction"] = "retry_transaction";
23
+ EButtonKeyType["PrintMerchantReceipt"] = "print_merchant_receipt";
24
+ EButtonKeyType["PrintCustomerReceipt"] = "print_customer_receipt";
25
+ EButtonKeyType["ApproveSignature"] = "approve_signature";
26
+ EButtonKeyType["DeclineSignature"] = "decline_signature";
27
+ EButtonKeyType["SubmitToAPI"] = "submit_to_api";
28
+ EButtonKeyType["CallTestFunction"] = "call_test_function";
29
+ return EButtonKeyType;
30
+ }({});
31
+
32
+ /**
33
+ * 操作行为超时时间
34
+ */
35
+ export var CANCEL_ACTION_TIMEOUT = 1000 * 20; // 20秒
@@ -0,0 +1,10 @@
1
+ import { EPaymentStatus } from '../aggregatePayment/types';
2
+ import { type MX51Params, type ParsedMX51Result } from './types';
3
+ /**
4
+ * 解析MX51参数
5
+ * @param params 接口返回的原始参数
6
+ * @param status 支付状态
7
+ * @param data 接口返回的数据
8
+ * @returns 解析后的结果对象
9
+ */
10
+ export declare const parseMX51Params: (params: MX51Params, paymentStatus: EPaymentStatus, data: any) => ParsedMX51Result | null;