@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,433 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/eftposPay/mx51/index.tsx
30
+ var mx51_exports = {};
31
+ __export(mx51_exports, {
32
+ default: () => mx51_default
33
+ });
34
+ module.exports = __toCommonJS(mx51_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_utils = require("@pisell/utils");
37
+ var import_materials = require("@pisell/materials");
38
+ var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
39
+ var import_utils2 = require("../../../utils");
40
+ var import_store = require("../store");
41
+ var import_const = require("../const");
42
+ var import_hooks = require("../hooks");
43
+ var import_aggregatePayment = require("../aggregatePayment");
44
+ var import_payLog = __toESM(require("../utils/payLog"));
45
+ var import_types = require("../aggregatePayment/types");
46
+ var import_utils3 = require("./utils");
47
+ var import_types2 = require("./types");
48
+ var import_Action = __toESM(require("./Action"));
49
+ var import_store2 = require("../store");
50
+ var import_hooks2 = require("../hooks");
51
+ var import_manufacturer = require("../manufacturer");
52
+ var import_helper = require("../helper");
53
+ var AggregatePayment = ({ onChange }) => {
54
+ const context = (0, import_useEngineContext.default)();
55
+ const utils = context.appHelper.utils || {};
56
+ import_utils2.request.setRequest(utils == null ? void 0 : utils.request);
57
+ const {
58
+ title,
59
+ custom,
60
+ status,
61
+ eftpos,
62
+ mode,
63
+ name,
64
+ symbol,
65
+ amount,
66
+ order_id
67
+ } = (0, import_store.useContextData)();
68
+ const {
69
+ statusRef,
70
+ numRef,
71
+ netRef,
72
+ modeRef,
73
+ deviceRef,
74
+ orderIdRef,
75
+ amountRef,
76
+ payRef
77
+ } = (0, import_hooks.useStoreRef)();
78
+ const dispatch = (0, import_store2.useDispatch)();
79
+ const fail = (0, import_hooks2.useFail)(0);
80
+ const failRef = (0, import_react.useRef)(fail);
81
+ const [receiptModalShow, setReceiptModalShow] = (0, import_react.useState)(false);
82
+ const [receiptModalData, setReceiptModalData] = (0, import_react.useState)(null);
83
+ const [cancelDisabled, setCancelDisabled] = (0, import_react.useState)(false);
84
+ const actionTimeoutRef = (0, import_react.useRef)(null);
85
+ const clearRef = (0, import_react.useRef)(null);
86
+ (0, import_react.useEffect)(() => {
87
+ failRef.current = fail;
88
+ }, [fail]);
89
+ const initRef = (0, import_react.useRef)(false);
90
+ const unloadRef = (0, import_react.useRef)(false);
91
+ const updateToLoading = (title2) => {
92
+ dispatch((0, import_store2.updateStatus)(import_const.StatusEnum.Loading));
93
+ dispatch(
94
+ (0, import_store2.updateState)({
95
+ title: title2 || import_utils.locales.getText("page.eftpos-pay.text.loading")(modeRef.current)
96
+ })
97
+ );
98
+ };
99
+ const payment = (0, import_aggregatePayment.usePayment)({
100
+ paymentCode: "EFTPOS_MX51",
101
+ paymentNum: numRef.current || "",
102
+ shouldContinue: () => !(unloadRef.current || !netRef.current),
103
+ config: {
104
+ hasQueryInterval: false,
105
+ // 不开启轮询间隔
106
+ globalQueryTimeout: 1e3 * 60 * 2,
107
+ // 全局轮询超时时间2分钟
108
+ requestDelaySeconds: 130
109
+ // 接口兜底查询时间130秒
110
+ },
111
+ callback: (_instance, response) => {
112
+ var _a, _b;
113
+ console.log("callback =>>>>>> ", response);
114
+ const { status: status2, data } = response || {};
115
+ const { transaction, action } = ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a.external_unified_response) || {};
116
+ const transformedData = (0, import_utils3.parseMX51Params)(transaction, status2, data);
117
+ console.log("event_transformedData =>>>>>> ", transformedData);
118
+ dispatch((0, import_store2.updateCustom)({ customAction: transformedData }));
119
+ let needClearActionTimeout = true;
120
+ if (status2 === import_types.EPaymentStatus.Processing) {
121
+ if (action === "signature") {
122
+ dispatch((0, import_store2.updateStatus)(import_const.StatusEnum.Question));
123
+ dispatch((0, import_store2.updateState)({ title: (transformedData == null ? void 0 : transformedData.message) || "" }));
124
+ _instance.stop();
125
+ if ((_b = transformedData == null ? void 0 : transformedData.autoAction) == null ? void 0 : _b.includes("PRINT_MERCHANT_RECEIPT")) {
126
+ const merchantReceipt = (transformedData == null ? void 0 : transformedData.merchantReceipt) || "";
127
+ onChange("print", merchantReceipt ? [merchantReceipt] : []);
128
+ }
129
+ } else {
130
+ needClearActionTimeout = false;
131
+ updateToLoading();
132
+ }
133
+ } else if (status2 === import_types.EPaymentStatus.Success) {
134
+ handleSuccess(data);
135
+ } else if (status2 === import_types.EPaymentStatus.Failed) {
136
+ if (transformedData) {
137
+ dispatch((0, import_store2.updateStatus)("fail"));
138
+ dispatch((0, import_store2.updateState)({ title: (transformedData == null ? void 0 : transformedData.message) || "" }));
139
+ } else {
140
+ handleFail(data);
141
+ }
142
+ }
143
+ if (needClearActionTimeout) {
144
+ if (actionTimeoutRef.current) {
145
+ import_payLog.default.log("清除操作行为超时定时器");
146
+ clearTimeout(actionTimeoutRef.current);
147
+ actionTimeoutRef.current = null;
148
+ }
149
+ }
150
+ }
151
+ });
152
+ (0, import_react.useEffect)(() => {
153
+ console.log("mx51页面初始化", statusRef.current);
154
+ if (statusRef.current === import_const.StatusEnum.Success || statusRef.current === import_const.StatusEnum.Fail || statusRef.current === import_const.StatusEnum.Question) {
155
+ return;
156
+ }
157
+ if (initRef.current) {
158
+ return;
159
+ }
160
+ initRef.current = true;
161
+ if (numRef.current) {
162
+ console.log("payment.query");
163
+ payment.query();
164
+ return;
165
+ }
166
+ payment.run();
167
+ }, []);
168
+ (0, import_react.useEffect)(() => {
169
+ return () => {
170
+ console.log("页面卸载");
171
+ unloadRef.current = true;
172
+ if (actionTimeoutRef.current) {
173
+ clearTimeout(actionTimeoutRef.current);
174
+ actionTimeoutRef.current = null;
175
+ }
176
+ if (clearRef.current) {
177
+ clearTimeout(clearRef.current);
178
+ clearRef.current = null;
179
+ }
180
+ };
181
+ }, []);
182
+ const handleFail = (errorData) => {
183
+ var _a, _b;
184
+ const { message, response_code } = ((_a = errorData == null ? void 0 : errorData.data) == null ? void 0 : _a.external_unified_response) || {};
185
+ const _code = `${response_code || ""}` || import_const.PayStatus.PaymentFailed;
186
+ const _message = message || (errorData == null ? void 0 : errorData.message) || "";
187
+ console.log("handleFail =>>>> ", errorData, _code, _message);
188
+ (_b = failRef.current) == null ? void 0 : _b.call(failRef, { code: _code, message: _message }, true);
189
+ };
190
+ const handleSuccess = (res) => {
191
+ var _a, _b;
192
+ const receipt = [];
193
+ const { transaction, external_service_fee } = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.external_unified_response) || {};
194
+ const { merchant_receipt, customer_receipt } = transaction || {};
195
+ const card_reader_surcharge = external_service_fee || 0;
196
+ const deviceSetting = (_b = deviceRef.current) == null ? void 0 : _b.setting;
197
+ const isEftposPrintMerchantReceipt = deviceSetting == null ? void 0 : deviceSetting.print_merchant_receipt;
198
+ const isEftposPrintCustomerReceipt = deviceSetting == null ? void 0 : deviceSetting.prompt_customer_receipt;
199
+ if (!isEftposPrintMerchantReceipt && merchant_receipt) {
200
+ receipt.push(merchant_receipt);
201
+ }
202
+ if (!isEftposPrintCustomerReceipt && customer_receipt) {
203
+ receipt.push(customer_receipt);
204
+ }
205
+ dispatch((0, import_store.updateNextStep)());
206
+ dispatch(
207
+ (0, import_store2.updateCustom)({
208
+ card_reader_surcharge,
209
+ receipt
210
+ })
211
+ );
212
+ dispatch(
213
+ (0, import_store2.updateState)({
214
+ status: "success",
215
+ title: import_utils.locales.getText("page.eftpos-pay.text.successful")(
216
+ modeRef.current
217
+ )
218
+ })
219
+ );
220
+ clearRef.current = setTimeout(() => {
221
+ const params = (0, import_helper.getPayParams)(
222
+ {
223
+ mode: modeRef.current,
224
+ amount: amountRef.current,
225
+ order_id: orderIdRef.current,
226
+ number: numRef.current,
227
+ device: deviceRef.current,
228
+ pay: payRef.current,
229
+ custom: {
230
+ card_reader_surcharge,
231
+ receipt
232
+ }
233
+ },
234
+ "success"
235
+ );
236
+ onChange("success", { ...params, receipt });
237
+ }, 1e3);
238
+ };
239
+ const onCancel = (element) => {
240
+ console.log("onCancel", element);
241
+ setCancelDisabled(true);
242
+ payment.action({ submit_url: element == null ? void 0 : element.submitUrl });
243
+ actionTimeoutRef.current = setTimeout(() => {
244
+ var _a, _b, _c;
245
+ import_payLog.default.log("取消操作超时,前往标记支付");
246
+ (_b = (_a = payment == null ? void 0 : payment._instance) == null ? void 0 : _a.stop) == null ? void 0 : _b.call(_a);
247
+ (_c = failRef.current) == null ? void 0 : _c.call(failRef, { code: import_const.PayStatus.Timeout }, true);
248
+ }, import_types2.CANCEL_ACTION_TIMEOUT);
249
+ };
250
+ const onDecline = (element) => {
251
+ console.log("onDecline", element);
252
+ updateToLoading();
253
+ payment.action({ submit_url: element == null ? void 0 : element.submitUrl });
254
+ };
255
+ const onAccept = (element) => {
256
+ console.log("onAccept", element);
257
+ updateToLoading();
258
+ payment.action({ submit_url: element == null ? void 0 : element.submitUrl });
259
+ };
260
+ const onPrintMerchantReceipt = (element) => {
261
+ console.log("onPrintMerchantReceipt", element);
262
+ onChange("print", (element == null ? void 0 : element.receipt) ? [element == null ? void 0 : element.receipt] : []);
263
+ setReceiptModalShow(true);
264
+ setReceiptModalData(element == null ? void 0 : element.receipt);
265
+ };
266
+ const onPrintCustomerReceipt = (element) => {
267
+ console.log("onPrintCustomerReceipt", element);
268
+ onChange("print", (element == null ? void 0 : element.receipt) ? [element == null ? void 0 : element.receipt] : []);
269
+ setReceiptModalShow(true);
270
+ setReceiptModalData(element == null ? void 0 : element.receipt);
271
+ };
272
+ const onRetry = (element) => {
273
+ console.log("onRetry", element);
274
+ onChange("page", "pay");
275
+ const _params = {
276
+ ...custom || {},
277
+ // 自定义参数需要重新传递
278
+ mode,
279
+ name,
280
+ symbol,
281
+ amount,
282
+ order_id,
283
+ number: ""
284
+ };
285
+ dispatch((0, import_store2.updateState)((0, import_manufacturer.getInitState)(eftpos, _params)));
286
+ };
287
+ const onTransactionComplete = (element) => {
288
+ var _a, _b, _c;
289
+ console.log("onTransactionComplete", element);
290
+ const { paymentStatus, response, merchantReceipt, customerReceipt } = element._extra || {};
291
+ if (paymentStatus === import_types.EPaymentStatus.Success) {
292
+ const receipt = [];
293
+ const card_reader_surcharge = ((_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.external_unified_response) == null ? void 0 : _b.external_service_fee) || 0;
294
+ const deviceSetting = (_c = deviceRef.current) == null ? void 0 : _c.setting;
295
+ const isEftposPrintMerchantReceipt = deviceSetting == null ? void 0 : deviceSetting.print_merchant_receipt;
296
+ const isEftposPrintCustomerReceipt = deviceSetting == null ? void 0 : deviceSetting.prompt_customer_receipt;
297
+ if (!isEftposPrintMerchantReceipt && merchantReceipt) {
298
+ receipt.push(merchantReceipt);
299
+ }
300
+ if (!isEftposPrintCustomerReceipt && customerReceipt) {
301
+ receipt.push(customerReceipt);
302
+ }
303
+ const params = (0, import_helper.getPayParams)(
304
+ {
305
+ mode: modeRef.current,
306
+ amount: amountRef.current,
307
+ order_id: orderIdRef.current,
308
+ number: numRef.current,
309
+ device: deviceRef.current,
310
+ pay: payRef.current,
311
+ custom: {
312
+ card_reader_surcharge,
313
+ receipt
314
+ }
315
+ },
316
+ "success"
317
+ );
318
+ onChange("success", { ...params, receipt });
319
+ } else {
320
+ onChange("fail", {
321
+ order_id: orderIdRef.current,
322
+ number: numRef.current,
323
+ uniquePaymentNumber: numRef.current,
324
+ device: deviceRef.current
325
+ });
326
+ }
327
+ };
328
+ const onSubmitToAPI = (element, extra) => {
329
+ updateToLoading();
330
+ const inputValues = (extra == null ? void 0 : extra.inputValues) || {};
331
+ payment.action(
332
+ { submit_url: element == null ? void 0 : element.submitUrl, payload: { ...inputValues } },
333
+ { needResponse: true }
334
+ );
335
+ };
336
+ const onNormalClick = (element, config) => {
337
+ if (element == null ? void 0 : element.submitUrl) {
338
+ console.log("onNormalClick_submit_url", element == null ? void 0 : element.submitUrl);
339
+ updateToLoading();
340
+ payment.action({ submit_url: element == null ? void 0 : element.submitUrl }, config);
341
+ } else {
342
+ console.log("onNormalClick_no_submit_url", element);
343
+ }
344
+ };
345
+ const onElementClick = (element, extra) => {
346
+ console.log("onElementClick", element, extra);
347
+ import_payLog.default.log(`点击${(element == null ? void 0 : element.key) || "未知"}按钮`);
348
+ switch (element.key) {
349
+ case import_types2.EButtonKeyType.CancelTransaction:
350
+ onCancel(element);
351
+ break;
352
+ case import_types2.EButtonKeyType.DeclineSignature:
353
+ onDecline(element);
354
+ break;
355
+ case import_types2.EButtonKeyType.ApproveSignature:
356
+ onAccept(element);
357
+ break;
358
+ case import_types2.EButtonKeyType.PrintMerchantReceipt:
359
+ onPrintMerchantReceipt(element);
360
+ break;
361
+ case import_types2.EButtonKeyType.PrintCustomerReceipt:
362
+ onPrintCustomerReceipt(element);
363
+ break;
364
+ case import_types2.EButtonKeyType.RetryTransaction:
365
+ onRetry(element);
366
+ break;
367
+ case import_types2.EButtonKeyType.TransactionComplete:
368
+ onTransactionComplete(element);
369
+ break;
370
+ case import_types2.EButtonKeyType.SubmitToAPI:
371
+ onSubmitToAPI(element, extra);
372
+ break;
373
+ case import_types2.EButtonKeyType.CallTestFunction:
374
+ (0, import_materials.PisellToast)({ content: "Test" });
375
+ break;
376
+ default:
377
+ onNormalClick(element);
378
+ break;
379
+ }
380
+ };
381
+ const onCloseReceiptModal = () => {
382
+ setReceiptModalShow(false);
383
+ setReceiptModalData(null);
384
+ };
385
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-body" }, status === import_const.StatusEnum.Question ? /* @__PURE__ */ import_react.default.createElement(
386
+ "div",
387
+ {
388
+ className: "pisell-lowcode__eft-pay-title",
389
+ style: { textAlign: "center" }
390
+ },
391
+ title
392
+ ) : null, status !== import_const.StatusEnum.Success ? /* @__PURE__ */ import_react.default.createElement(
393
+ import_Action.default,
394
+ {
395
+ data: custom == null ? void 0 : custom.customAction,
396
+ showMessage: status === import_const.StatusEnum.Loading,
397
+ onClick: onElementClick,
398
+ cancelDisabled
399
+ }
400
+ ) : null), receiptModalShow ? /* @__PURE__ */ import_react.default.createElement(
401
+ import_materials.PisellModal,
402
+ {
403
+ open: receiptModalShow,
404
+ onCancel: onCloseReceiptModal,
405
+ maskClosable: true,
406
+ footer: null
407
+ },
408
+ /* @__PURE__ */ import_react.default.createElement(
409
+ "div",
410
+ {
411
+ style: {
412
+ padding: "16px",
413
+ display: "flex",
414
+ alignItems: "center",
415
+ justifyContent: "center"
416
+ }
417
+ },
418
+ /* @__PURE__ */ import_react.default.createElement(
419
+ "span",
420
+ {
421
+ style: {
422
+ display: "inline-block",
423
+ whiteSpace: "pre-wrap",
424
+ fontFamily: "monospace",
425
+ backgroundColor: "#fff"
426
+ }
427
+ },
428
+ receiptModalData
429
+ )
430
+ )
431
+ ) : null);
432
+ };
433
+ var mx51_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,43 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/eftposPay/mx51/types.ts
20
+ var types_exports = {};
21
+ __export(types_exports, {
22
+ CANCEL_ACTION_TIMEOUT: () => CANCEL_ACTION_TIMEOUT,
23
+ EButtonKeyType: () => EButtonKeyType
24
+ });
25
+ module.exports = __toCommonJS(types_exports);
26
+ var EButtonKeyType = /* @__PURE__ */ ((EButtonKeyType2) => {
27
+ EButtonKeyType2["CancelTransaction"] = "cancel_transaction";
28
+ EButtonKeyType2["TransactionComplete"] = "transaction_complete";
29
+ EButtonKeyType2["RetryTransaction"] = "retry_transaction";
30
+ EButtonKeyType2["PrintMerchantReceipt"] = "print_merchant_receipt";
31
+ EButtonKeyType2["PrintCustomerReceipt"] = "print_customer_receipt";
32
+ EButtonKeyType2["ApproveSignature"] = "approve_signature";
33
+ EButtonKeyType2["DeclineSignature"] = "decline_signature";
34
+ EButtonKeyType2["SubmitToAPI"] = "submit_to_api";
35
+ EButtonKeyType2["CallTestFunction"] = "call_test_function";
36
+ return EButtonKeyType2;
37
+ })(EButtonKeyType || {});
38
+ var CANCEL_ACTION_TIMEOUT = 1e3 * 20;
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ CANCEL_ACTION_TIMEOUT,
42
+ EButtonKeyType
43
+ });
@@ -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;