@alipay/ams-checkout 1.11.1 → 1.13.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.
@@ -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 { sdkVersion } from "../../config";
20
21
  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";
21
22
  import { queryPaymentInfo, submitPayInfo } from "../../service";
22
23
  import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
@@ -54,7 +55,7 @@ var ComponentApp = /*#__PURE__*/function () {
54
55
  _defineProperty(this, "_multipleCallbackEvents", void 0);
55
56
  _defineProperty(this, "_merchantAppointParam", void 0);
56
57
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
57
- this._appVersion = '1.11.1';
58
+ this._appVersion = '1.13.0';
58
59
  this._isInitComponent = false;
59
60
  this._selector = "#".concat(COMPONENT_SECTION_ID);
60
61
  this.createIframeNode = function () {
@@ -94,13 +95,14 @@ var ComponentApp = /*#__PURE__*/function () {
94
95
  }, {
95
96
  key: "initLoggerMeta",
96
97
  value: function initLoggerMeta() {
97
- var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2;
98
+ var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2, _this$_renderParams3;
98
99
  var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
99
100
  var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
100
101
  this.AMSSDK.logger.setMedta({
101
102
  platform: this.platform === platformEnum.desktop ? 'PC' : 'WAP',
102
103
  // PC/WAP,
103
- sdkVersion: this._appVersion,
104
+ sdkVersion: sdkVersion,
105
+ webAppVersion: this._appVersion,
104
106
  instanceId: this.AMSSDK._instanceId,
105
107
  storageId: this.AMSSDK._storageId,
106
108
  // the better way to use md5 paymentSesionID
@@ -110,9 +112,9 @@ var ComponentApp = /*#__PURE__*/function () {
110
112
  productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
111
113
  paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
112
114
  paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
113
- requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData
115
+ requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
116
+ trackId: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData
114
117
  });
115
- this.AMSSDK.logger.setComponentStartTime(Date.now());
116
118
  }
117
119
 
118
120
  /**
@@ -131,9 +133,9 @@ var ComponentApp = /*#__PURE__*/function () {
131
133
  }, {
132
134
  key: "initSecurity",
133
135
  value: function initSecurity() {
134
- var _this$_renderParams3,
136
+ var _this$_renderParams4,
135
137
  _this = this;
136
- var product = (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionMetaData) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionConfig) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.productScene;
138
+ var product = (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionConfig) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.productScene;
137
139
  if (componentSignEnum.CASHIER_PAYMENT_APM === this._componentSign) return;
138
140
  if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
139
141
  this.AMSSDK.logger.logInfo({
@@ -512,7 +514,8 @@ var ComponentApp = /*#__PURE__*/function () {
512
514
  _this5.AMSSDK.logger.logInfo({
513
515
  title: 'sdk_event_sdkQuery'
514
516
  }, {
515
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
517
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
518
+ requestBody: params
516
519
  }).send();
517
520
  queryPaymentInfo(params, {
518
521
  env: _this5.AMSSDK.options.env.environment,
@@ -523,6 +526,12 @@ var ComponentApp = /*#__PURE__*/function () {
523
526
  value: Date.now()
524
527
  });
525
528
  resolve(res);
529
+ _this5.AMSSDK.logger.logInfo({
530
+ title: 'sdk_event_sdkQueryEnd'
531
+ }, {
532
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
533
+ responseBody: res
534
+ }).send();
526
535
  }).catch(function (err) {
527
536
  if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD, componentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
528
537
  return resolve({
@@ -532,13 +541,13 @@ var ComponentApp = /*#__PURE__*/function () {
532
541
  _this5.dispatchToSDK(EVENT.error.name, {
533
542
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
534
543
  });
535
- reject(err);
536
- }).finally(function () {
537
- _this5.AMSSDK.logger.logInfo({
538
- title: 'sdk_event_sdkQueryEnd'
544
+ _this5.AMSSDK.logger.logError({
545
+ title: 'sdk_event_sdkQuery_failed'
539
546
  }, {
540
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
547
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
548
+ errorReason: err
541
549
  }).send();
550
+ reject(err);
542
551
  });
543
552
  case 49:
544
553
  case "end":
@@ -557,16 +566,16 @@ var ComponentApp = /*#__PURE__*/function () {
557
566
  }, {
558
567
  key: "createSubmitPromise",
559
568
  value: function createSubmitPromise() {
560
- var _this$_renderParams4,
561
- _this$_renderParams5,
569
+ var _this$_renderParams5,
570
+ _this$_renderParams6,
562
571
  _this6 = this;
563
572
  this._performanceData.push({
564
573
  key: 'sdk_submit_start',
565
574
  value: Date.now()
566
575
  });
567
576
  var params = {
568
- paymentSessionData: this._renderParams && ((_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.sessionData) || '',
569
- paymentSessionConfig: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 || (_this$_renderParams5 = _this$_renderParams5.paymentSessionMetaData) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.paymentSessionConfig
577
+ paymentSessionData: this._renderParams && ((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData) || '',
578
+ 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
570
579
  };
571
580
 
572
581
  // eslint-disable-next-line no-async-promise-executor
@@ -588,7 +597,8 @@ var ComponentApp = /*#__PURE__*/function () {
588
597
  _this6.AMSSDK.logger.logInfo({
589
598
  title: 'sdk_event_submitPay'
590
599
  }, {
591
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
600
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
601
+ requestBody: params
592
602
  }).send();
593
603
  _context3.t0 = submitPayInfo;
594
604
  _context3.t1 = params;
@@ -611,21 +621,23 @@ var ComponentApp = /*#__PURE__*/function () {
611
621
  key: 'sdk_submit_end',
612
622
  value: Date.now()
613
623
  });
614
- if (res !== null && res !== void 0 && res.success) {
615
- resolve(res);
616
- } else {
617
- resolve(res);
618
- }
619
- }).catch(function () {
620
- resolve({
621
- success: false
622
- });
623
- }).finally(function () {
624
624
  _this6.AMSSDK.logger.logInfo({
625
625
  title: 'sdk_event_submitPayEnd'
626
626
  }, {
627
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
627
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
628
+ responseBody: res
628
629
  }).send();
630
+ resolve(res);
631
+ }).catch(function (err) {
632
+ _this6.AMSSDK.logger.logError({
633
+ title: 'sdk_event_submitPay_failed'
634
+ }, {
635
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
636
+ responseBody: err
637
+ }).send();
638
+ resolve({
639
+ success: false
640
+ });
629
641
  });
630
642
  case 13:
631
643
  case "end":
@@ -681,6 +693,7 @@ var ComponentApp = /*#__PURE__*/function () {
681
693
  analytics: {
682
694
  enabled: false
683
695
  },
696
+ productScene: componentSign,
684
697
  productSceneVersion: productSceneVersion,
685
698
  environment: this.AMSSDK.options.env.environment,
686
699
  // TODO 确定一下这个参数是干啥的
@@ -688,7 +701,8 @@ var ComponentApp = /*#__PURE__*/function () {
688
701
  extendInfo: '',
689
702
  locale: '',
690
703
  instanceId: '',
691
- isPreload: 'true'
704
+ isPreload: 'true',
705
+ mid: ''
692
706
  }),
693
707
  path = _getIframeUrl.path,
694
708
  locationSearch = _getIframeUrl.locationSearch;
@@ -718,16 +732,20 @@ var ComponentApp = /*#__PURE__*/function () {
718
732
  value: Date.now()
719
733
  });
720
734
  try {
721
- var _renderParams$payment, _renderParams$payment2;
735
+ var _renderParams$payment, _renderParams$payment2, _renderParams$payment3, _renderParams$payment4;
722
736
  var productSceneVersion = (renderParams === null || renderParams === void 0 || (_renderParams$payment = renderParams.paymentSessionMetaData) === null || _renderParams$payment === void 0 || (_renderParams$payment = _renderParams$payment.paymentSessionConfig) === null || _renderParams$payment === void 0 ? void 0 : _renderParams$payment.productSceneVersion) || '';
723
- var extendInfo = (renderParams === null || renderParams === void 0 || (_renderParams$payment2 = renderParams.paymentSessionMetaData) === null || _renderParams$payment2 === void 0 ? void 0 : _renderParams$payment2.extendInfo) || '';
737
+ var productScene = (renderParams === null || renderParams === void 0 || (_renderParams$payment2 = renderParams.paymentSessionMetaData) === null || _renderParams$payment2 === void 0 || (_renderParams$payment2 = _renderParams$payment2.paymentSessionConfig) === null || _renderParams$payment2 === void 0 ? void 0 : _renderParams$payment2.productScene) || '';
738
+ var extendInfo = (renderParams === null || renderParams === void 0 || (_renderParams$payment3 = renderParams.paymentSessionMetaData) === null || _renderParams$payment3 === void 0 ? void 0 : _renderParams$payment3.extendInfo) || '';
739
+ var mid = renderParams === null || renderParams === void 0 || (_renderParams$payment4 = renderParams.paymentSessionMetaData) === null || _renderParams$payment4 === void 0 ? void 0 : _renderParams$payment4.clientId;
724
740
  var environment = this.AMSSDK.options.env.environment;
725
741
  this.appDomain = getAppDomain({
726
742
  environment: environment,
727
743
  appVersion: this._appVersion,
728
744
  componentSign: this._componentSign,
745
+ productScene: productScene,
729
746
  productSceneVersion: productSceneVersion,
730
- extendInfo: extendInfo
747
+ extendInfo: extendInfo,
748
+ mid: mid
731
749
  });
732
750
  this.app = createIframe(this.AMSSDK.options.mode, this.platform);
733
751
  var hostSign = ((renderParams === null || renderParams === void 0 ? void 0 : renderParams.sessionData) || '').split('&&')[1] || '';
@@ -735,13 +753,15 @@ var ComponentApp = /*#__PURE__*/function () {
735
753
  renderDisplayType: renderParams.renderDisplayType,
736
754
  componentSign: this._componentSign,
737
755
  analytics: this.AMSSDK.options.analytics,
756
+ productScene: productScene,
738
757
  productSceneVersion: productSceneVersion,
739
758
  environment: environment,
740
759
  appVersion: this._appVersion,
741
760
  extendInfo: extendInfo,
742
761
  locale: this.AMSSDK.options.locale,
743
762
  instanceId: this.AMSSDK._instanceId,
744
- hostSign: hostSign
763
+ hostSign: hostSign,
764
+ mid: mid
745
765
  }),
746
766
  path = _getIframeUrl2.path,
747
767
  locationSearch = _getIframeUrl2.locationSearch;
@@ -1376,7 +1396,7 @@ var ComponentApp = /*#__PURE__*/function () {
1376
1396
  key: "sendRenderEvent",
1377
1397
  value: (function () {
1378
1398
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1379
- var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
1399
+ var _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, _this$_renderParams11, _this$_renderParams12, _this$AMSSDK$logger, _this$_renderParams13, _this$_renderParams14, _this$_renderParams15, _this$AMSSDK, _this$_renderParams16, res, submitRes;
1380
1400
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1381
1401
  while (1) switch (_context8.prev = _context8.next) {
1382
1402
  case 0:
@@ -1405,17 +1425,29 @@ var ComponentApp = /*#__PURE__*/function () {
1405
1425
  data: {
1406
1426
  queryResult: res,
1407
1427
  submitResult: submitRes,
1408
- sessionResult: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionMetaData,
1409
- paymentSessionData: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData,
1428
+ sessionResult: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.paymentSessionMetaData,
1429
+ paymentSessionData: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.sessionData,
1410
1430
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
1411
- renderDisplayType: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.renderDisplayType,
1412
- appearance: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.appearance,
1413
- notRedirectAfterComplete: ((_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.notRedirectAfterComplete) === true,
1431
+ renderDisplayType: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.renderDisplayType,
1432
+ appearance: (_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.appearance,
1433
+ notRedirectAfterComplete: ((_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.notRedirectAfterComplete) === true,
1414
1434
  merchantAppointParam: this._merchantAppointParam,
1415
1435
  envInfo: {
1416
1436
  screenHeight: screen.height,
1417
1437
  screenWidth: screen.width
1418
- }
1438
+ },
1439
+ logMetaData: _objectSpread(_objectSpread({
1440
+ trackId: (_this$_renderParams12 = this._renderParams) === null || _this$_renderParams12 === void 0 ? void 0 : _this$_renderParams12.sessionData,
1441
+ platform: this.platform,
1442
+ firstLogTime: (_this$AMSSDK$logger = this.AMSSDK.logger) === null || _this$AMSSDK$logger === void 0 ? void 0 : _this$AMSSDK$logger.getComponentStartTime()
1443
+ }, ((_this$_renderParams13 = this._renderParams) === null || _this$_renderParams13 === void 0 || (_this$_renderParams13 = _this$_renderParams13.paymentSessionMetaData) === null || _this$_renderParams13 === void 0 ? void 0 : _this$_renderParams13.paymentSessionConfig) || {}), {}, {
1444
+ renderDisplayType: (_this$_renderParams14 = this._renderParams) === null || _this$_renderParams14 === void 0 ? void 0 : _this$_renderParams14.renderDisplayType,
1445
+ sdkVersion: this._appVersion,
1446
+ merchantId: (_this$_renderParams15 = this._renderParams) === null || _this$_renderParams15 === void 0 || (_this$_renderParams15 = _this$_renderParams15.paymentSessionMetaData) === null || _this$_renderParams15 === void 0 ? void 0 : _this$_renderParams15.clientId,
1447
+ instanceId: (_this$AMSSDK = this.AMSSDK) === null || _this$AMSSDK === void 0 ? void 0 : _this$AMSSDK._instanceId,
1448
+ performanceData: this._performanceData,
1449
+ paymentMethodType: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 || (_this$_renderParams16 = _this$_renderParams16.paymentSessionMetaData) === null || _this$_renderParams16 === void 0 || (_this$_renderParams16 = _this$_renderParams16.paymentMethodInfoView) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.paymentMethodType
1450
+ })
1419
1451
  }
1420
1452
  }
1421
1453
  }, null, true);
@@ -1,11 +1,11 @@
1
- import { ApplePayActionEnum, PaymentActionEnum } from "../core/bus/interface";
2
- import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from "../types/index";
1
+ import { ApplePayActionEnum, PaymentActionEnum, PaypalActionEnum } from "../core/bus/interface";
2
+ import { paymentMethodCategoryTypeEnum, PaypalMethodEnum, productSceneEnum, ProductSceneVersion } from "../types/index";
3
3
  export var ExtendPlugin = [{
4
4
  sessionMatcher: {
5
5
  productScene: productSceneEnum.CASHIER_PAYMENT,
6
6
  productSceneVersion: ProductSceneVersion.V1,
7
7
  paymentMethodCategoryType: paymentMethodCategoryTypeEnum.CARD,
8
- paymentMethodTypes: ["CARD_APPLE_PAY"]
8
+ paymentMethodTypes: ['CARD_APPLE_PAY']
9
9
  },
10
10
  paymentChannelMatcher: {
11
11
  paymentMethod: 'ApplePay'
@@ -14,6 +14,20 @@ export var ExtendPlugin = [{
14
14
  canMakePayments: ApplePayActionEnum.canMakePayments,
15
15
  optional_init: PaymentActionEnum.optional_init,
16
16
  createComponent: ApplePayActionEnum.createComponent,
17
- destoryComponent: ApplePayActionEnum.destoryComponent
17
+ destroyComponent: ApplePayActionEnum.destroyComponent
18
+ }
19
+ }, {
20
+ sessionMatcher: {
21
+ productScene: productSceneEnum.CASHIER_PAYMENT,
22
+ productSceneVersion: ProductSceneVersion.V1,
23
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum.APM,
24
+ paymentMethodTypes: [PaypalMethodEnum.PAYPAL_CHECKOUT, PaypalMethodEnum.PAYPAL_PAYLATER, PaypalMethodEnum.PAYPAL_VAULT]
25
+ },
26
+ paymentChannelMatcher: {
27
+ paymentMethod: 'Paypal'
28
+ },
29
+ busActionNames: {
30
+ mountComponent: PaypalActionEnum.mountComponent,
31
+ destroyComponent: PaypalActionEnum.destroyComponent
18
32
  }
19
33
  }];
@@ -0,0 +1,20 @@
1
+ import { BusContext, BusMessage, BusSubscriber } from '../../core/bus';
2
+ import { Logger } from '../../util/logger';
3
+ export declare class PaypalBusSubscriber extends BusSubscriber {
4
+ logger: Logger;
5
+ constructor(logger: Logger);
6
+ actionNames(): string[];
7
+ private onEventCallback;
8
+ protected renderPaypalButton(context: BusContext, message: BusMessage): Promise<never>;
9
+ private appendPaypalLoading;
10
+ private removePaypalLoading;
11
+ private preCheck;
12
+ private loadPaypalResource;
13
+ private createPaypalScript;
14
+ private onShippingChange;
15
+ private createOrder;
16
+ private onApprove;
17
+ private onCancel;
18
+ private destroyComponent;
19
+ onMessage(context: BusContext, message: BusMessage): void;
20
+ }