@alipay/ams-checkout 1.20.0 → 1.21.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.
Files changed (36) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +11 -0
  3. package/esm/config/index.js +20 -1
  4. package/esm/constant/index.d.ts +14 -1
  5. package/esm/constant/index.js +13 -0
  6. package/esm/core/component/address.d.ts +8 -0
  7. package/esm/core/component/address.js +72 -0
  8. package/esm/core/component/index.d.ts +5 -2
  9. package/esm/core/component/index.js +70 -56
  10. package/esm/core/instance/index.d.ts +2 -0
  11. package/esm/core/instance/index.js +65 -2
  12. package/esm/index.d.ts +9 -9
  13. package/esm/index.js +44 -8
  14. package/esm/plugin/applepay/component.js +1 -1
  15. package/esm/plugin/component/cashierApp.d.ts +3 -3
  16. package/esm/plugin/component/cashierApp.js +33 -3
  17. package/esm/plugin/component/channel.js +1 -0
  18. package/esm/plugin/component/component.inline.style.d.ts +8 -9
  19. package/esm/plugin/component/component.inline.style.js +87 -6
  20. package/esm/plugin/component/component.popup.style.d.ts +1 -0
  21. package/esm/plugin/component/component.popup.style.js +3 -0
  22. package/esm/plugin/component/index.d.ts +3 -1
  23. package/esm/plugin/component/index.js +143 -88
  24. package/esm/plugin/component/popupWindow.style.d.ts +5 -2
  25. package/esm/plugin/component/popupWindow.style.js +70 -14
  26. package/esm/plugin/payment-element/utils.d.ts +2 -0
  27. package/esm/plugin/payment-element/utils.js +6 -0
  28. package/esm/plugin/paypal/index.js +1 -0
  29. package/esm/plugin/type.d.ts +1 -0
  30. package/esm/types/index.d.ts +100 -4
  31. package/esm/types/index.js +14 -0
  32. package/esm/util/index.d.ts +2 -1
  33. package/esm/util/index.js +5 -0
  34. package/esm/util/security.d.ts +1 -0
  35. package/esm/util/security.js +1 -1
  36. package/package.json +1 -1
@@ -17,6 +17,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
18
18
  */
19
19
  /* eslint-disable @typescript-eslint/no-explicit-any */
20
+ import { v4 as uuid } from 'uuid';
20
21
  import { sdkVersion } from "../../config";
21
22
  import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../constant";
22
23
  import { queryPaymentInfo, submitPayInfo } from "../../service";
@@ -24,14 +25,15 @@ import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSce
24
25
  import { getType, isJsonString, isPC } from "../../util";
25
26
  import { isLocalMock } from "../../util/mock";
26
27
  import { matchVersion } from "../../util/versionCompare";
28
+ import { handlePaymentSessionConfig } from "../payment-element/utils";
27
29
  import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
28
30
  import { getChannelBehavior } from "./channel";
29
31
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
30
- import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
31
- import { createModal, destroyModal, insertStyleSheet } from "./popupWindow.style";
32
+ import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup, slideInAndOutKeyframes } from "./component.popup.style";
33
+ import { createModal, destroyModal, insertStyleSheet, removePopupLoading } from "./popupWindow.style";
32
34
  window.changingPageHeight = window.innerHeight;
33
35
  var ComponentApp = /*#__PURE__*/function () {
34
- function ComponentApp() {
36
+ function ComponentApp(componentOption) {
35
37
  _classCallCheck(this, ComponentApp);
36
38
  _defineProperty(this, "app", void 0);
37
39
  _defineProperty(this, "AMSSDK", void 0);
@@ -57,7 +59,7 @@ var ComponentApp = /*#__PURE__*/function () {
57
59
  _defineProperty(this, "_multipleCallbackEvents", void 0);
58
60
  _defineProperty(this, "_merchantAppointParam", void 0);
59
61
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
60
- this._appVersion = '1.19.0';
62
+ this._appVersion = componentOption.appVersion;
61
63
  this._isInitComponent = false;
62
64
  this._selector = "#".concat(COMPONENT_SECTION_ID);
63
65
  this.createIframeNode = function () {
@@ -258,12 +260,12 @@ var ComponentApp = /*#__PURE__*/function () {
258
260
  return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
259
261
  }
260
262
  renderParams = this.setParameterDefaultValues(componentSign, renderParams);
263
+ this._merchantAppointParam = renderParams.merchantAppointParam;
261
264
  this._isInitComponent = true;
262
265
  this._renderParams = renderParams;
263
266
  this._componentSign = componentSign;
264
267
  if ((_renderParams = renderParams) !== null && _renderParams !== void 0 && _renderParams.selector) this._selector = renderParams.selector;
265
268
  this._renderDisplayType = renderParams.renderDisplayType;
266
- this._merchantAppointParam = renderParams.merchantAppointParam;
267
269
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
268
270
  this.initLoggerMeta();
269
271
  this.initSecurity();
@@ -386,10 +388,22 @@ var ComponentApp = /*#__PURE__*/function () {
386
388
  }, {
387
389
  key: "renderInlineLoading",
388
390
  value: function renderInlineLoading(renderParams, selector) {
389
- var _renderParams$appeara;
391
+ var _renderParams$appeara, _this$_renderParams11;
390
392
  var showLoading = renderParams === null || renderParams === void 0 || (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
391
393
  showLoading = typeof showLoading === 'boolean' ? showLoading : true;
392
- if (showLoading) addInlineLoading(selector, this.platform);
394
+ var extendInfo = renderParams.paymentSessionMetaData.extendInfo;
395
+ var isExpressCheckout = false;
396
+ try {
397
+ // expressCheckout可能出现string(false) JSON.parse再转一次
398
+ isExpressCheckout = JSON.parse(JSON.parse(extendInfo).expressCheckout);
399
+ } catch (error) {
400
+ // 遇到JSON解析错误,默认false
401
+ }
402
+ if (showLoading) addInlineLoading(selector, this.platform, {
403
+ componentSign: this._componentSign,
404
+ type: (_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.appearance) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.layout) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.type,
405
+ isExpressCheckout: isExpressCheckout
406
+ });
393
407
  }
394
408
  }, {
395
409
  key: "renderPopupLoading",
@@ -426,9 +440,7 @@ var ComponentApp = /*#__PURE__*/function () {
426
440
  }, {
427
441
  key: "createActionQueryPromise",
428
442
  value: function createActionQueryPromise() {
429
- var _this$_renderParams11,
430
- _this5 = this;
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;
443
+ var _this5 = this;
432
444
  this._performanceData.push({
433
445
  key: 'sdk_action_query_start',
434
446
  value: Date.now()
@@ -437,7 +449,7 @@ var ComponentApp = /*#__PURE__*/function () {
437
449
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
438
450
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
439
451
  var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5, _this5$_renderParams6;
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;
452
+ var envInfo, params, _ref6, _ref6$extendInfo, extendInfo, actionData, enableVaultingApiOptimize, enableEasypayApiOptimize, _ref7, skipSdkQuery, skipSdkQueryForm, extendInfoData, ifSkip, channelBehavior, _this5$_renderParams7, _ref8, _ref8$productSceneVer, productSceneVersion, _ref8$productScene, productScene, _this5$_renderParams8, _action$web2, _action$wap2, action, signType;
441
453
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
442
454
  while (1) switch (_context2.prev = _context2.next) {
443
455
  case 0:
@@ -473,22 +485,35 @@ var ComponentApp = /*#__PURE__*/function () {
473
485
  success: true
474
486
  }));
475
487
  case 9:
488
+ if (componentSignEnum.ELEMENT_PAYMENT === _this5._componentSign) {
489
+ params.paymentSessionConfig = handlePaymentSessionConfig(params.paymentSessionConfig);
490
+ }
491
+ /** 地址组件跳过接口查询 */
492
+ if (!(componentSignEnum.ELEMENT_ADDRESS === _this5._componentSign)) {
493
+ _context2.next = 12;
494
+ break;
495
+ }
496
+ return _context2.abrupt("return", resolve({
497
+ message: 'sdk no need to make query request',
498
+ success: true
499
+ }));
500
+ case 12:
476
501
  if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
477
- _context2.next = 21;
502
+ _context2.next = 24;
478
503
  break;
479
504
  }
480
505
  if (!enableVaultingApiOptimize) {
481
- _context2.next = 21;
506
+ _context2.next = 24;
482
507
  break;
483
508
  }
484
509
  if (!skipSdkQueryForm) {
485
- _context2.next = 18;
510
+ _context2.next = 21;
486
511
  break;
487
512
  }
488
513
  // 优先判断 skipSdkQueryForm
489
514
  ifSkip = matchVersion(skipSdkQueryForm, _this5._appVersion);
490
515
  if (!ifSkip) {
491
- _context2.next = 16;
516
+ _context2.next = 19;
492
517
  break;
493
518
  }
494
519
  resolve({
@@ -496,12 +521,12 @@ var ComponentApp = /*#__PURE__*/function () {
496
521
  success: true
497
522
  });
498
523
  return _context2.abrupt("return");
499
- case 16:
500
- _context2.next = 21;
524
+ case 19:
525
+ _context2.next = 24;
501
526
  break;
502
- case 18:
527
+ case 21:
503
528
  if (!skipSdkQuery) {
504
- _context2.next = 21;
529
+ _context2.next = 24;
505
530
  break;
506
531
  }
507
532
  resolve({
@@ -509,10 +534,10 @@ var ComponentApp = /*#__PURE__*/function () {
509
534
  success: true
510
535
  });
511
536
  return _context2.abrupt("return");
512
- case 21:
537
+ case 24:
513
538
  channelBehavior = getChannelBehavior((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData); // Easypay TOSS 渠道无需actionQuery
514
539
  if (!(channelBehavior !== null && channelBehavior !== void 0 && channelBehavior.usePaymentSessionAsQueryResult)) {
515
- _context2.next = 24;
540
+ _context2.next = 27;
516
541
  break;
517
542
  }
518
543
  return _context2.abrupt("return", resolve({
@@ -520,79 +545,78 @@ var ComponentApp = /*#__PURE__*/function () {
520
545
  amountConfirmRequired: actionData === null || actionData === void 0 ? void 0 : actionData.amountConfirmRequired,
521
546
  success: true
522
547
  }));
523
- case 24:
548
+ case 27:
524
549
  if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
525
- _context2.next = 30;
550
+ _context2.next = 33;
526
551
  break;
527
552
  }
528
553
  params.paymentMethodType = 'CARD';
529
- _context2.next = 28;
554
+ _context2.next = 31;
530
555
  return _this5.getDeviceIdAndLog();
531
- case 28:
556
+ case 31:
532
557
  envInfo.deviceId = _context2.sent;
533
558
  if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
534
559
  envInfo.extendInfo = {
535
560
  WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
536
561
  };
537
562
  }
538
- case 30:
563
+ case 33:
539
564
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
540
- _context2.next = 40;
565
+ _context2.next = 42;
541
566
  break;
542
567
  }
543
568
  _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;
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)) {
546
- _context2.next = 35;
569
+ if (!((_this5$_renderParams7 = _this5._renderParams) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.action) !== null && _this5$_renderParams7 !== void 0 && _this5$_renderParams7.skipSdkQuery && enableEasypayApiOptimize)) {
570
+ _context2.next = 37;
547
571
  break;
548
572
  }
549
573
  return _context2.abrupt("return", resolve({
550
574
  message: 'sdk no need to make query request',
551
575
  success: true
552
576
  }));
553
- case 35:
577
+ case 37:
554
578
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0')) {
555
- _context2.next = 37;
579
+ _context2.next = 39;
556
580
  break;
557
581
  }
558
582
  return _context2.abrupt("return", resolve({
559
583
  message: 'sdk no need to make query request',
560
584
  success: true
561
585
  }));
562
- case 37:
563
- _context2.next = 39;
564
- return _this5.getDeviceIdAndLog();
565
586
  case 39:
587
+ _context2.next = 41;
588
+ return _this5.getDeviceIdAndLog();
589
+ case 41:
566
590
  envInfo.deviceId = _context2.sent;
567
- case 40:
591
+ case 42:
568
592
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
569
- _context2.next = 50;
593
+ _context2.next = 52;
570
594
  break;
571
595
  }
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) || {};
596
+ action = ((_this5$_renderParams8 = _this5._renderParams) === null || _this5$_renderParams8 === void 0 || (_this5$_renderParams8 = _this5$_renderParams8.paymentSessionMetaData) === null || _this5$_renderParams8 === void 0 ? void 0 : _this5$_renderParams8.action) || {};
573
597
  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;
574
598
  if (!(signType === 'SMS')) {
575
- _context2.next = 45;
599
+ _context2.next = 47;
576
600
  break;
577
601
  }
578
602
  return _context2.abrupt("return", resolve({
579
603
  message: 'sdk no need to make query request',
580
604
  success: true
581
605
  }));
582
- case 45:
606
+ case 47:
583
607
  if (!(!signType || signType !== 'REDIRECT')) {
584
- _context2.next = 47;
608
+ _context2.next = 49;
585
609
  break;
586
610
  }
587
611
  return _context2.abrupt("return", resolve({
588
612
  success: false
589
613
  }));
590
- case 47:
591
- _context2.next = 49;
592
- return _this5.getDeviceIdAndLog();
593
614
  case 49:
615
+ _context2.next = 51;
616
+ return _this5.getDeviceIdAndLog();
617
+ case 51:
594
618
  envInfo.deviceId = _context2.sent;
595
- case 50:
619
+ case 52:
596
620
  _this5.AMSSDK.logger.logInfo({
597
621
  title: 'sdk_event_sdkQuery'
598
622
  }, {
@@ -631,7 +655,7 @@ var ComponentApp = /*#__PURE__*/function () {
631
655
  }).send();
632
656
  reject(err);
633
657
  });
634
- case 52:
658
+ case 54:
635
659
  case "end":
636
660
  return _context2.stop();
637
661
  }
@@ -663,12 +687,21 @@ var ComponentApp = /*#__PURE__*/function () {
663
687
  var channelBehavior = getChannelBehavior((_this$_renderParams14 = this._renderParams) === null || _this$_renderParams14 === void 0 ? void 0 : _this$_renderParams14.paymentSessionMetaData);
664
688
  // eslint-disable-next-line no-async-promise-executor
665
689
  this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
666
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
690
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
667
691
  var _channelBehavior$buil, _this6$_renderParams$;
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;
692
+ var shouldSkipSubmitPayInSDK, _this6$_renderParams, _this6$_renderParams2, _ref10, _ref10$productSceneVe, productSceneVersion, _ref10$productScene, productScene, _ref11, _ref11$action, _ref11$action2, _ref11$action2$enable, enableSignAgreement, _ref11$action2$autoDe, autoDebitWithToken, extParams;
669
693
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
670
694
  while (1) switch (_context3.prev = _context3.next) {
671
695
  case 0:
696
+ if (!(_this6.AMSSDK.options.product === productSceneEnum.ELEMENT_ADDRESS)) {
697
+ _context3.next = 2;
698
+ break;
699
+ }
700
+ return _context3.abrupt("return", resolve({
701
+ message: 'sdk no need to make submitPay request',
702
+ success: true
703
+ }));
704
+ case 2:
672
705
  shouldSkipSubmitPayInSDK = false;
673
706
  if (channelBehavior) {
674
707
  // 新逻辑走 channelBehavior判断
@@ -677,8 +710,8 @@ var ComponentApp = /*#__PURE__*/function () {
677
710
  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;
678
711
  }
679
712
  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;
713
+ _ref10 = params.paymentSessionConfig || {}, _ref10$productSceneVe = _ref10.productSceneVersion, productSceneVersion = _ref10$productSceneVe === void 0 ? '' : _ref10$productSceneVe, _ref10$productScene = _ref10.productScene, productScene = _ref10$productScene === void 0 ? '' : _ref10$productScene;
714
+ _ref11 = ((_this6$_renderParams2 = _this6._renderParams) === null || _this6$_renderParams2 === void 0 ? void 0 : _this6$_renderParams2.paymentSessionMetaData) || {}, _ref11$action = _ref11.action, _ref11$action2 = _ref11$action === void 0 ? {} : _ref11$action, _ref11$action2$enable = _ref11$action2.enableSignAgreement, enableSignAgreement = _ref11$action2$enable === void 0 ? false : _ref11$action2$enable, _ref11$action2$autoDe = _ref11$action2.autoDebitWithToken, autoDebitWithToken = _ref11$action2$autoDe === void 0 ? false : _ref11$action2$autoDe;
682
715
  if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
683
716
  ///EasyPay 2.0 首次传signAgreement字段
684
717
  params['signAgreement'] = enableSignAgreement;
@@ -687,14 +720,14 @@ var ComponentApp = /*#__PURE__*/function () {
687
720
  // 带上标记告知WebCheckOut SDK已发送submitpay请求
688
721
  _this6._allowSubmitPayCallAhead = !shouldSkipSubmitPayInSDK;
689
722
  if (!shouldSkipSubmitPayInSDK) {
690
- _context3.next = 6;
723
+ _context3.next = 8;
691
724
  break;
692
725
  }
693
726
  return _context3.abrupt("return", resolve({
694
727
  message: 'sdk no need to make submitPay request',
695
728
  success: true
696
729
  }));
697
- case 6:
730
+ case 8:
698
731
  _this6.AMSSDK.logger.logInfo({
699
732
  title: 'sdk_event_submitPay'
700
733
  }, {
@@ -713,9 +746,9 @@ var ComponentApp = /*#__PURE__*/function () {
713
746
  _context3.t0 = submitPayInfo;
714
747
  _context3.t1 = params;
715
748
  _context3.t2 = _this6.AMSSDK.options.env.environment;
716
- _context3.next = 14;
749
+ _context3.next = 16;
717
750
  return _this6.getDeviceIdAndLog();
718
- case 14:
751
+ case 16:
719
752
  _context3.t3 = _context3.sent;
720
753
  _context3.t4 = {
721
754
  deviceId: _context3.t3
@@ -749,14 +782,14 @@ var ComponentApp = /*#__PURE__*/function () {
749
782
  success: false
750
783
  });
751
784
  });
752
- case 19:
785
+ case 21:
753
786
  case "end":
754
787
  return _context3.stop();
755
788
  }
756
789
  }, _callee3);
757
790
  }));
758
791
  return function (_x3) {
759
- return _ref10.apply(this, arguments);
792
+ return _ref9.apply(this, arguments);
760
793
  };
761
794
  }());
762
795
  }
@@ -797,19 +830,17 @@ var ComponentApp = /*#__PURE__*/function () {
797
830
  value: function createPreloadApp(componentSign) {
798
831
  var productSceneVersion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.0';
799
832
  var preloadIframe = createPreloadIframe(componentSign, productSceneVersion);
833
+ var productScene = componentSign.split(/_(?=[^_]*$)/)[0];
800
834
  var _getIframeUrl = getIframeUrl({
801
835
  renderDisplayType: renderDisplayTypeEnum.popup,
802
836
  componentSign: componentSign,
803
837
  analytics: {
804
838
  enabled: false
805
839
  },
806
- productScene: componentSign,
840
+ productScene: productScene,
807
841
  productSceneVersion: productSceneVersion,
808
842
  environment: this.AMSSDK.options.env.environment,
809
- // TODO 确定一下这个参数是干啥的
810
843
  appVersion: this._appVersion,
811
- extendInfo: '',
812
- locale: '',
813
844
  instanceId: '',
814
845
  isPreload: 'true',
815
846
  mid: ''
@@ -933,7 +964,7 @@ var ComponentApp = /*#__PURE__*/function () {
933
964
  key: "createDialog",
934
965
  value: function () {
935
966
  var _createDialog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
936
- var pageUrl, isLoad, timeout, logTimeout;
967
+ var pageUrl, _data$device, isLoad, timeout, logTimeout;
937
968
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
938
969
  while (1) switch (_context4.prev = _context4.next) {
939
970
  case 0:
@@ -943,8 +974,8 @@ var ComponentApp = /*#__PURE__*/function () {
943
974
  _context4.next = 5;
944
975
  return createModal({
945
976
  widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
946
- heightPadding: data === null || data === void 0 ? void 0 : data.heightPadding,
947
- device: this.platform,
977
+ device: (_data$device = data === null || data === void 0 ? void 0 : data.device) !== null && _data$device !== void 0 ? _data$device : this.platform,
978
+ loadingConfig: data === null || data === void 0 ? void 0 : data.loadingConfig,
948
979
  url: pageUrl
949
980
  });
950
981
  case 5:
@@ -963,6 +994,7 @@ var ComponentApp = /*#__PURE__*/function () {
963
994
  }, POPUP_LOADTIME_LOG_LIMIT);
964
995
  this.popupApp.onload = function () {
965
996
  isLoad = true;
997
+ removePopupLoading();
966
998
  clearTimeout(timeout);
967
999
  clearTimeout(logTimeout);
968
1000
  };
@@ -1212,6 +1244,25 @@ var ComponentApp = /*#__PURE__*/function () {
1212
1244
  this.handleAppHeartBeat();
1213
1245
  return;
1214
1246
  }
1247
+ if (data.context.event === EVENT.beforeSubmit.name) {
1248
+ var _this$AMSSDK$_eventCe;
1249
+ if ((_this$AMSSDK$_eventCe = this.AMSSDK._eventCenter) !== null && _this$AMSSDK$_eventCe !== void 0 && _this$AMSSDK$_eventCe.isExist(EVENT.beforeSubmit.name)) {
1250
+ this.AMSSDK._eventCenter.emit(EVENT.beforeSubmit.name, data.context.data);
1251
+ return;
1252
+ }
1253
+ // 不存在事件,默认通过
1254
+ var eventCallbackId = uuid();
1255
+ this.dispatchToApp({
1256
+ context: {
1257
+ event: EVENT.beforeSubmitDone.name,
1258
+ eventCallbackId: eventCallbackId,
1259
+ data: {
1260
+ result: 'IGNORE'
1261
+ }
1262
+ }
1263
+ });
1264
+ return;
1265
+ }
1215
1266
  if (data.context.event === EVENT.eventCallback.name) {
1216
1267
  this.AMSSDK.logger.logInfo({
1217
1268
  title: 'sdk_event_event_callback'
@@ -1255,9 +1306,8 @@ var ComponentApp = /*#__PURE__*/function () {
1255
1306
 
1256
1307
  // 此style用于弹窗出现和高度变化时动画,动画不同,属性不同
1257
1308
  this.app.style.height = parseInt(this.app.style.height) > 0 ? '100%' : "".concat(data.context.data.height, "px");
1258
-
1259
1309
  // 弹出和弹入动画
1260
- var runkeyframes = "@keyframes ".concat(COMPONENT_CONTAINER_ID, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(data.context.data.height, "px;\n }\n }\n @keyframes ").concat(COMPONENT_CONTAINER_ID, "-slide-out {\n 0% {\n height: ").concat(data.context.data.height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
1310
+ var runkeyframes = slideInAndOutKeyframes(COMPONENT_CONTAINER_ID, data.context.data.height);
1261
1311
  // 创建style标签
1262
1312
  var style = document.createElement('style');
1263
1313
  style.id = animationStyleId;
@@ -1267,7 +1317,6 @@ var ComponentApp = /*#__PURE__*/function () {
1267
1317
  style.innerHTML = runkeyframes;
1268
1318
  // 将style样式存放到head标签
1269
1319
  document.getElementsByTagName('head')[0].appendChild(style);
1270
-
1271
1320
  // size变动时动画
1272
1321
  setTimeout(function () {
1273
1322
  cashier.style.transition = 'height 0.28s ease-in-out';
@@ -1387,9 +1436,9 @@ var ComponentApp = /*#__PURE__*/function () {
1387
1436
  }
1388
1437
  }, {
1389
1438
  key: "handleDeclareInfo",
1390
- value: function handleDeclareInfo(_ref13) {
1391
- var _ref13$closeDialogDat = _ref13.closeDialogData,
1392
- closeDialogData = _ref13$closeDialogDat === void 0 ? {} : _ref13$closeDialogDat;
1439
+ value: function handleDeclareInfo(_ref12) {
1440
+ var _ref12$closeDialogDat = _ref12.closeDialogData,
1441
+ closeDialogData = _ref12$closeDialogDat === void 0 ? {} : _ref12$closeDialogDat;
1393
1442
  _handleDeclareInfo({
1394
1443
  closeDialogData: closeDialogData
1395
1444
  });
@@ -1530,24 +1579,25 @@ var ComponentApp = /*#__PURE__*/function () {
1530
1579
  key: "sendRenderEvent",
1531
1580
  value: (function () {
1532
1581
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
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;
1582
+ var _this$_renderParams15, _this$_renderParams16, _this$_renderParams17, _this$_renderParams18, _this$_renderParams19, _this$_renderParams20, _this$_renderParams21, _this$_renderParams22, _this$_renderParams23, _this$AMSSDK$logger, _this$_renderParams24, _this$_renderParams25, _this$_renderParams26, _this$AMSSDK, _this$_renderParams27, isAddressElement, res, submitRes;
1534
1583
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1535
1584
  while (1) switch (_context8.prev = _context8.next) {
1536
1585
  case 0:
1537
1586
  _context8.prev = 0;
1538
- if (!(!this._actionQueryPromise || !this._actionSubmitPromise)) {
1539
- _context8.next = 3;
1587
+ isAddressElement = this.AMSSDK.options.product === productSceneEnum.ELEMENT_ADDRESS;
1588
+ if (!((!this._actionQueryPromise || !this._actionSubmitPromise) && !isAddressElement)) {
1589
+ _context8.next = 4;
1540
1590
  break;
1541
1591
  }
1542
1592
  return _context8.abrupt("return");
1543
- case 3:
1544
- _context8.next = 5;
1593
+ case 4:
1594
+ _context8.next = 6;
1545
1595
  return this._actionQueryPromise;
1546
- case 5:
1596
+ case 6:
1547
1597
  res = _context8.sent;
1548
- _context8.next = 8;
1598
+ _context8.next = 9;
1549
1599
  return this._actionSubmitPromise;
1550
- case 8:
1600
+ case 9:
1551
1601
  submitRes = _context8.sent;
1552
1602
  this._performanceData.push({
1553
1603
  key: 'sdk_render_component',
@@ -1567,21 +1617,25 @@ var ComponentApp = /*#__PURE__*/function () {
1567
1617
  notRedirectAfterComplete: ((_this$_renderParams19 = this._renderParams) === null || _this$_renderParams19 === void 0 ? void 0 : _this$_renderParams19.notRedirectAfterComplete) === true,
1568
1618
  merchantAppointParam: this._merchantAppointParam,
1569
1619
  allowSubmitPayCallAhead: this._allowSubmitPayCallAhead,
1620
+ /** 地址组件集成的参数 */
1621
+ configParams: (_this$_renderParams20 = this._renderParams) === null || _this$_renderParams20 === void 0 ? void 0 : _this$_renderParams20.configParams,
1622
+ prefillValue: (_this$_renderParams21 = this._renderParams) === null || _this$_renderParams21 === void 0 ? void 0 : _this$_renderParams21.prefillValue,
1623
+ componentSession: (_this$_renderParams22 = this._renderParams) === null || _this$_renderParams22 === void 0 ? void 0 : _this$_renderParams22.componentSession,
1570
1624
  envInfo: {
1571
1625
  screenHeight: screen.height,
1572
1626
  screenWidth: screen.width
1573
1627
  },
1574
1628
  logMetaData: _objectSpread(_objectSpread({
1575
- trackId: (_this$_renderParams20 = this._renderParams) === null || _this$_renderParams20 === void 0 ? void 0 : _this$_renderParams20.sessionData,
1629
+ trackId: (_this$_renderParams23 = this._renderParams) === null || _this$_renderParams23 === void 0 ? void 0 : _this$_renderParams23.sessionData,
1576
1630
  platform: this.platform,
1577
1631
  firstLogTime: (_this$AMSSDK$logger = this.AMSSDK.logger) === null || _this$AMSSDK$logger === void 0 ? void 0 : _this$AMSSDK$logger.getComponentStartTime()
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,
1632
+ }, ((_this$_renderParams24 = this._renderParams) === null || _this$_renderParams24 === void 0 || (_this$_renderParams24 = _this$_renderParams24.paymentSessionMetaData) === null || _this$_renderParams24 === void 0 ? void 0 : _this$_renderParams24.paymentSessionConfig) || {}), {}, {
1633
+ renderDisplayType: (_this$_renderParams25 = this._renderParams) === null || _this$_renderParams25 === void 0 ? void 0 : _this$_renderParams25.renderDisplayType,
1580
1634
  sdkVersion: this._appVersion,
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,
1635
+ merchantId: (_this$_renderParams26 = this._renderParams) === null || _this$_renderParams26 === void 0 || (_this$_renderParams26 = _this$_renderParams26.paymentSessionMetaData) === null || _this$_renderParams26 === void 0 ? void 0 : _this$_renderParams26.clientId,
1582
1636
  instanceId: (_this$AMSSDK = this.AMSSDK) === null || _this$AMSSDK === void 0 ? void 0 : _this$AMSSDK._instanceId,
1583
1637
  performanceData: this._performanceData,
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
1638
+ paymentMethodType: (_this$_renderParams27 = this._renderParams) === null || _this$_renderParams27 === void 0 || (_this$_renderParams27 = _this$_renderParams27.paymentSessionMetaData) === null || _this$_renderParams27 === void 0 || (_this$_renderParams27 = _this$_renderParams27.paymentMethodInfoView) === null || _this$_renderParams27 === void 0 ? void 0 : _this$_renderParams27.paymentMethodType
1585
1639
  })
1586
1640
  }
1587
1641
  }
@@ -1598,16 +1652,16 @@ var ComponentApp = /*#__PURE__*/function () {
1598
1652
  }
1599
1653
  });
1600
1654
  // eslint-disable-next-line no-empty
1601
- _context8.next = 17;
1655
+ _context8.next = 18;
1602
1656
  break;
1603
- case 15:
1604
- _context8.prev = 15;
1657
+ case 16:
1658
+ _context8.prev = 16;
1605
1659
  _context8.t0 = _context8["catch"](0);
1606
- case 17:
1660
+ case 18:
1607
1661
  case "end":
1608
1662
  return _context8.stop();
1609
1663
  }
1610
- }, _callee8, this, [[0, 15]]);
1664
+ }, _callee8, this, [[0, 16]]);
1611
1665
  }));
1612
1666
  function sendRenderEvent() {
1613
1667
  return _sendRenderEvent.apply(this, arguments);
@@ -1641,8 +1695,9 @@ var ComponentApp = /*#__PURE__*/function () {
1641
1695
  }, {
1642
1696
  key: "hideComponentAnimation",
1643
1697
  value: function hideComponentAnimation() {
1698
+ var _container$style;
1644
1699
  var container = document.getElementById(COMPONENT_CONTAINER_ID);
1645
- if (this.app) this.app.style.height = container.style.height;
1700
+ if (this.app) this.app.style.height = container === null || container === void 0 || (_container$style = container.style) === null || _container$style === void 0 ? void 0 : _container$style.height;
1646
1701
  if (container) {
1647
1702
  // size变化动画取消
1648
1703
  container.style.transition = '';
@@ -1,8 +1,11 @@
1
+ export declare const createCustomSheet: (curTheme?: 'dark' | 'light') => void;
2
+ export declare const renderPopupLoading: (container: HTMLDivElement, curTheme: 'dark' | 'light') => void;
3
+ export declare const removePopupLoading: (isShowMockup?: boolean) => void;
1
4
  export declare const insertStyleSheet: () => void;
2
- export declare const createModal: ({ device, url, widthPadding, heightPadding }: {
5
+ export declare const createModal: ({ device, url, widthPadding, loadingConfig }: {
3
6
  device: any;
4
7
  url: any;
5
8
  widthPadding: any;
6
- heightPadding: any;
9
+ loadingConfig: any;
7
10
  }) => Promise<HTMLIFrameElement>;
8
11
  export declare const destroyModal: () => void;