@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
@@ -20,10 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var helper_exports = {};
21
21
  __export(helper_exports, {
22
22
  cloneDeep: () => cloneDeep,
23
+ getPayParams: () => getPayParams,
23
24
  getUuid: () => getUuid,
25
+ limitDecimals: () => limitDecimals,
24
26
  sleep: () => sleep
25
27
  });
26
28
  module.exports = __toCommonJS(helper_exports);
29
+ var import_decimal = require("decimal.js");
30
+ var import_const = require("./const");
27
31
  function getUuid() {
28
32
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxx".replace(/[xy]/g, (c) => {
29
33
  const r = Math.random() * 16 | 0;
@@ -54,9 +58,69 @@ function cloneDeep(source, hash = /* @__PURE__ */ new WeakMap()) {
54
58
  });
55
59
  return target;
56
60
  }
61
+ var getPayParams = (data, statue) => {
62
+ var _a;
63
+ if (statue === "fail") {
64
+ return {
65
+ number: data.number,
66
+ device: data.device,
67
+ order_id: data.order_id
68
+ };
69
+ }
70
+ if (data.mode === import_const.ModeEnum.Pay) {
71
+ const pay = data.pay;
72
+ const card_reader_surcharge = ((_a = data.custom) == null ? void 0 : _a.card_reader_surcharge) || 0;
73
+ const obj = pay || {};
74
+ const cardReaderSurcharge = card_reader_surcharge;
75
+ const surCardDeci = new import_decimal.Decimal(Number(cardReaderSurcharge));
76
+ const surMoneyDeci = new import_decimal.Decimal(Number((obj == null ? void 0 : obj.surMoney) || 0));
77
+ const surRateMoneyDeci = new import_decimal.Decimal(Number(obj == null ? void 0 : obj.surRateMoney));
78
+ const surMoneyTotal = surMoneyDeci.add(surCardDeci);
79
+ const surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
80
+ const amount = new import_decimal.Decimal(Number(obj == null ? void 0 : obj.amount));
81
+ const total = surchargeDeci.add(amount);
82
+ return {
83
+ ...obj,
84
+ cardReaderSurcharge,
85
+ surMoney: surMoneyTotal.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
86
+ surcharge: surchargeDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
87
+ total: total.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
88
+ number: data.number,
89
+ device: data.device,
90
+ order_id: data.order_id
91
+ };
92
+ }
93
+ if (data.mode === import_const.ModeEnum.Refund) {
94
+ return {
95
+ amount: data.amount,
96
+ total: data.amount,
97
+ number: data.number,
98
+ device: data.device,
99
+ order_id: data.order_id
100
+ };
101
+ }
102
+ return {
103
+ amount: data.amount,
104
+ total: data.amount,
105
+ number: data.number,
106
+ order_id: data.order_id
107
+ };
108
+ };
109
+ var limitDecimals = (value) => {
110
+ const reg = /^(\-)*(\d+)\.(\d\d).*$/;
111
+ if (typeof value === "string") {
112
+ return !isNaN(Number(value)) ? value.replace(reg, "$1$2.$3") : "";
113
+ }
114
+ if (typeof value === "number") {
115
+ return !isNaN(value) ? String(value).replace(reg, "$1$2.$3") : "";
116
+ }
117
+ return "";
118
+ };
57
119
  // Annotate the CommonJS export names for ESM import in node:
58
120
  0 && (module.exports = {
59
121
  cloneDeep,
122
+ getPayParams,
60
123
  getUuid,
124
+ limitDecimals,
61
125
  sleep
62
126
  });
@@ -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;
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,29 +14,89 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
 
29
19
  // src/components/eftposPay/hooks.tsx
30
20
  var hooks_exports = {};
31
21
  __export(hooks_exports, {
32
- useFail: () => useFail
22
+ useFail: () => useFail,
23
+ useStoreRef: () => useStoreRef
33
24
  });
34
25
  module.exports = __toCommonJS(hooks_exports);
35
26
  var import_utils = require("@pisell/utils");
36
- var import_react = __toESM(require("react"));
27
+ var import_react = require("react");
37
28
  var import_const = require("./const");
38
29
  var import_store = require("./store");
39
30
  var Max4004 = 1;
31
+ var useStoreRef = () => {
32
+ const {
33
+ order_id,
34
+ device,
35
+ pay,
36
+ number,
37
+ mode,
38
+ net,
39
+ status,
40
+ symbol,
41
+ amount,
42
+ eftpos
43
+ } = (0, import_store.useContextData)();
44
+ const deviceRef = (0, import_react.useRef)(device);
45
+ const payRef = (0, import_react.useRef)(pay);
46
+ const numRef = (0, import_react.useRef)(number);
47
+ const orderIdRef = (0, import_react.useRef)(order_id);
48
+ const modeRef = (0, import_react.useRef)(mode);
49
+ const statusRef = (0, import_react.useRef)(status);
50
+ const netRef = (0, import_react.useRef)(net);
51
+ const symbolRef = (0, import_react.useRef)(symbol);
52
+ const amountRef = (0, import_react.useRef)(amount);
53
+ const eftposRef = (0, import_react.useRef)(eftpos);
54
+ (0, import_react.useEffect)(() => {
55
+ deviceRef.current = device;
56
+ }, [device]);
57
+ (0, import_react.useEffect)(() => {
58
+ payRef.current = pay;
59
+ }, [pay]);
60
+ (0, import_react.useEffect)(() => {
61
+ numRef.current = number;
62
+ }, [number]);
63
+ (0, import_react.useEffect)(() => {
64
+ orderIdRef.current = order_id;
65
+ }, [order_id]);
66
+ (0, import_react.useEffect)(() => {
67
+ modeRef.current = mode;
68
+ }, [mode]);
69
+ (0, import_react.useEffect)(() => {
70
+ statusRef.current = status;
71
+ }, [status]);
72
+ (0, import_react.useEffect)(() => {
73
+ netRef.current = net;
74
+ }, [net]);
75
+ (0, import_react.useEffect)(() => {
76
+ symbolRef.current = symbol;
77
+ }, [symbol]);
78
+ (0, import_react.useEffect)(() => {
79
+ amountRef.current = amount;
80
+ }, [amount]);
81
+ (0, import_react.useEffect)(() => {
82
+ eftposRef.current = eftpos;
83
+ }, [eftpos]);
84
+ return {
85
+ deviceRef,
86
+ payRef,
87
+ numRef,
88
+ orderIdRef,
89
+ modeRef,
90
+ statusRef,
91
+ netRef,
92
+ symbolRef,
93
+ amountRef,
94
+ eftposRef
95
+ };
96
+ };
40
97
  var useFail = (index, isMark = false) => {
41
- const { steps, custom, mode } = (0, import_store.useContextData)();
98
+ const { steps, custom } = (0, import_store.useContextData)();
99
+ const { modeRef } = useStoreRef();
42
100
  const dispatch = (0, import_store.useDispatch)();
43
101
  const ref = (0, import_react.useRef)((custom == null ? void 0 : custom.retry) || 0);
44
102
  (0, import_react.useEffect)(() => {
@@ -57,14 +115,9 @@ var useFail = (index, isMark = false) => {
57
115
  return;
58
116
  }
59
117
  const [code] = [`${res.code}`];
60
- dispatch(
61
- (0, import_store.updateCustomStemItem)({
62
- step: index
63
- })
64
- );
65
118
  if (code === import_const.PayStatus.Unknown) {
66
119
  steps[index].title = import_utils.locales.getText("page.eftpos-pay.text.failed")(
67
- mode
120
+ modeRef.current
68
121
  );
69
122
  steps[index].fail = import_utils.locales.getText(
70
123
  "page.eftpos-pay.text.transaction.fail"
@@ -80,7 +133,25 @@ var useFail = (index, isMark = false) => {
80
133
  );
81
134
  return;
82
135
  }
83
- if (code === import_const.PayStatus.Timeout || code === import_const.PayStatus.PayTimeout) {
136
+ if (code === import_const.PayStatus.PayTimeout) {
137
+ steps[index].fail = import_utils.locales.getText(
138
+ "page.eftpos-pay.text.transaction.fail.timeout"
139
+ );
140
+ steps[index].title = import_utils.locales.getText("page.eftpos-pay.text.failed")(
141
+ modeRef.current
142
+ );
143
+ steps[index].status = "fail";
144
+ dispatch((0, import_store.updateSteps)(steps));
145
+ dispatch((0, import_store.updateComponent)("Fail"));
146
+ dispatch(
147
+ (0, import_store.updateCustom)({
148
+ errorStatus: "know"
149
+ // unknow know
150
+ })
151
+ );
152
+ return;
153
+ }
154
+ if (code === import_const.PayStatus.Timeout) {
84
155
  if (isMark) {
85
156
  steps[index].status = "fail";
86
157
  dispatch((0, import_store.updateSteps)(steps));
@@ -89,7 +160,7 @@ var useFail = (index, isMark = false) => {
89
160
  manual: {
90
161
  title: import_utils.locales.getText("page.eftpos-pay.text.timedout.title"),
91
162
  text: import_utils.locales.getText("page.eftpos-pay.text.timedout.text")(
92
- mode
163
+ modeRef.current
93
164
  )
94
165
  }
95
166
  })
@@ -101,17 +172,13 @@ var useFail = (index, isMark = false) => {
101
172
  })
102
173
  );
103
174
  dispatch((0, import_store.updateComponent)("Manual"));
104
- dispatch(
105
- (0, import_store.updateCustom)({
106
- errorStatus: "know"
107
- // unknow know
108
- })
109
- );
110
175
  return;
111
176
  }
112
- steps[index].fail = code === import_const.PayStatus.Timeout ? import_utils.locales.getText("page.eftpos-pay.text.transaction.pay.fail.timeout") : import_utils.locales.getText("page.eftpos-pay.text.transaction.fail.timeout");
177
+ steps[index].fail = import_utils.locales.getText(
178
+ "page.eftpos-pay.text.transaction.pay.fail.timeout"
179
+ );
113
180
  steps[index].title = import_utils.locales.getText("page.eftpos-pay.text.failed")(
114
- mode
181
+ modeRef.current
115
182
  );
116
183
  steps[index].status = "fail";
117
184
  dispatch((0, import_store.updateSteps)(steps));
@@ -126,14 +193,18 @@ var useFail = (index, isMark = false) => {
126
193
  }
127
194
  if (code === import_const.PayStatus.NoPay) {
128
195
  if (ref.current > Max4004) {
196
+ dispatch(
197
+ (0, import_store.updateState)({
198
+ number: ""
199
+ })
200
+ );
129
201
  dispatch(
130
202
  (0, import_store.updateCustom)({
131
- retry: ref.current,
132
- number: void 0
203
+ retry: ref.current
133
204
  })
134
205
  );
135
206
  steps[index].title = import_utils.locales.getText("page.eftpos-pay.text.failed")(
136
- mode
207
+ modeRef.current
137
208
  );
138
209
  steps[index].fail = import_utils.locales.getText(
139
210
  "page.eftpos-pay.text.transaction.fail"
@@ -144,10 +215,14 @@ var useFail = (index, isMark = false) => {
144
215
  return;
145
216
  }
146
217
  ref.current += 1;
218
+ dispatch(
219
+ (0, import_store.updateState)({
220
+ number: ""
221
+ })
222
+ );
147
223
  dispatch(
148
224
  (0, import_store.updateCustom)({
149
- retry: ref.current,
150
- number: void 0
225
+ retry: ref.current
151
226
  })
152
227
  );
153
228
  dispatch((0, import_store.updateKey)(Date.now()));
@@ -172,7 +247,9 @@ var useFail = (index, isMark = false) => {
172
247
  return;
173
248
  }
174
249
  if (code === import_const.PayStatus.PayCardErrorFailed) {
175
- steps[index].title = import_utils.locales.getText("page.eftpos-pay.text.transaction.fail.cancel.title");
250
+ steps[index].title = import_utils.locales.getText(
251
+ "page.eftpos-pay.text.transaction.fail.cancel.title"
252
+ );
176
253
  steps[index].fail = import_utils.locales.getText(
177
254
  "page.eftpos-pay.text.transaction.fail.cancel"
178
255
  );
@@ -191,17 +268,21 @@ var useFail = (index, isMark = false) => {
191
268
  steps[index].title = import_utils.locales.getText(
192
269
  "page.eftpos-pay.text.interrupted"
193
270
  );
194
- steps[index].warn = /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, import_utils.locales.getText(
271
+ steps[index].warn = `${import_utils.locales.getText(
195
272
  "page.eftpos-pay.text.transaction.eftpos.fail.title"
196
- ), /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText(
273
+ )}
274
+ ${import_utils.locales.getText(
197
275
  "page.eftpos-pay.text.transaction.eftpos.fail.power"
198
- ), ". ", /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText(
276
+ )}
277
+ ${import_utils.locales.getText(
199
278
  "page.eftpos-pay.text.transaction.eftpos.fail.device"
200
- ), /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText(
279
+ )}
280
+ ${import_utils.locales.getText(
201
281
  "page.eftpos-pay.text.transaction.eftpos.fail.network"
202
- ), /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText("page.eftpos-pay.text.transaction.eftpos.fail.if")(
203
- mode
204
- ));
282
+ )}
283
+ ${import_utils.locales.getText(
284
+ "page.eftpos-pay.text.transaction.eftpos.fail.if"
285
+ )(modeRef.current)}`;
205
286
  steps[index].status = "warn";
206
287
  steps[index].custom = steps[index].custom ? { ...steps[index].custom, isPosNetworkError: true } : { isPosNetworkError: true };
207
288
  dispatch((0, import_store.updateSteps)(steps));
@@ -214,7 +295,63 @@ var useFail = (index, isMark = false) => {
214
295
  );
215
296
  return;
216
297
  }
217
- steps[index].title = import_utils.locales.getText("page.eftpos-pay.text.failed")(mode);
298
+ if (code === import_const.PayStatus.PayBankRefuses) {
299
+ steps[index].fail = import_utils.locales.getText(
300
+ "page.eftpos-pay.text.transaction.back.declined.text"
301
+ );
302
+ steps[index].title = import_utils.locales.getText(
303
+ "page.eftpos-pay.text.transaction.back.declined.title"
304
+ );
305
+ steps[index].status = "fail";
306
+ dispatch((0, import_store.updateSteps)(steps));
307
+ dispatch((0, import_store.updateComponent)("Fail"));
308
+ dispatch(
309
+ (0, import_store.updateCustom)({
310
+ errorStatus: "know"
311
+ // unknow know
312
+ })
313
+ );
314
+ return;
315
+ }
316
+ if (code === import_const.PayStatus.SignatureDeclined) {
317
+ steps[index].fail = import_utils.locales.getText(
318
+ "page.eftpos-pay.text.transaction.user.declined.text"
319
+ );
320
+ steps[index].title = import_utils.locales.getText(
321
+ "page.eftpos-pay.text.transaction.user.declined.title"
322
+ );
323
+ steps[index].status = "fail";
324
+ dispatch((0, import_store.updateSteps)(steps));
325
+ dispatch((0, import_store.updateComponent)("Fail"));
326
+ dispatch(
327
+ (0, import_store.updateCustom)({
328
+ errorStatus: "know"
329
+ // unknow know
330
+ })
331
+ );
332
+ return;
333
+ }
334
+ if (code === import_const.PayStatus.UserConfigError) {
335
+ steps[index].title = import_utils.locales.getText(
336
+ "page.eftpos-pay.text.transaction.user.config.title"
337
+ );
338
+ steps[index].fail = import_utils.locales.getText(
339
+ "page.eftpos-pay.text.transaction.user.config.text"
340
+ );
341
+ steps[index].status = "fail";
342
+ dispatch((0, import_store.updateSteps)(steps));
343
+ dispatch((0, import_store.updateComponent)("Fail"));
344
+ dispatch(
345
+ (0, import_store.updateCustom)({
346
+ errorStatus: "know"
347
+ // unknow know
348
+ })
349
+ );
350
+ return;
351
+ }
352
+ steps[index].title = import_utils.locales.getText("page.eftpos-pay.text.failed")(
353
+ modeRef.current
354
+ );
218
355
  steps[index].status = "fail";
219
356
  steps[index].fail = import_utils.locales.getText(
220
357
  "page.eftpos-pay.text.transaction.fail"
@@ -233,5 +370,6 @@ var useFail = (index, isMark = false) => {
233
370
  };
234
371
  // Annotate the CommonJS export names for ESM import in node:
235
372
  0 && (module.exports = {
236
- useFail
373
+ useFail,
374
+ useStoreRef
237
375
  });
@@ -1,7 +1,5 @@
1
1
  import React from 'react';
2
- import { PosProps, ModeEnum } from './const';
2
+ import { PosProps } from './const';
3
3
  import './index.less';
4
- declare const _default: (props: Omit<PosProps, "action"> & {
5
- mode: ModeEnum;
6
- }) => React.JSX.Element;
4
+ declare const _default: (props: PosProps) => React.JSX.Element;
7
5
  export default _default;
@@ -50,14 +50,16 @@ var App = ({
50
50
  getApi,
51
51
  device_number,
52
52
  terminal,
53
+ tyroUrl,
54
+ tyroVersion,
55
+ onChangeParams,
53
56
  ...props
54
57
  }) => {
55
58
  var _a;
56
59
  const data = (0, import_store.useContextData)();
57
- const ref = (0, import_react.useRef)(false);
60
+ const dispatch = (0, import_store.useDispatch)();
58
61
  const [current, setCurrent] = (0, import_react.useState)(action);
59
62
  const statusRef = (0, import_react.useRef)(data.status);
60
- const actRef = (0, import_react.useRef)(action);
61
63
  const context = (0, import_useEngineContext.default)();
62
64
  const { formatAmount, isTerminal } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {
63
65
  formatAmount: (number, precision, symbol) => `${symbol}${number}`,
@@ -94,17 +96,29 @@ var App = ({
94
96
  }
95
97
  return {};
96
98
  }, [getApi]);
97
- const onChange = (status, params) => {
99
+ (0, import_react.useEffect)(() => {
100
+ onChangeParams && onChangeParams({
101
+ ...data,
102
+ ...data.eftpos === "tyro" ? { custom: { ...data.custom, btnList: [], list: [] } } : {},
103
+ form: "restore"
104
+ });
105
+ }, [data, onChangeParams]);
106
+ const onChange = (0, import_react.useCallback)((status, params) => {
98
107
  if (status === "page" && typeof params === "string") {
99
108
  if (["amount", "deviceList", "pay"].includes(params)) {
100
109
  setCurrent(params);
110
+ dispatch((0, import_store.updateState)({ action: params }));
101
111
  }
102
112
  }
103
113
  console.log("状态切换 = ", status, params);
104
114
  props.onChangeStatus(status, params);
105
- };
115
+ }, []);
106
116
  const onClose = () => {
107
- onChange("fail");
117
+ onChange("fail", {
118
+ number: data.number,
119
+ device: data.device,
120
+ order_id: data.order_id
121
+ });
108
122
  };
109
123
  if (current === import_const.RouteEnum.DeviceList) {
110
124
  return /* @__PURE__ */ import_react.default.createElement(
@@ -137,11 +151,14 @@ var App = ({
137
151
  import_pay.default,
138
152
  {
139
153
  api,
154
+ tyroUrl,
155
+ tyroVersion,
140
156
  onChange,
141
157
  className: isIpad ? "pisell-lowcode__eft-pay-terminal" : "",
142
158
  terminal,
143
159
  isIpad,
144
- net
160
+ net,
161
+ formatAmount
145
162
  }
146
163
  );
147
164
  };
@@ -149,39 +166,67 @@ var eftposPay_default = (props) => {
149
166
  var _a, _b, _c, _d, _e, _f;
150
167
  const context = (0, import_useEngineContext.default)();
151
168
  const { store } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || { store: {} };
169
+ const symbol = ((_d = (_c = (_b = store == null ? void 0 : store.getState) == null ? void 0 : _b.call(store)) == null ? void 0 : _c.global) == null ? void 0 : _d.symbol) || "$";
152
170
  const mode = (0, import_react.useMemo)(() => {
171
+ if (props.source === "restore") {
172
+ if (props.params) {
173
+ if (props.params.mode) {
174
+ return props.params.mode;
175
+ }
176
+ }
177
+ return import_const.ModeEnum.Pay;
178
+ }
153
179
  if (props.mode) {
154
180
  return props.mode;
155
181
  }
156
182
  return import_const.ModeEnum.Pay;
157
- }, [props.mode]);
158
- const action = (0, import_react.useMemo)(() => {
159
- if (mode === import_const.ModeEnum.Pay) {
160
- return import_const.RouteEnum.DeviceList;
161
- }
162
- if (mode === import_const.ModeEnum.Refund) {
163
- return import_const.RouteEnum.DeviceList;
164
- }
165
- if (mode === import_const.ModeEnum.Query) {
166
- return import_const.RouteEnum.Pay;
167
- }
168
- throw Error("未知模式");
169
- }, [mode]);
170
- const symbol = ((_d = (_c = (_b = store == null ? void 0 : store.getState) == null ? void 0 : _b.call(store)) == null ? void 0 : _c.global) == null ? void 0 : _d.symbol) || "$";
171
- const onChangeStatus = (status, params) => {
172
- props.onChangeStatus(status, params);
173
- };
183
+ }, [props.mode, props.source, props.params]);
174
184
  const state = (0, import_react.useMemo)(() => {
175
185
  const current = props.params && props.params.symbol ? props.params.symbol : symbol;
176
- console.log("current 单位 = ", props.params.symbol, symbol);
186
+ if (props.source === "restore") {
187
+ return props.params;
188
+ }
177
189
  return (0, import_manufacturer.getInitState)(
178
190
  props.type,
179
191
  props.params ? { mode, ...props.params, symbol: current } : { mode, symbol: current }
180
192
  );
181
193
  }, [mode, props.params, props.type, symbol]);
182
- (0, import_react.useEffect)(() => {
183
- document.body.id = "body";
184
- }, []);
194
+ const onChangeStatus = (0, import_react.useCallback)(
195
+ (status, params) => {
196
+ props.onChangeStatus(status, params);
197
+ },
198
+ []
199
+ );
200
+ const action = (0, import_react.useMemo)(() => {
201
+ const act = (() => {
202
+ if (state.action) {
203
+ return state.action;
204
+ }
205
+ if (mode === import_const.ModeEnum.Pay) {
206
+ if (state.device && state.pay) {
207
+ return import_const.RouteEnum.Pay;
208
+ }
209
+ if (state.device) {
210
+ return import_const.RouteEnum.Amount;
211
+ }
212
+ return import_const.RouteEnum.DeviceList;
213
+ }
214
+ if (mode === import_const.ModeEnum.Refund) {
215
+ if (state.device) {
216
+ return import_const.RouteEnum.Pay;
217
+ }
218
+ return import_const.RouteEnum.DeviceList;
219
+ }
220
+ if (mode === import_const.ModeEnum.Query) {
221
+ return import_const.RouteEnum.Pay;
222
+ }
223
+ throw Error("未知模式");
224
+ })();
225
+ if (props.source === "restore") {
226
+ onChangeStatus("page", act);
227
+ }
228
+ return act;
229
+ }, [mode, state]);
185
230
  console.log("props?.params?.device_number = ", (_e = props == null ? void 0 : props.params) == null ? void 0 : _e.device_number);
186
231
  return /* @__PURE__ */ import_react.default.createElement(import_store.Provider, { state }, /* @__PURE__ */ import_react.default.createElement(
187
232
  App,
@@ -190,7 +235,9 @@ var eftposPay_default = (props) => {
190
235
  params: props.params,
191
236
  onChangeStatus,
192
237
  terminal: props.terminal,
238
+ onChangeParams: props.onChangeParams,
193
239
  action,
240
+ source: props.source,
194
241
  device_number: (_f = props == null ? void 0 : props.params) == null ? void 0 : _f.device_number
195
242
  }
196
243
  ));