@alipay/ams-checkout 1.15.1 → 1.18.0

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.
@@ -47,6 +47,7 @@ var ComponentApp = /*#__PURE__*/function () {
47
47
  _defineProperty(this, "_selector", void 0);
48
48
  _defineProperty(this, "_appVersion", void 0);
49
49
  _defineProperty(this, "_isRetention", void 0);
50
+ _defineProperty(this, "_allowSubmitPayCallAhead", void 0);
50
51
  _defineProperty(this, "_actionQueryPromise", null);
51
52
  _defineProperty(this, "_actionSubmitPromise", null);
52
53
  _defineProperty(this, "_renderParams", null);
@@ -56,7 +57,7 @@ var ComponentApp = /*#__PURE__*/function () {
56
57
  _defineProperty(this, "_multipleCallbackEvents", void 0);
57
58
  _defineProperty(this, "_merchantAppointParam", void 0);
58
59
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
59
- this._appVersion = '1.15.1';
60
+ this._appVersion = '1.18.0';
60
61
  this._isInitComponent = false;
61
62
  this._selector = "#".concat(COMPONENT_SECTION_ID);
62
63
  this.createIframeNode = function () {
@@ -247,6 +248,10 @@ var ComponentApp = /*#__PURE__*/function () {
247
248
  key: "appendIframeNodes",
248
249
  value: function appendIframeNodes(componentSign, renderParams) {
249
250
  var _renderParams,
251
+ _this$_renderParams5,
252
+ _this$_renderParams6,
253
+ _this$_renderParams7,
254
+ _this$_renderParams8,
250
255
  _this3 = this;
251
256
  if (this._isInitComponent) {
252
257
  this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
@@ -266,6 +271,61 @@ var ComponentApp = /*#__PURE__*/function () {
266
271
  key: 'sdk_create_component',
267
272
  value: Date.now()
268
273
  });
274
+ var params = {
275
+ paymentSessionData: this._renderParams && ((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData) || '',
276
+ paymentSessionConfig: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 || (_this$_renderParams6 = _this$_renderParams6.paymentSessionMetaData) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionConfig
277
+ };
278
+ var _ref2 = params.paymentSessionConfig || {},
279
+ _ref2$productSceneVer = _ref2.productSceneVersion,
280
+ productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
281
+ _ref2$productScene = _ref2.productScene,
282
+ productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
283
+ var _ref3 = ((_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.paymentSessionMetaData) || {},
284
+ _ref3$action = _ref3.action,
285
+ _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
286
+ _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
287
+ autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb,
288
+ _ref3$action2$require = _ref3$action2.requireFastSdk,
289
+ requireFastSdk = _ref3$action2$require === void 0 ? false : _ref3$action2$require;
290
+ var _ref4 = ((_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.paymentSessionMetaData) || {},
291
+ _ref4$authUrlInfo = _ref4.authUrlInfo,
292
+ authUrlInfo = _ref4$authUrlInfo === void 0 ? {} : _ref4$authUrlInfo;
293
+ this.AMSSDK.logger.logInfo({
294
+ title: 'sdk_event_createComponent'
295
+ }, {
296
+ version: productSceneVersion,
297
+ product: this.AMSSDK.options.product
298
+ }).send();
299
+ if (componentSignEnum.EASY_PAY_WALLET === this._componentSign) {
300
+ if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '1.0' && !autoDebitWithToken && requireFastSdk) {
301
+ // EASY_PAY 1.0首次支付,requireFastSdk为true,不需要接口请求
302
+ this.handleAuthUrlInfo(authUrlInfo);
303
+ return;
304
+ }
305
+ }
306
+ if (componentSignEnum.AUTO_DEBIT_WALLET === this._componentSign) {
307
+ var _this$_renderParams9, _action$web, _action$wap;
308
+ var action = ((_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 || (_this$_renderParams9 = _this$_renderParams9.paymentSessionMetaData) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.action) || {};
309
+ var signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
310
+ var _requireFastSdk = (action === null || action === void 0 ? void 0 : action.requireFastSdk) || false;
311
+ if (signType === 'REDIRECT' && _requireFastSdk === true) {
312
+ // REDIRECT,requireFastSdk为true,不需要接口请求
313
+ this.handleAuthUrlInfo(authUrlInfo);
314
+ return;
315
+ }
316
+ }
317
+ if (componentSignEnum.AUTO_DEBIT_PAY_WALLET === this._componentSign) {
318
+ if (requireFastSdk === true && productSceneVersion === '1.0') {
319
+ // REDIRECT,requireFastSdk为true,不需要接口请求
320
+ this.handleAuthUrlInfo(authUrlInfo);
321
+ return;
322
+ } else {
323
+ return Promise.reject({
324
+ code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
325
+ message: "Abnormal response data, interface failure, or unsupported payment method."
326
+ });
327
+ }
328
+ }
269
329
  this.dispatchToSDK(EVENT.eventCallback.name, {
270
330
  code: eventCodeEnum.SDK_START_OF_LOADING
271
331
  });
@@ -275,10 +335,10 @@ var ComponentApp = /*#__PURE__*/function () {
275
335
  insertStyleSheet();
276
336
  }
277
337
  if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
278
- var _this$_renderParams5;
338
+ var _this$_renderParams10;
279
339
  createBaseElement(this.platform, this.closeBtnFunc.bind(this));
280
340
  createRetentionPopup(this.platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
281
- var channelBehavior = getChannelBehavior((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.paymentSessionMetaData);
341
+ var channelBehavior = getChannelBehavior((_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.paymentSessionMetaData);
282
342
  var onClickOutside = function onClickOutside() {};
283
343
  if (channelBehavior !== null && channelBehavior !== void 0 && channelBehavior.allowClickOutsideClose) {
284
344
  onClickOutside = this.closeBtnFunc.bind(this);
@@ -366,19 +426,18 @@ var ComponentApp = /*#__PURE__*/function () {
366
426
  }, {
367
427
  key: "createActionQueryPromise",
368
428
  value: function createActionQueryPromise() {
369
- var _this$_renderParams6,
429
+ var _this$_renderParams11,
370
430
  _this5 = this;
371
- var paymentMethodType = (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 || (_this$_renderParams6 = _this$_renderParams6.paymentSessionMetaData) === null || _this$_renderParams6 === void 0 || (_this$_renderParams6 = _this$_renderParams6.paymentMethodInfoView) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentMethodType;
431
+ var paymentMethodType = (_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.paymentSessionMetaData) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.paymentMethodInfoView) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.paymentMethodType;
372
432
  this._performanceData.push({
373
433
  key: 'sdk_action_query_start',
374
434
  value: Date.now()
375
435
  });
376
-
377
436
  // eslint-disable-next-line no-async-promise-executor
378
437
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
379
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
438
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
380
439
  var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5, _this5$_renderParams6;
381
- var envInfo, params, _ref3, _ref3$extendInfo, extendInfo, actionData, enableVaultingApiOptimize, enableEasypayApiOptimize, _ref4, skipSdkQuery, skipSdkQueryForm, extendInfoData, ifSkip, channelBehavior, _this5$_renderParams7, _this5$_renderParams8, _ref5, _ref5$productSceneVer, productSceneVersion, _ref5$productScene, productScene, _ref6, _ref6$action, _ref6$action2, _ref6$action2$autoDeb, autoDebitWithToken, _this5$_renderParams9, _action$web, _action$wap, action, signType;
440
+ var envInfo, params, _ref6, _ref6$extendInfo, extendInfo, actionData, enableVaultingApiOptimize, enableEasypayApiOptimize, _ref7, skipSdkQuery, skipSdkQueryForm, extendInfoData, ifSkip, channelBehavior, _this5$_renderParams7, _this5$_renderParams8, _ref8, _ref8$productSceneVer, productSceneVersion, _ref8$productScene, productScene, _ref9, _ref9$action, _ref9$action2, _ref9$action2$autoDeb, autoDebitWithToken, _this5$_renderParams9, _action$web2, _action$wap2, action, signType;
382
441
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
383
442
  while (1) switch (_context2.prev = _context2.next) {
384
443
  case 0:
@@ -394,10 +453,10 @@ var ComponentApp = /*#__PURE__*/function () {
394
453
  /**
395
454
  * @description Simulated or unnecessary scenarios
396
455
  */
397
- _ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, _ref3$extendInfo = _ref3.extendInfo, extendInfo = _ref3$extendInfo === void 0 ? '' : _ref3$extendInfo, actionData = _ref3.action;
456
+ _ref6 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, _ref6$extendInfo = _ref6.extendInfo, extendInfo = _ref6$extendInfo === void 0 ? '' : _ref6$extendInfo, actionData = _ref6.action;
398
457
  enableVaultingApiOptimize = false;
399
458
  enableEasypayApiOptimize = false;
400
- _ref4 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action) || {}, skipSdkQuery = _ref4.skipSdkQuery, skipSdkQueryForm = _ref4.skipSdkQueryForm;
459
+ _ref7 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action) || {}, skipSdkQuery = _ref7.skipSdkQuery, skipSdkQueryForm = _ref7.skipSdkQueryForm;
401
460
  try {
402
461
  extendInfoData = JSON.parse(extendInfo);
403
462
  enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
@@ -481,8 +540,8 @@ var ComponentApp = /*#__PURE__*/function () {
481
540
  _context2.next = 40;
482
541
  break;
483
542
  }
484
- _ref5 = params.paymentSessionConfig || {}, _ref5$productSceneVer = _ref5.productSceneVersion, productSceneVersion = _ref5$productSceneVer === void 0 ? '' : _ref5$productSceneVer, _ref5$productScene = _ref5.productScene, productScene = _ref5$productScene === void 0 ? '' : _ref5$productScene;
485
- _ref6 = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.paymentSessionMetaData) || {}, _ref6$action = _ref6.action, _ref6$action2 = _ref6$action === void 0 ? {} : _ref6$action, _ref6$action2$autoDeb = _ref6$action2.autoDebitWithToken, autoDebitWithToken = _ref6$action2$autoDeb === void 0 ? false : _ref6$action2$autoDeb;
543
+ _ref8 = params.paymentSessionConfig || {}, _ref8$productSceneVer = _ref8.productSceneVersion, productSceneVersion = _ref8$productSceneVer === void 0 ? '' : _ref8$productSceneVer, _ref8$productScene = _ref8.productScene, productScene = _ref8$productScene === void 0 ? '' : _ref8$productScene;
544
+ _ref9 = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.paymentSessionMetaData) || {}, _ref9$action = _ref9.action, _ref9$action2 = _ref9$action === void 0 ? {} : _ref9$action, _ref9$action2$autoDeb = _ref9$action2.autoDebitWithToken, autoDebitWithToken = _ref9$action2$autoDeb === void 0 ? false : _ref9$action2$autoDeb;
486
545
  if (!((_this5$_renderParams8 = _this5._renderParams) !== null && _this5$_renderParams8 !== void 0 && (_this5$_renderParams8 = _this5$_renderParams8.paymentSessionMetaData) !== null && _this5$_renderParams8 !== void 0 && (_this5$_renderParams8 = _this5$_renderParams8.action) !== null && _this5$_renderParams8 !== void 0 && _this5$_renderParams8.skipSdkQuery && enableEasypayApiOptimize)) {
487
546
  _context2.next = 35;
488
547
  break;
@@ -492,7 +551,7 @@ var ComponentApp = /*#__PURE__*/function () {
492
551
  success: true
493
552
  }));
494
553
  case 35:
495
- if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
554
+ if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0')) {
496
555
  _context2.next = 37;
497
556
  break;
498
557
  }
@@ -511,7 +570,7 @@ var ComponentApp = /*#__PURE__*/function () {
511
570
  break;
512
571
  }
513
572
  action = ((_this5$_renderParams9 = _this5._renderParams) === null || _this5$_renderParams9 === void 0 || (_this5$_renderParams9 = _this5$_renderParams9.paymentSessionMetaData) === null || _this5$_renderParams9 === void 0 ? void 0 : _this5$_renderParams9.action) || {};
514
- signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
573
+ signType = isPC() ? action === null || action === void 0 || (_action$web2 = action.web) === null || _action$web2 === void 0 ? void 0 : _action$web2.signType : action === null || action === void 0 || (_action$wap2 = action.wap) === null || _action$wap2 === void 0 ? void 0 : _action$wap2.signType;
515
574
  if (!(signType === 'SMS')) {
516
575
  _context2.next = 45;
517
576
  break;
@@ -579,7 +638,7 @@ var ComponentApp = /*#__PURE__*/function () {
579
638
  }, _callee2);
580
639
  }));
581
640
  return function (_x, _x2) {
582
- return _ref2.apply(this, arguments);
641
+ return _ref5.apply(this, arguments);
583
642
  };
584
643
  }());
585
644
  return this._actionQueryPromise;
@@ -589,24 +648,24 @@ var ComponentApp = /*#__PURE__*/function () {
589
648
  }, {
590
649
  key: "createSubmitPromise",
591
650
  value: function createSubmitPromise() {
592
- var _this$_renderParams7,
593
- _this$_renderParams8,
594
- _this$_renderParams9,
651
+ var _this$_renderParams12,
652
+ _this$_renderParams13,
653
+ _this$_renderParams14,
595
654
  _this6 = this;
596
655
  this._performanceData.push({
597
656
  key: 'sdk_submit_start',
598
657
  value: Date.now()
599
658
  });
600
659
  var params = {
601
- paymentSessionData: this._renderParams && ((_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData) || '',
602
- paymentSessionConfig: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 || (_this$_renderParams8 = _this$_renderParams8.paymentSessionMetaData) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.paymentSessionConfig
660
+ paymentSessionData: this._renderParams && ((_this$_renderParams12 = this._renderParams) === null || _this$_renderParams12 === void 0 ? void 0 : _this$_renderParams12.sessionData) || '',
661
+ paymentSessionConfig: (_this$_renderParams13 = this._renderParams) === null || _this$_renderParams13 === void 0 || (_this$_renderParams13 = _this$_renderParams13.paymentSessionMetaData) === null || _this$_renderParams13 === void 0 ? void 0 : _this$_renderParams13.paymentSessionConfig
603
662
  };
604
- var channelBehavior = getChannelBehavior((_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.paymentSessionMetaData);
663
+ var channelBehavior = getChannelBehavior((_this$_renderParams14 = this._renderParams) === null || _this$_renderParams14 === void 0 ? void 0 : _this$_renderParams14.paymentSessionMetaData);
605
664
  // eslint-disable-next-line no-async-promise-executor
606
665
  this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
607
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
666
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
608
667
  var _channelBehavior$buil, _this6$_renderParams$;
609
- var shouldSkipSubmitPayInSDK, _this6$_renderParams, extParams;
668
+ var shouldSkipSubmitPayInSDK, _this6$_renderParams, _this6$_renderParams2, _ref11, _ref11$productSceneVe, productSceneVersion, _ref11$productScene, productScene, _ref12, _ref12$action, _ref12$action2, _ref12$action2$enable, enableSignAgreement, _ref12$action2$autoDe, autoDebitWithToken, extParams;
610
669
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
611
670
  while (1) switch (_context3.prev = _context3.next) {
612
671
  case 0:
@@ -617,15 +676,25 @@ var ComponentApp = /*#__PURE__*/function () {
617
676
  } else {
618
677
  shouldSkipSubmitPayInSDK = !((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.action) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.skipSdkQuery) || componentSignEnum.EASY_PAY_WALLET !== _this6._componentSign;
619
678
  }
679
+ if (componentSignEnum.EASY_PAY_WALLET === _this6._componentSign) {
680
+ _ref11 = params.paymentSessionConfig || {}, _ref11$productSceneVe = _ref11.productSceneVersion, productSceneVersion = _ref11$productSceneVe === void 0 ? '' : _ref11$productSceneVe, _ref11$productScene = _ref11.productScene, productScene = _ref11$productScene === void 0 ? '' : _ref11$productScene;
681
+ _ref12 = ((_this6$_renderParams2 = _this6._renderParams) === null || _this6$_renderParams2 === void 0 ? void 0 : _this6$_renderParams2.paymentSessionMetaData) || {}, _ref12$action = _ref12.action, _ref12$action2 = _ref12$action === void 0 ? {} : _ref12$action, _ref12$action2$enable = _ref12$action2.enableSignAgreement, enableSignAgreement = _ref12$action2$enable === void 0 ? false : _ref12$action2$enable, _ref12$action2$autoDe = _ref12$action2.autoDebitWithToken, autoDebitWithToken = _ref12$action2$autoDe === void 0 ? false : _ref12$action2$autoDe;
682
+ if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
683
+ ///EasyPay 2.0 首次传signAgreement字段
684
+ params['signAgreement'] = enableSignAgreement;
685
+ }
686
+ }
687
+ // 带上标记告知WebCheckOut SDK已发送submitpay请求
688
+ _this6._allowSubmitPayCallAhead = !shouldSkipSubmitPayInSDK;
620
689
  if (!shouldSkipSubmitPayInSDK) {
621
- _context3.next = 4;
690
+ _context3.next = 6;
622
691
  break;
623
692
  }
624
693
  return _context3.abrupt("return", resolve({
625
694
  message: 'sdk no need to make submitPay request',
626
695
  success: true
627
696
  }));
628
- case 4:
697
+ case 6:
629
698
  _this6.AMSSDK.logger.logInfo({
630
699
  title: 'sdk_event_submitPay'
631
700
  }, {
@@ -644,9 +713,9 @@ var ComponentApp = /*#__PURE__*/function () {
644
713
  _context3.t0 = submitPayInfo;
645
714
  _context3.t1 = params;
646
715
  _context3.t2 = _this6.AMSSDK.options.env.environment;
647
- _context3.next = 12;
716
+ _context3.next = 14;
648
717
  return _this6.getDeviceIdAndLog();
649
- case 12:
718
+ case 14:
650
719
  _context3.t3 = _context3.sent;
651
720
  _context3.t4 = {
652
721
  deviceId: _context3.t3
@@ -680,14 +749,14 @@ var ComponentApp = /*#__PURE__*/function () {
680
749
  success: false
681
750
  });
682
751
  });
683
- case 17:
752
+ case 19:
684
753
  case "end":
685
754
  return _context3.stop();
686
755
  }
687
756
  }, _callee3);
688
757
  }));
689
758
  return function (_x3) {
690
- return _ref7.apply(this, arguments);
759
+ return _ref10.apply(this, arguments);
691
760
  };
692
761
  }());
693
762
  }
@@ -807,8 +876,13 @@ var ComponentApp = /*#__PURE__*/function () {
807
876
  path = _getIframeUrl2.path,
808
877
  locationSearch = _getIframeUrl2.locationSearch;
809
878
  this._appLocationSearch = locationSearch;
810
- this.app.src = "".concat(path, "?").concat(locationSearch);
811
-
879
+ // locationSearch 是一个序列化好的字符串
880
+ // 先判断path 是否有QueryParams,如果有需要扩展,否则直接拼?xx=xx
881
+ if (path.indexOf('?') !== -1) {
882
+ this.app.src = "".concat(path, "&").concat(locationSearch);
883
+ } else {
884
+ this.app.src = "".concat(path, "?").concat(locationSearch);
885
+ }
812
886
  // Subscribe to messages from iframe
813
887
  this.addEventListener();
814
888
  } catch (error) {
@@ -823,7 +897,12 @@ var ComponentApp = /*#__PURE__*/function () {
823
897
  }, {
824
898
  key: "listener",
825
899
  value: function listener(e) {
900
+ var _e$data;
826
901
  if (e.origin !== this.appDomain) return;
902
+ if (((_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.source) === 'react-devtools-content-script') {
903
+ // 防止 react 开发工具发的消息,非常频繁影响查看日志
904
+ return;
905
+ }
827
906
  var isJson = isJsonString(e.data);
828
907
  if (isJson) {
829
908
  var data = JSON.parse(e.data);
@@ -1203,11 +1282,31 @@ var ComponentApp = /*#__PURE__*/function () {
1203
1282
  this.app.style.height = "".concat(data.context.data.height, "px");
1204
1283
  }
1205
1284
  }
1285
+ }, {
1286
+ key: "handleAuthUrlInfo",
1287
+ value: function handleAuthUrlInfo(authUrlInfo) {
1288
+ var data = {};
1289
+ if (!(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.normalUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.schemeUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.applinkUrl) && authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.authUrl) {
1290
+ data = {
1291
+ normalUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
1292
+ schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
1293
+ applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl
1294
+ };
1295
+ } else {
1296
+ data = {
1297
+ normalUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.normalUrl,
1298
+ schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.schemeUrl,
1299
+ applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl
1300
+ };
1301
+ }
1302
+ this.handleRedirect(data, true);
1303
+ }
1206
1304
  }, {
1207
1305
  key: "handleRedirect",
1208
1306
  value: function handleRedirect(data) {
1209
1307
  var _data$isDestroy,
1210
1308
  _this7 = this;
1309
+ var fromFastSdk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1211
1310
  var _data = typeof data === 'string' ? {
1212
1311
  normalUrl: data
1213
1312
  } : _objectSpread(_objectSpread({}, data), {}, {
@@ -1230,7 +1329,8 @@ var ComponentApp = /*#__PURE__*/function () {
1230
1329
  }, {
1231
1330
  redirectInfo: JSON.stringify(_data),
1232
1331
  openType: type,
1233
- url: url
1332
+ url: url,
1333
+ fromFastSdk: fromFastSdk
1234
1334
  }).send();
1235
1335
  };
1236
1336
  var failCallback = function failCallback(type, url) {
@@ -1243,7 +1343,8 @@ var ComponentApp = /*#__PURE__*/function () {
1243
1343
  }, {
1244
1344
  redirectInfo: JSON.stringify(_data),
1245
1345
  openType: type,
1246
- url: url
1346
+ url: url,
1347
+ fromFastSdk: fromFastSdk
1247
1348
  }).send();
1248
1349
  };
1249
1350
 
@@ -1286,9 +1387,9 @@ var ComponentApp = /*#__PURE__*/function () {
1286
1387
  }
1287
1388
  }, {
1288
1389
  key: "handleDeclareInfo",
1289
- value: function handleDeclareInfo(_ref8) {
1290
- var _ref8$closeDialogData = _ref8.closeDialogData,
1291
- closeDialogData = _ref8$closeDialogData === void 0 ? {} : _ref8$closeDialogData;
1390
+ value: function handleDeclareInfo(_ref13) {
1391
+ var _ref13$closeDialogDat = _ref13.closeDialogData,
1392
+ closeDialogData = _ref13$closeDialogDat === void 0 ? {} : _ref13$closeDialogDat;
1292
1393
  _handleDeclareInfo({
1293
1394
  closeDialogData: closeDialogData
1294
1395
  });
@@ -1429,7 +1530,7 @@ var ComponentApp = /*#__PURE__*/function () {
1429
1530
  key: "sendRenderEvent",
1430
1531
  value: (function () {
1431
1532
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1432
- var _this$_renderParams10, _this$_renderParams11, _this$_renderParams12, _this$_renderParams13, _this$_renderParams14, _this$_renderParams15, _this$AMSSDK$logger, _this$_renderParams16, _this$_renderParams17, _this$_renderParams18, _this$AMSSDK, _this$_renderParams19, res, submitRes;
1533
+ var _this$_renderParams15, _this$_renderParams16, _this$_renderParams17, _this$_renderParams18, _this$_renderParams19, _this$_renderParams20, _this$AMSSDK$logger, _this$_renderParams21, _this$_renderParams22, _this$_renderParams23, _this$AMSSDK, _this$_renderParams24, res, submitRes;
1433
1534
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1434
1535
  while (1) switch (_context8.prev = _context8.next) {
1435
1536
  case 0:
@@ -1458,28 +1559,29 @@ var ComponentApp = /*#__PURE__*/function () {
1458
1559
  data: {
1459
1560
  queryResult: res,
1460
1561
  submitResult: submitRes,
1461
- sessionResult: (_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.paymentSessionMetaData,
1462
- paymentSessionData: (_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.sessionData,
1562
+ sessionResult: (_this$_renderParams15 = this._renderParams) === null || _this$_renderParams15 === void 0 ? void 0 : _this$_renderParams15.paymentSessionMetaData,
1563
+ paymentSessionData: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.sessionData,
1463
1564
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
1464
- renderDisplayType: (_this$_renderParams12 = this._renderParams) === null || _this$_renderParams12 === void 0 ? void 0 : _this$_renderParams12.renderDisplayType,
1465
- appearance: (_this$_renderParams13 = this._renderParams) === null || _this$_renderParams13 === void 0 ? void 0 : _this$_renderParams13.appearance,
1466
- notRedirectAfterComplete: ((_this$_renderParams14 = this._renderParams) === null || _this$_renderParams14 === void 0 ? void 0 : _this$_renderParams14.notRedirectAfterComplete) === true,
1565
+ renderDisplayType: (_this$_renderParams17 = this._renderParams) === null || _this$_renderParams17 === void 0 ? void 0 : _this$_renderParams17.renderDisplayType,
1566
+ appearance: (_this$_renderParams18 = this._renderParams) === null || _this$_renderParams18 === void 0 ? void 0 : _this$_renderParams18.appearance,
1567
+ notRedirectAfterComplete: ((_this$_renderParams19 = this._renderParams) === null || _this$_renderParams19 === void 0 ? void 0 : _this$_renderParams19.notRedirectAfterComplete) === true,
1467
1568
  merchantAppointParam: this._merchantAppointParam,
1569
+ allowSubmitPayCallAhead: this._allowSubmitPayCallAhead,
1468
1570
  envInfo: {
1469
1571
  screenHeight: screen.height,
1470
1572
  screenWidth: screen.width
1471
1573
  },
1472
1574
  logMetaData: _objectSpread(_objectSpread({
1473
- trackId: (_this$_renderParams15 = this._renderParams) === null || _this$_renderParams15 === void 0 ? void 0 : _this$_renderParams15.sessionData,
1575
+ trackId: (_this$_renderParams20 = this._renderParams) === null || _this$_renderParams20 === void 0 ? void 0 : _this$_renderParams20.sessionData,
1474
1576
  platform: this.platform,
1475
1577
  firstLogTime: (_this$AMSSDK$logger = this.AMSSDK.logger) === null || _this$AMSSDK$logger === void 0 ? void 0 : _this$AMSSDK$logger.getComponentStartTime()
1476
- }, ((_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 || (_this$_renderParams16 = _this$_renderParams16.paymentSessionMetaData) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.paymentSessionConfig) || {}), {}, {
1477
- renderDisplayType: (_this$_renderParams17 = this._renderParams) === null || _this$_renderParams17 === void 0 ? void 0 : _this$_renderParams17.renderDisplayType,
1578
+ }, ((_this$_renderParams21 = this._renderParams) === null || _this$_renderParams21 === void 0 || (_this$_renderParams21 = _this$_renderParams21.paymentSessionMetaData) === null || _this$_renderParams21 === void 0 ? void 0 : _this$_renderParams21.paymentSessionConfig) || {}), {}, {
1579
+ renderDisplayType: (_this$_renderParams22 = this._renderParams) === null || _this$_renderParams22 === void 0 ? void 0 : _this$_renderParams22.renderDisplayType,
1478
1580
  sdkVersion: this._appVersion,
1479
- merchantId: (_this$_renderParams18 = this._renderParams) === null || _this$_renderParams18 === void 0 || (_this$_renderParams18 = _this$_renderParams18.paymentSessionMetaData) === null || _this$_renderParams18 === void 0 ? void 0 : _this$_renderParams18.clientId,
1581
+ merchantId: (_this$_renderParams23 = this._renderParams) === null || _this$_renderParams23 === void 0 || (_this$_renderParams23 = _this$_renderParams23.paymentSessionMetaData) === null || _this$_renderParams23 === void 0 ? void 0 : _this$_renderParams23.clientId,
1480
1582
  instanceId: (_this$AMSSDK = this.AMSSDK) === null || _this$AMSSDK === void 0 ? void 0 : _this$AMSSDK._instanceId,
1481
1583
  performanceData: this._performanceData,
1482
- paymentMethodType: (_this$_renderParams19 = this._renderParams) === null || _this$_renderParams19 === void 0 || (_this$_renderParams19 = _this$_renderParams19.paymentSessionMetaData) === null || _this$_renderParams19 === void 0 || (_this$_renderParams19 = _this$_renderParams19.paymentMethodInfoView) === null || _this$_renderParams19 === void 0 ? void 0 : _this$_renderParams19.paymentMethodType
1584
+ paymentMethodType: (_this$_renderParams24 = this._renderParams) === null || _this$_renderParams24 === void 0 || (_this$_renderParams24 = _this$_renderParams24.paymentSessionMetaData) === null || _this$_renderParams24 === void 0 || (_this$_renderParams24 = _this$_renderParams24.paymentMethodInfoView) === null || _this$_renderParams24 === void 0 ? void 0 : _this$_renderParams24.paymentMethodType
1483
1585
  })
1484
1586
  }
1485
1587
  }
@@ -47,6 +47,7 @@ export declare enum componentSignEnum {
47
47
  'CASHIER_PAYMENT_BANK' = "CASHIER_PAYMENT_BANK",
48
48
  'CASHIER_PAYMENT_APM' = "CASHIER_PAYMENT_APM",
49
49
  'AUTO_DEBIT_WALLET' = "AUTO_DEBIT_WALLET",
50
+ 'AUTO_DEBIT_PAY_WALLET' = "AUTO_DEBIT_PAY_WALLET",
50
51
  'NONE' = "NONE",
51
52
  'VAULTING_CARD' = "VAULTING_CARD"
52
53
  }
@@ -54,6 +55,7 @@ export declare enum productSceneEnum {
54
55
  'EASY_PAY' = "EASY_PAY",
55
56
  'CASHIER_PAYMENT' = "CASHIER_PAYMENT",
56
57
  'AUTO_DEBIT' = "AUTO_DEBIT",
58
+ 'AUTO_DEBIT_PAY' = "AUTO_DEBIT_PAY",
57
59
  'VAULTING' = "VAULTING",
58
60
  'FLASH_BUY' = "FLASH_BUY",
59
61
  'CARD_APPLE_PAY' = "CARD_APPLE_PAY"
@@ -136,6 +138,10 @@ export interface InitSecurityConfig {
136
138
  product: productSceneEnum;
137
139
  region?: string;
138
140
  }
141
+ export interface frontModulesToBeLoadedInterface {
142
+ acquirerName: string;
143
+ scriptUrl: string;
144
+ }
139
145
  export interface IpaymentSessionMetaData {
140
146
  clientId?: string;
141
147
  renderDisplayType?: string;
@@ -147,13 +153,22 @@ export interface IpaymentSessionMetaData {
147
153
  action?: {
148
154
  amountConfirmRequired?: boolean;
149
155
  autoDebitWithToken: boolean;
156
+ enableSignAgreement?: boolean;
150
157
  skipSdkQuery: boolean;
158
+ requireFastSdk: boolean;
151
159
  skipSdkQueryForm?: {
152
160
  value: boolean;
153
161
  version: string;
154
162
  platform: string;
155
163
  };
156
164
  };
165
+ authUrlInfo?: {
166
+ appIdentifier?: string;
167
+ applinkUrl?: string;
168
+ normalUrl?: string;
169
+ schemeUrl?: string;
170
+ authUrl?: string;
171
+ };
157
172
  paymentSessionFactor?: {
158
173
  extendInfo?: {
159
174
  merchantCapabilities?: string[];
@@ -214,6 +229,7 @@ export interface IpaymentSessionMetaData {
214
229
  */
215
230
  agreementDescription?: string;
216
231
  };
232
+ frontModulesToBeLoaded?: frontModulesToBeLoadedInterface[];
217
233
  };
218
234
  }
219
235
  export interface IPaymentSessionFactor {
@@ -22,6 +22,7 @@ export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
22
22
  componentSignEnum["CASHIER_PAYMENT_BANK"] = "CASHIER_PAYMENT_BANK";
23
23
  componentSignEnum["CASHIER_PAYMENT_APM"] = "CASHIER_PAYMENT_APM";
24
24
  componentSignEnum["AUTO_DEBIT_WALLET"] = "AUTO_DEBIT_WALLET";
25
+ componentSignEnum["AUTO_DEBIT_PAY_WALLET"] = "AUTO_DEBIT_PAY_WALLET";
25
26
  componentSignEnum["NONE"] = "NONE";
26
27
  componentSignEnum["VAULTING_CARD"] = "VAULTING_CARD";
27
28
  return componentSignEnum;
@@ -30,6 +31,7 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
30
31
  productSceneEnum["EASY_PAY"] = "EASY_PAY";
31
32
  productSceneEnum["CASHIER_PAYMENT"] = "CASHIER_PAYMENT";
32
33
  productSceneEnum["AUTO_DEBIT"] = "AUTO_DEBIT";
34
+ productSceneEnum["AUTO_DEBIT_PAY"] = "AUTO_DEBIT_PAY";
33
35
  productSceneEnum["VAULTING"] = "VAULTING";
34
36
  productSceneEnum["FLASH_BUY"] = "FLASH_BUY";
35
37
  productSceneEnum["CARD_APPLE_PAY"] = "CARD_APPLE_PAY";
@@ -39,4 +39,10 @@ declare const getOrSetStorageId: (key: string, value?: string) => string;
39
39
  declare const checkTimeElapsed: () => boolean;
40
40
  declare const isFunction: (func: any) => boolean;
41
41
  declare function parseBase64ToString(base64: string): string;
42
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, };
42
+ declare function loadSDKScript({ src, attrOptions, timeOut, loadCallback }: {
43
+ src: any;
44
+ attrOptions?: {};
45
+ timeOut?: number;
46
+ loadCallback?: any;
47
+ }, logger: any): Promise<unknown>;
48
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
package/esm/util/index.js CHANGED
@@ -261,4 +261,70 @@ function parseBase64ToString(base64) {
261
261
  return null;
262
262
  }
263
263
  }
264
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString };
264
+ function loadSDKScript(_ref, logger) {
265
+ var _this2 = this;
266
+ var src = _ref.src,
267
+ _ref$attrOptions = _ref.attrOptions,
268
+ attrOptions = _ref$attrOptions === void 0 ? {} : _ref$attrOptions,
269
+ _ref$timeOut = _ref.timeOut,
270
+ timeOut = _ref$timeOut === void 0 ? 3 : _ref$timeOut,
271
+ _ref$loadCallback = _ref.loadCallback,
272
+ loadCallback = _ref$loadCallback === void 0 ? null : _ref$loadCallback;
273
+ return new Promise(function (resolve, reject) {
274
+ // 创建 script 标签
275
+ logger.logInfo({
276
+ title: 'load_item_sdk_start'
277
+ }, {
278
+ src: src,
279
+ attrOptions: JSON.stringify(attrOptions)
280
+ });
281
+ console.time();
282
+ var script = document.createElement('script');
283
+ var timer = null;
284
+ script.type = 'text/javascript';
285
+
286
+ // 监听加载完成事件
287
+ script.onload = function () {
288
+ // 当脚本加载完毕时,执行回调函数
289
+ logger.logInfo({
290
+ title: 'load_item_sdk_end'
291
+ }, {
292
+ src: src,
293
+ attrOptions: JSON.stringify(attrOptions)
294
+ });
295
+ console.timeEnd();
296
+ clearTimeout(timer);
297
+ if (loadCallback) loadCallback();
298
+ resolve(true);
299
+ };
300
+
301
+ // 监听加载失败事件
302
+ script.onerror = function () {
303
+ logger.logError({
304
+ title: 'load_item_sdk_error'
305
+ }, {
306
+ src: src,
307
+ attrOptions: JSON.stringify(attrOptions)
308
+ });
309
+ clearTimeout(timer);
310
+ console.error('The script ' + src + ' is not accessible.');
311
+ reject(false);
312
+ };
313
+ timer = setTimeout(function () {
314
+ _this2.logger.logError({
315
+ title: 'load_item_sdk_timeout'
316
+ }, {
317
+ src: src,
318
+ attrOptions: JSON.stringify(attrOptions)
319
+ });
320
+ reject(false);
321
+ }, timeOut * 1000);
322
+ script.src = src;
323
+ attrOptions && Object.keys(attrOptions).forEach(function (key) {
324
+ script.setAttribute(key, attrOptions[key]);
325
+ });
326
+ // 将 script 标签添加到页面中
327
+ document.head.appendChild(script);
328
+ });
329
+ }
330
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
@@ -27,13 +27,13 @@ export declare function isGreyscaleMatch(item: UpgradeItem, randomGreyscale: num
27
27
  export declare const getMatchAppVersion: (_extendInfo: string, sdkInfo: UpgradeSdkInfo) => string;
28
28
  /**
29
29
  * 获取保存的加载版本
30
- * @param productScene
30
+ * @param versionKey
31
31
  * @returns
32
32
  */
33
- export declare const getLastAppVersion: (productScene: string) => string;
33
+ export declare const getLastAppVersion: (versionKey: string) => string;
34
34
  /**
35
35
  * 保存指定场景的加载版本供下次使用
36
- * @param productScene
36
+ * @param versionKey
37
37
  * @returns
38
38
  */
39
- export declare const setLastAppVersion: (productScene: string, appVersion: string) => boolean;
39
+ export declare const setLastAppVersion: (versionKey: string, appVersion: string) => boolean;
@@ -89,12 +89,12 @@ export var getMatchAppVersion = function getMatchAppVersion(_extendInfo, sdkInfo
89
89
 
90
90
  /**
91
91
  * 获取保存的加载版本
92
- * @param productScene
92
+ * @param versionKey
93
93
  * @returns
94
94
  */
95
- export var getLastAppVersion = function getLastAppVersion(productScene) {
95
+ export var getLastAppVersion = function getLastAppVersion(versionKey) {
96
96
  try {
97
- var key = "Antom_".concat(productScene, "_LastAppVersion");
97
+ var key = "Antom_".concat(versionKey, "_LastAppVersion");
98
98
  return getStorageString(key, '');
99
99
  } catch (error) {
100
100
  return '';
@@ -102,12 +102,12 @@ export var getLastAppVersion = function getLastAppVersion(productScene) {
102
102
  };
103
103
  /**
104
104
  * 保存指定场景的加载版本供下次使用
105
- * @param productScene
105
+ * @param versionKey
106
106
  * @returns
107
107
  */
108
- export var setLastAppVersion = function setLastAppVersion(productScene, appVersion) {
108
+ export var setLastAppVersion = function setLastAppVersion(versionKey, appVersion) {
109
109
  try {
110
- var key = "Antom_".concat(productScene, "_LastAppVersion");
110
+ var key = "Antom_".concat(versionKey, "_LastAppVersion");
111
111
  return setStorageString(key, appVersion);
112
112
  } catch (error) {
113
113
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "1.15.1",
3
+ "version": "1.18.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",