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