@pisell/private-materials 6.3.109 → 6.3.111

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 (85) 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 +9 -9
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +10 -10
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +11 -11
  11. package/es/components/booking/forms/sendModal/useSendModal.d.ts +1 -0
  12. package/es/components/eftposPay/hooks.d.ts +1 -1
  13. package/es/components/eftposPay/store/index.d.ts +3 -3
  14. package/es/components/eventBooking/components/ErrorTip/index.d.ts +1 -0
  15. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/CallToBook/index.d.ts +1 -0
  16. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +1 -0
  17. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +1 -0
  18. package/es/components/pay/toC/PaymentMethods/MWCreditCard/Add/index.d.ts +6 -0
  19. package/es/components/pay/toC/PaymentMethods/MWCreditCard/Add/index.js +65 -21
  20. package/es/components/pay/toC/PaymentMethods/MWCreditCard/Add/index.less +110 -9
  21. package/es/components/pay/toC/PaymentMethods/MWCreditCard/List/index.d.ts +2 -0
  22. package/es/components/pay/toC/PaymentMethods/MWCreditCard/List/index.js +28 -16
  23. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.d.ts +20 -1
  24. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.js +14 -1
  25. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.less +20 -0
  26. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/index.d.ts +7 -1
  27. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/index.js +167 -56
  28. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/index.less +47 -0
  29. package/es/components/pay/toC/PaymentMethods/MWCreditCard/components/TDSErrorModal/index.d.ts +34 -0
  30. package/es/components/pay/toC/PaymentMethods/MWCreditCard/components/TDSErrorModal/index.js +83 -0
  31. package/es/components/pay/toC/PaymentMethods/MWCreditCard/components/TDSErrorModal/index.less +52 -0
  32. package/es/components/pay/toC/PaymentMethods/MWCreditCard/index.d.ts +9 -1
  33. package/es/components/pay/toC/PaymentMethods/MWCreditCard/index.js +260 -33
  34. package/es/components/pay/toC/PaymentMethods/MWCreditCard/tds2.d.ts +23 -3
  35. package/es/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +292 -115
  36. package/es/components/pay/toC/PaymentMethods/index.js +12 -2
  37. package/es/components/pay/toC/index.js +53 -18
  38. package/es/components/pay/toC/locales.d.ts +115 -0
  39. package/es/components/pay/toC/locales.js +143 -18
  40. package/es/components/pay/toC/serve.d.ts +10 -0
  41. package/es/components/pay/toC/serve.js +40 -1
  42. package/es/components/pay/toC/utils.d.ts +5 -0
  43. package/es/components/pay/toC/utils.js +10 -0
  44. package/es/plus/pisellSalesManagement/config/booking.d.ts +6 -6
  45. package/es/plus/selectHolder/components/ErrorTip/index.d.ts +1 -0
  46. package/es/plus/walletEditor/components/ImageUpload/index.d.ts +1 -1
  47. package/es/pro/Selector/Selector.d.ts +1 -1
  48. package/lib/components/booking/forms/sendModal/useSendModal.d.ts +1 -0
  49. package/lib/components/eftposPay/hooks.d.ts +1 -1
  50. package/lib/components/eftposPay/store/index.d.ts +3 -3
  51. package/lib/components/eventBooking/components/ErrorTip/index.d.ts +1 -0
  52. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/CallToBook/index.d.ts +1 -0
  53. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +1 -0
  54. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +1 -0
  55. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/Add/index.d.ts +6 -0
  56. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/Add/index.js +40 -17
  57. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/Add/index.less +110 -9
  58. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/List/index.d.ts +2 -0
  59. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/List/index.js +17 -5
  60. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.d.ts +20 -1
  61. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.js +8 -2
  62. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.less +20 -0
  63. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/index.d.ts +7 -1
  64. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/index.js +98 -24
  65. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/index.less +47 -0
  66. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/components/TDSErrorModal/index.d.ts +34 -0
  67. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/components/TDSErrorModal/index.js +107 -0
  68. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/components/TDSErrorModal/index.less +52 -0
  69. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/index.d.ts +9 -1
  70. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/index.js +149 -5
  71. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/tds2.d.ts +23 -3
  72. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +99 -16
  73. package/lib/components/pay/toC/PaymentMethods/index.js +17 -12
  74. package/lib/components/pay/toC/index.js +34 -3
  75. package/lib/components/pay/toC/locales.d.ts +115 -0
  76. package/lib/components/pay/toC/locales.js +133 -18
  77. package/lib/components/pay/toC/serve.d.ts +10 -0
  78. package/lib/components/pay/toC/serve.js +10 -0
  79. package/lib/components/pay/toC/utils.d.ts +5 -0
  80. package/lib/components/pay/toC/utils.js +17 -0
  81. package/lib/plus/pisellSalesManagement/config/booking.d.ts +6 -6
  82. package/lib/plus/selectHolder/components/ErrorTip/index.d.ts +1 -0
  83. package/lib/plus/walletEditor/components/ImageUpload/index.d.ts +1 -1
  84. package/lib/pro/Selector/Selector.d.ts +1 -1
  85. package/package.json +4 -4
@@ -12,6 +12,7 @@ import dayjs from 'dayjs';
12
12
  import { sendWarningLog } from '@pisell/utils';
13
13
  import { PisellToast } from '@pisell/materials';
14
14
  import { setPayNumber } from "../../payGroup";
15
+ import { getUniqueIdempotencyToken } from "../../utils";
15
16
  var REACT_APP_API_ENV = process.env.REACT_APP_API_ENV;
16
17
  var paymentInfo = {
17
18
  transactionInfo: {
@@ -30,6 +31,25 @@ var paymentInfo = {
30
31
  };
31
32
  var paymentData = {};
32
33
  var postmessageUrl = 'merchantwarrior';
34
+
35
+ /**
36
+ * 当前活跃的 message 监听器清理函数。
37
+ * 步骤3(createThreeDSMethodIframe)和步骤5(createChallengeIframe)
38
+ * 各自注册 window message 监听器时会存入此变量,
39
+ * 供组件卸载或新流程启动时清理残留监听器 + reject 挂起的 Promise。
40
+ */
41
+ var activeCleanup = null;
42
+
43
+ /**
44
+ * 取消当前支付流程中残留的 message 监听器和定时器,
45
+ * 并 reject 挂起的 Promise 使 startPayment 的 await 结束。
46
+ * reject 值为 0,startPayment catch 中 `if (err === 0) return` 会静默处理。
47
+ */
48
+ export var cancelCurrentPayment = function cancelCurrentPayment() {
49
+ var _activeCleanup;
50
+ (_activeCleanup = activeCleanup) === null || _activeCleanup === void 0 || _activeCleanup();
51
+ activeCleanup = null;
52
+ };
33
53
  var log = function log(data) {
34
54
  var _template = {
35
55
  module: module,
@@ -56,7 +76,6 @@ var setHistoryLog = function setHistoryLog(log) {
56
76
  var getCurrentTime = function getCurrentTime() {
57
77
  return dayjs().format('YYYY-MM-DD HH:mm:ss');
58
78
  };
59
-
60
79
  /**
61
80
  * @title: 点击支付
62
81
  * @description:
@@ -66,17 +85,18 @@ var getCurrentTime = function getCurrentTime() {
66
85
  * @Date: 2022-10-22 10:05
67
86
  */
68
87
  export var startPayment = /*#__PURE__*/function () {
69
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref, callback) {
70
- var orderId, cardInfo, payData, paymentInfo, step2, step3, step4, step5;
88
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref, options) {
89
+ var orderId, cardInfo, payData, _ref3, callback, isCancelled, paymentInfo, step2, step3, step4, step5;
71
90
  return _regeneratorRuntime().wrap(function _callee$(_context) {
72
91
  while (1) switch (_context.prev = _context.next) {
73
92
  case 0:
74
93
  orderId = _ref.orderId, cardInfo = _ref.cardInfo, payData = _ref.payData;
94
+ _ref3 = options || {}, callback = _ref3.callback, isCancelled = _ref3.isCancelled;
75
95
  paymentInfo = {
76
96
  amount: 0,
77
97
  order_id: 0
78
98
  };
79
- _context.prev = 2;
99
+ _context.prev = 3;
80
100
  paymentData = {
81
101
  orderId: orderId,
82
102
  logList: []
@@ -91,30 +111,40 @@ export var startPayment = /*#__PURE__*/function () {
91
111
 
92
112
  // 提交卡信息到后端, 如果有 payData, 则直接使用传入数据
93
113
  if (!payData) {
94
- _context.next = 9;
114
+ _context.next = 10;
95
115
  break;
96
116
  }
97
117
  _context.t0 = payData;
98
- _context.next = 12;
118
+ _context.next = 13;
99
119
  break;
100
- case 9:
101
- _context.next = 11;
102
- return checkEnrollment(orderId, cardInfo, callback);
103
- case 11:
104
- _context.t0 = _context.sent;
120
+ case 10:
121
+ _context.next = 12;
122
+ return checkEnrollment(orderId, cardInfo, {
123
+ callback: callback,
124
+ isCancelled: isCancelled
125
+ });
105
126
  case 12:
127
+ _context.t0 = _context.sent;
128
+ case 13:
106
129
  step2 = _context.t0;
130
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
131
+ _context.next = 17;
132
+ break;
133
+ }
134
+ closeIframe();
135
+ return _context.abrupt("return");
136
+ case 17:
107
137
  setHistoryLog({
108
138
  msg: '步骤2完成: 提交卡信息到后端',
109
139
  time: getCurrentTime(),
110
140
  hasStep2: !!step2
111
141
  });
112
142
  if (!(step2 === 0)) {
113
- _context.next = 16;
143
+ _context.next = 20;
114
144
  break;
115
145
  }
116
146
  return _context.abrupt("return");
117
- case 16:
147
+ case 20:
118
148
  paymentData.step2 = step2;
119
149
  paymentInfo.amount = step2.amount;
120
150
  paymentInfo.order_id = step2.order_id;
@@ -125,10 +155,17 @@ export var startPayment = /*#__PURE__*/function () {
125
155
  });
126
156
 
127
157
  // 监听postMessage
128
- _context.next = 23;
158
+ _context.next = 27;
129
159
  return createThreeDSMethodIframe(step2, callback);
130
- case 23:
160
+ case 27:
131
161
  step3 = _context.sent;
162
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
163
+ _context.next = 31;
164
+ break;
165
+ }
166
+ closeIframe();
167
+ return _context.abrupt("return");
168
+ case 31:
132
169
  paymentData.step3 = step3;
133
170
  setHistoryLog({
134
171
  msg: '步骤3完成: iframe监听结束',
@@ -136,11 +173,11 @@ export var startPayment = /*#__PURE__*/function () {
136
173
  step3Result: step3
137
174
  });
138
175
  if (!(step3 === 'N')) {
139
- _context.next = 28;
176
+ _context.next = 35;
140
177
  break;
141
178
  }
142
179
  return _context.abrupt("return");
143
- case 28:
180
+ case 35:
144
181
  setHistoryLog({
145
182
  msg: '步骤4开始: 调用checkTDSAuth',
146
183
  time: getCurrentTime(),
@@ -149,36 +186,53 @@ export var startPayment = /*#__PURE__*/function () {
149
186
  });
150
187
 
151
188
  // 提交token至后端
152
- _context.next = 31;
153
- return checkTDSAuth(step2, step3, callback);
154
- case 31:
189
+ _context.next = 38;
190
+ return checkTDSAuth(step2, step3, {
191
+ callback: callback,
192
+ isCancelled: isCancelled
193
+ });
194
+ case 38:
155
195
  step4 = _context.sent;
196
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
197
+ _context.next = 42;
198
+ break;
199
+ }
200
+ closeIframe();
201
+ return _context.abrupt("return");
202
+ case 42:
156
203
  setHistoryLog({
157
204
  msg: '步骤4完成: checkTDSAuth 返回',
158
205
  time: getCurrentTime(),
159
206
  hasStep4: !!step4
160
207
  });
161
208
  if (!(step4 === 0)) {
162
- _context.next = 35;
209
+ _context.next = 45;
163
210
  break;
164
211
  }
165
212
  return _context.abrupt("return");
166
- case 35:
213
+ case 45:
167
214
  paymentData.step4 = step4;
168
215
 
169
216
  // 返回数据执行步骤5, 没有则略过 5&6
170
217
  if (!step4) {
171
- _context.next = 47;
218
+ _context.next = 63;
172
219
  break;
173
220
  }
174
221
  setHistoryLog({
175
222
  msg: '步骤5开始: 创建challenge iframe',
176
223
  time: getCurrentTime()
177
224
  });
178
- _context.next = 40;
225
+ _context.next = 50;
179
226
  return createChallengeIframe(step4, callback);
180
- case 40:
227
+ case 50:
181
228
  step5 = _context.sent;
229
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
230
+ _context.next = 54;
231
+ break;
232
+ }
233
+ closeIframe();
234
+ return _context.abrupt("return");
235
+ case 54:
182
236
  paymentData.step5 = step5;
183
237
  setHistoryLog({
184
238
  msg: '步骤5完成: challenge iframe结束',
@@ -190,15 +244,29 @@ export var startPayment = /*#__PURE__*/function () {
190
244
  });
191
245
 
192
246
  // 步骤6, 换取token
193
- _context.next = 46;
247
+ _context.next = 59;
194
248
  return checkPARes(step2, step4, step5);
195
- case 46:
249
+ case 59:
250
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
251
+ _context.next = 62;
252
+ break;
253
+ }
254
+ closeIframe();
255
+ return _context.abrupt("return");
256
+ case 62:
196
257
  setHistoryLog({
197
258
  msg: '步骤6完成: check_pares接口返回',
198
259
  time: getCurrentTime()
199
260
  });
200
- case 47:
201
- callback({
261
+ case 63:
262
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
263
+ _context.next = 66;
264
+ break;
265
+ }
266
+ closeIframe();
267
+ return _context.abrupt("return");
268
+ case 66:
269
+ callback === null || callback === void 0 || callback({
202
270
  key: 'hideModal'
203
271
  });
204
272
  setHistoryLog({
@@ -211,50 +279,67 @@ export var startPayment = /*#__PURE__*/function () {
211
279
  status: 'success'
212
280
  }, paymentInfo), callback);
213
281
  return _context.abrupt("return", true);
214
- case 53:
215
- _context.prev = 53;
216
- _context.t1 = _context["catch"](2);
282
+ case 72:
283
+ _context.prev = 72;
284
+ _context.t1 = _context["catch"](3);
217
285
  console.log('error', _context.t1);
218
286
  setHistoryLog({
219
287
  msg: '支付异常',
220
288
  time: getCurrentTime(),
221
- error: _context.t1
289
+ error: _context.t1,
290
+ errorCode: _context.t1 === null || _context.t1 === void 0 ? void 0 : _context.t1.code
222
291
  });
223
- callback({
292
+ closeIframe();
293
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
294
+ _context.next = 79;
295
+ break;
296
+ }
297
+ return _context.abrupt("return");
298
+ case 79:
299
+ callback === null || callback === void 0 || callback({
224
300
  key: 'hideModal'
225
301
  });
226
- closeIframe();
227
302
  if (!(_context.t1 === 0)) {
228
- _context.next = 61;
303
+ _context.next = 82;
229
304
  break;
230
305
  }
231
306
  return _context.abrupt("return");
232
- case 61:
307
+ case 82:
308
+ if (!((_context.t1 === null || _context.t1 === void 0 ? void 0 : _context.t1.code) === 700500)) {
309
+ _context.next = 85;
310
+ break;
311
+ }
312
+ callback === null || callback === void 0 || callback({
313
+ key: 'bankVerifyFailed'
314
+ });
315
+ return _context.abrupt("return", false);
316
+ case 85:
233
317
  paymentData.error = _context.t1;
234
318
  paymentEnd(_objectSpread({
235
319
  status: 'fail'
236
320
  }, paymentInfo), callback);
237
321
  return _context.abrupt("return", false);
238
- case 64:
322
+ case 88:
239
323
  case "end":
240
324
  return _context.stop();
241
325
  }
242
- }, _callee, null, [[2, 53]]);
326
+ }, _callee, null, [[3, 72]]);
243
327
  }));
244
328
  return function startPayment(_x, _x2) {
245
329
  return _ref2.apply(this, arguments);
246
330
  };
247
331
  }();
248
332
 
249
- /*******
250
- * @title: 步骤2
251
- * @description: 提交卡信息到后端
252
- * @return {*}
253
- * @Author: Wzw
254
- * @Date: 2022-10-18 10:26
333
+ /**
334
+ * @title: 前置检查 - 提交卡信息到后端(预检查版本)
335
+ * @description: 与 checkEnrollment 调用相同 API,但不包含 Toast/callback/closeIframe 等副作用。
336
+ * 失败时直接 throw error,由调用方(MWCreditCard)捕获并展示 3DS 错误弹窗。
337
+ * @param {string} orderId 订单ID
338
+ * @param {any} cardInfo 卡信息
339
+ * @return {Promise<any>} 返回后端数据(含 pay_info),失败则 throw
255
340
  */
256
- export var checkEnrollment = /*#__PURE__*/function () {
257
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(orderId, cardInfo, callback) {
341
+ export var preCheckEnrollment = /*#__PURE__*/function () {
342
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(orderId, cardInfo) {
258
343
  var _yield$request$getReq, data;
259
344
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
260
345
  while (1) switch (_context2.prev = _context2.next) {
@@ -270,13 +355,13 @@ export var checkEnrollment = /*#__PURE__*/function () {
270
355
  _context2.next = 8;
271
356
  break;
272
357
  }
273
- return _context2.abrupt("return", null);
358
+ throw new Error('Card does not support 3DS verification');
274
359
  case 8:
275
360
  return _context2.abrupt("return", data);
276
361
  case 11:
277
362
  _context2.prev = 11;
278
363
  _context2.t0 = _context2["catch"](0);
279
- // 记录卡失败的原因
364
+ // 记录失败日志
280
365
  log({
281
366
  msg: _context2.t0,
282
367
  data: {
@@ -284,24 +369,88 @@ export var checkEnrollment = /*#__PURE__*/function () {
284
369
  cardInfo: cardInfo
285
370
  }
286
371
  });
287
- callback({
372
+ // 直接向上抛出,由调用方处理
373
+ throw _context2.t0;
374
+ case 15:
375
+ case "end":
376
+ return _context2.stop();
377
+ }
378
+ }, _callee2, null, [[0, 11]]);
379
+ }));
380
+ return function preCheckEnrollment(_x3, _x4) {
381
+ return _ref4.apply(this, arguments);
382
+ };
383
+ }();
384
+
385
+ /*******
386
+ * @title: 步骤2
387
+ * @description: 提交卡信息到后端
388
+ * @return {*}
389
+ * @Author: Wzw
390
+ * @Date: 2022-10-18 10:26
391
+ */
392
+ export var checkEnrollment = /*#__PURE__*/function () {
393
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(orderId, cardInfo, options) {
394
+ var _ref6, callback, isCancelled, _yield$request$getReq2, data;
395
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
396
+ while (1) switch (_context3.prev = _context3.next) {
397
+ case 0:
398
+ _ref6 = options || {}, callback = _ref6.callback, isCancelled = _ref6.isCancelled;
399
+ _context3.prev = 1;
400
+ _context3.next = 4;
401
+ return request.getRequest().post('/h5/pay/order/mw-3ds-pay/v2/' + orderId, _objectSpread({}, cardInfo));
402
+ case 4:
403
+ _yield$request$getReq2 = _context3.sent;
404
+ data = _yield$request$getReq2.data;
405
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
406
+ _context3.next = 8;
407
+ break;
408
+ }
409
+ return _context3.abrupt("return", 0);
410
+ case 8:
411
+ setPayNumber(orderId, data === null || data === void 0 ? void 0 : data.pay_number);
412
+ if (data !== null && data !== void 0 && data.pay_info) {
413
+ _context3.next = 11;
414
+ break;
415
+ }
416
+ return _context3.abrupt("return", null);
417
+ case 11:
418
+ return _context3.abrupt("return", data);
419
+ case 14:
420
+ _context3.prev = 14;
421
+ _context3.t0 = _context3["catch"](1);
422
+ // 记录卡失败的原因
423
+ log({
424
+ msg: _context3.t0,
425
+ data: {
426
+ orderId: orderId,
427
+ cardInfo: cardInfo
428
+ }
429
+ });
430
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
431
+ _context3.next = 19;
432
+ break;
433
+ }
434
+ return _context3.abrupt("return", 0);
435
+ case 19:
436
+ callback === null || callback === void 0 || callback({
288
437
  key: 'hideModal'
289
438
  });
290
439
  closeIframe();
291
440
  PisellToast({
292
- content: (_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message) || '',
441
+ content: (_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.message) || '',
293
442
  duration: 2
294
443
  });
295
- console.log('error', _context2.t0);
296
- return _context2.abrupt("return", 0);
297
- case 19:
444
+ console.log('error', _context3.t0);
445
+ return _context3.abrupt("return", 0);
446
+ case 24:
298
447
  case "end":
299
- return _context2.stop();
448
+ return _context3.stop();
300
449
  }
301
- }, _callee2, null, [[0, 11]]);
450
+ }, _callee3, null, [[1, 14]]);
302
451
  }));
303
- return function checkEnrollment(_x3, _x4, _x5) {
304
- return _ref3.apply(this, arguments);
452
+ return function checkEnrollment(_x5, _x6, _x7) {
453
+ return _ref5.apply(this, arguments);
305
454
  };
306
455
  }();
307
456
 
@@ -314,27 +463,27 @@ export var checkEnrollment = /*#__PURE__*/function () {
314
463
  * @Date: 2022-10-18 10:36
315
464
  */
316
465
  export var createThreeDSMethodIframe = /*#__PURE__*/function () {
317
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(threeDSMethodData, callback) {
466
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(threeDSMethodData, callback) {
318
467
  var _threeDSMethodData$pa, _threeDSMethodData$pa2, _threeDSMethodData$pa3, _threeDSMethodData$pa4, _threeDSMethodData$pa5, _threeDSMethodData$pa6;
319
468
  var defaultReturnParams, displayBox, iframe, form, input, timer;
320
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
321
- while (1) switch (_context3.prev = _context3.next) {
469
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
470
+ while (1) switch (_context4.prev = _context4.next) {
322
471
  case 0:
323
472
  defaultReturnParams = {
324
473
  threeDSServerTransID: (threeDSMethodData === null || threeDSMethodData === void 0 || (_threeDSMethodData$pa = threeDSMethodData.pay_info) === null || _threeDSMethodData$pa === void 0 ? void 0 : _threeDSMethodData$pa.threeDSServerTransID) || (threeDSMethodData === null || threeDSMethodData === void 0 || (_threeDSMethodData$pa2 = threeDSMethodData.pay_info) === null || _threeDSMethodData$pa2 === void 0 ? void 0 : _threeDSMethodData$pa2.paReq) || '',
325
474
  threeDSCompInd: (threeDSMethodData === null || threeDSMethodData === void 0 || (_threeDSMethodData$pa3 = threeDSMethodData.pay_info) === null || _threeDSMethodData$pa3 === void 0 ? void 0 : _threeDSMethodData$pa3.threeDSCompInd) || 'N'
326
475
  }; // 有返回 threeDSServerTransID 直接走第4步
327
476
  if (!(threeDSMethodData !== null && threeDSMethodData !== void 0 && (_threeDSMethodData$pa4 = threeDSMethodData.pay_info) !== null && _threeDSMethodData$pa4 !== void 0 && _threeDSMethodData$pa4.threeDSServerTransID && threeDSMethodData !== null && threeDSMethodData !== void 0 && (_threeDSMethodData$pa5 = threeDSMethodData.pay_info) !== null && _threeDSMethodData$pa5 !== void 0 && _threeDSMethodData$pa5.threeDSCompInd)) {
328
- _context3.next = 3;
477
+ _context4.next = 3;
329
478
  break;
330
479
  }
331
- return _context3.abrupt("return", defaultReturnParams);
480
+ return _context4.abrupt("return", defaultReturnParams);
332
481
  case 3:
333
482
  if (!(!(threeDSMethodData !== null && threeDSMethodData !== void 0 && threeDSMethodData.pay_info.acsURL) || typeof (threeDSMethodData === null || threeDSMethodData === void 0 || (_threeDSMethodData$pa6 = threeDSMethodData.pay_info) === null || _threeDSMethodData$pa6 === void 0 ? void 0 : _threeDSMethodData$pa6.acsURL) !== 'string')) {
334
- _context3.next = 5;
483
+ _context4.next = 5;
335
484
  break;
336
485
  }
337
- return _context3.abrupt("return", defaultReturnParams);
486
+ return _context4.abrupt("return", defaultReturnParams);
338
487
  case 5:
339
488
  displayBox = document.getElementById('threeds-container'); // 清空dom中的内容
340
489
  displayBox.innerHTML = '';
@@ -365,7 +514,7 @@ export var createThreeDSMethodIframe = /*#__PURE__*/function () {
365
514
  form.method = 'post';
366
515
  form.submit();
367
516
  timer = null; // 返回promise
368
- return _context3.abrupt("return", new Promise(function (res, rej) {
517
+ return _context4.abrupt("return", new Promise(function (res, rej) {
369
518
  var _threeDSMethodData$pa7;
370
519
  var handleMessage = function handleMessage(event) {
371
520
  // 判断域名
@@ -402,15 +551,20 @@ export var createThreeDSMethodIframe = /*#__PURE__*/function () {
402
551
  });
403
552
  }, (threeDSMethodData === null || threeDSMethodData === void 0 || (_threeDSMethodData$pa7 = threeDSMethodData.pay_info) === null || _threeDSMethodData$pa7 === void 0 ? void 0 : _threeDSMethodData$pa7.tdsMethodTimeoutMS) || 10000);
404
553
  window.addEventListener('message', handleMessage, false);
554
+ activeCleanup = function activeCleanup() {
555
+ window.removeEventListener('message', handleMessage);
556
+ if (timer) clearTimeout(timer);
557
+ rej(0);
558
+ };
405
559
  }));
406
560
  case 28:
407
561
  case "end":
408
- return _context3.stop();
562
+ return _context4.stop();
409
563
  }
410
- }, _callee3);
564
+ }, _callee4);
411
565
  }));
412
- return function createThreeDSMethodIframe(_x6, _x7) {
413
- return _ref4.apply(this, arguments);
566
+ return function createThreeDSMethodIframe(_x8, _x9) {
567
+ return _ref7.apply(this, arguments);
414
568
  };
415
569
  }();
416
570
 
@@ -423,12 +577,13 @@ export var createThreeDSMethodIframe = /*#__PURE__*/function () {
423
577
  * @Date: 2022-10-18 10:43
424
578
  */
425
579
  export var checkTDSAuth = /*#__PURE__*/function () {
426
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(step2, step3, callback) {
427
- var pay_number, order_id, pay_info, amount, notifyURL, threeDSServerTransID, threeDSCompInd, currentData, isPre, _yield$request$getReq2, data;
428
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
429
- while (1) switch (_context4.prev = _context4.next) {
580
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(step2, step3, options) {
581
+ var _ref9, callback, isCancelled, pay_number, order_id, pay_info, amount, notifyURL, threeDSServerTransID, threeDSCompInd, currentData, isPre, request_unique_idempotency_token, _yield$request$getReq3, data;
582
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
583
+ while (1) switch (_context5.prev = _context5.next) {
430
584
  case 0:
431
- _context4.prev = 0;
585
+ _ref9 = options || {}, callback = _ref9.callback, isCancelled = _ref9.isCancelled;
586
+ _context5.prev = 1;
432
587
  pay_number = step2.pay_number, order_id = step2.order_id, pay_info = step2.pay_info, amount = step2.amount, notifyURL = step2.notifyURL;
433
588
  threeDSServerTransID = step3.threeDSServerTransID, threeDSCompInd = step3.threeDSCompInd;
434
589
  currentData = new Date();
@@ -436,16 +591,21 @@ export var checkTDSAuth = /*#__PURE__*/function () {
436
591
  if (REACT_APP_API_ENV === 'pre' && pay_info.check_tds_auth.card_name === 'aa bb') {
437
592
  isPre = true;
438
593
  }
594
+
595
+ // 获取唯一幂等token 方式浏览器自动重试
596
+ request_unique_idempotency_token = getUniqueIdempotencyToken();
439
597
  setHistoryLog({
440
598
  msg: '步骤4开始: 调用tds_auth_pay接口',
441
599
  time: getCurrentTime(),
442
600
  order_id: order_id,
443
- pay_number: pay_number
601
+ pay_number: pay_number,
602
+ request_unique_idempotency_token: request_unique_idempotency_token
444
603
  });
445
- _context4.next = 9;
604
+ _context5.next = 11;
446
605
  return request.getRequest().post('/h5/pay/order/mw-3ds-pay/v2/tds_auth_pay', {
447
606
  order_id: order_id,
448
607
  pay_number: pay_number,
608
+ request_unique_idempotency_token: request_unique_idempotency_token,
449
609
  mw_data: {
450
610
  accessToken: pay_info.check_tds_auth.access_token,
451
611
  method: 'checkTDSAuth',
@@ -480,9 +640,9 @@ export var checkTDSAuth = /*#__PURE__*/function () {
480
640
  notifyURL: notifyURL
481
641
  }
482
642
  });
483
- case 9:
484
- _yield$request$getReq2 = _context4.sent;
485
- data = _yield$request$getReq2.data;
643
+ case 11:
644
+ _yield$request$getReq3 = _context5.sent;
645
+ data = _yield$request$getReq3.data;
486
646
  setHistoryLog({
487
647
  msg: '步骤4完成: tds_auth_pay接口返回',
488
648
  time: getCurrentTime(),
@@ -490,44 +650,55 @@ export var checkTDSAuth = /*#__PURE__*/function () {
490
650
  });
491
651
  // 有threeDSToken 则走步骤7 直接支付
492
652
  if (data) {
493
- _context4.next = 14;
653
+ _context5.next = 16;
494
654
  break;
495
655
  }
496
- return _context4.abrupt("return", null);
497
- case 14:
498
- return _context4.abrupt("return", data);
499
- case 17:
500
- _context4.prev = 17;
501
- _context4.t0 = _context4["catch"](0);
656
+ return _context5.abrupt("return", null);
657
+ case 16:
658
+ return _context5.abrupt("return", data);
659
+ case 19:
660
+ _context5.prev = 19;
661
+ _context5.t0 = _context5["catch"](1);
502
662
  setHistoryLog({
503
663
  msg: '步骤4异常',
504
- time: getCurrentTime()
664
+ time: getCurrentTime(),
665
+ errorCode: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.code
505
666
  });
506
667
 
507
668
  // 记录卡失败的原因
508
669
  log({
509
- msg: _context4.t0,
670
+ msg: _context5.t0,
510
671
  data: paymentData
511
672
  });
673
+ if (!(isCancelled !== null && isCancelled !== void 0 && isCancelled())) {
674
+ _context5.next = 25;
675
+ break;
676
+ }
677
+ return _context5.abrupt("return", 0);
678
+ case 25:
679
+ if (!((_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.code) === 700500)) {
680
+ _context5.next = 27;
681
+ break;
682
+ }
683
+ throw _context5.t0;
684
+ case 27:
512
685
  PisellToast({
513
- content: (_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message) || '',
514
- duration: 1000 * 200,
515
- onClose: function onClose() {
516
- callback({
517
- key: 'hideModal'
518
- });
519
- closeIframe();
520
- }
686
+ content: (_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.message) || '',
687
+ duration: 1000 * 2
688
+ });
689
+ callback === null || callback === void 0 || callback({
690
+ key: 'hideModal'
521
691
  });
522
- return _context4.abrupt("return", 0);
523
- case 23:
692
+ closeIframe();
693
+ return _context5.abrupt("return", 0);
694
+ case 31:
524
695
  case "end":
525
- return _context4.stop();
696
+ return _context5.stop();
526
697
  }
527
- }, _callee4, null, [[0, 17]]);
698
+ }, _callee5, null, [[1, 19]]);
528
699
  }));
529
- return function checkTDSAuth(_x8, _x9, _x10) {
530
- return _ref5.apply(this, arguments);
700
+ return function checkTDSAuth(_x10, _x11, _x12) {
701
+ return _ref8.apply(this, arguments);
531
702
  };
532
703
  }();
533
704
 
@@ -586,6 +757,7 @@ export var createChallengeIframe = function createChallengeIframe(challengeData,
586
757
  if (timer) {
587
758
  clearTimeout(timer);
588
759
  }
760
+ window.removeEventListener('message', handleMessage);
589
761
  res(event.data.cres);
590
762
  closeIframe();
591
763
  }
@@ -602,6 +774,11 @@ export var createChallengeIframe = function createChallengeIframe(challengeData,
602
774
  rej('time out');
603
775
  }, 2 * 60 * 1000);
604
776
  window.addEventListener('message', handleMessage, false);
777
+ activeCleanup = function activeCleanup() {
778
+ window.removeEventListener('message', handleMessage);
779
+ if (timer) clearTimeout(timer);
780
+ rej(0);
781
+ };
605
782
  });
606
783
  };
607
784
 
@@ -614,15 +791,15 @@ export var createChallengeIframe = function createChallengeIframe(challengeData,
614
791
  * @Date: 2022-10-18 10:48
615
792
  */
616
793
  export var checkPARes = /*#__PURE__*/function () {
617
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(step2, step4, step5) {
618
- var pay_number, order_id, pay_info, amount, tdsPayKey, tdsPayToken, cres, _yield$request$getReq3, data;
619
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
620
- while (1) switch (_context5.prev = _context5.next) {
794
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(step2, step4, step5) {
795
+ var pay_number, order_id, pay_info, amount, tdsPayKey, tdsPayToken, cres, _yield$request$getReq4, data;
796
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
797
+ while (1) switch (_context6.prev = _context6.next) {
621
798
  case 0:
622
799
  pay_number = step2.pay_number, order_id = step2.order_id, pay_info = step2.pay_info, amount = step2.amount;
623
800
  tdsPayKey = step4.tdsPayKey, tdsPayToken = step4.tdsPayToken;
624
801
  cres = step5;
625
- _context5.next = 5;
802
+ _context6.next = 5;
626
803
  return request.getRequest().post('/h5/pay/order/mw-3ds-pay/v2/check_pares', {
627
804
  order_id: order_id,
628
805
  pay_number: pay_number,
@@ -638,17 +815,17 @@ export var checkPARes = /*#__PURE__*/function () {
638
815
  }
639
816
  });
640
817
  case 5:
641
- _yield$request$getReq3 = _context5.sent;
642
- data = _yield$request$getReq3.data;
643
- return _context5.abrupt("return", data);
818
+ _yield$request$getReq4 = _context6.sent;
819
+ data = _yield$request$getReq4.data;
820
+ return _context6.abrupt("return", data);
644
821
  case 8:
645
822
  case "end":
646
- return _context5.stop();
823
+ return _context6.stop();
647
824
  }
648
- }, _callee5);
825
+ }, _callee6);
649
826
  }));
650
- return function checkPARes(_x11, _x12, _x13) {
651
- return _ref6.apply(this, arguments);
827
+ return function checkPARes(_x13, _x14, _x15) {
828
+ return _ref10.apply(this, arguments);
652
829
  };
653
830
  }();
654
831