@alipay/ams-checkout 0.0.1713146800-dev.0 → 0.0.1713838058-dev.1

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 (40) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/request.js +3 -3
  3. package/esm/core/bus/index.d.ts +1 -1
  4. package/esm/core/bus/interface.d.ts +5 -1
  5. package/esm/core/bus/interface.js +6 -1
  6. package/esm/core/component/index.d.ts +1 -0
  7. package/esm/core/component/index.js +14 -6
  8. package/esm/core/instance/index.d.ts +8 -1
  9. package/esm/core/instance/index.js +22 -14
  10. package/esm/plugin/applepay/component.d.ts +1 -1
  11. package/esm/plugin/applepay/component.js +5 -5
  12. package/esm/plugin/applepay/index.d.ts +1 -1
  13. package/esm/plugin/applepay/index.js +6 -6
  14. package/esm/plugin/component/cashierApp.d.ts +6 -2
  15. package/esm/plugin/component/cashierApp.js +68 -12
  16. package/esm/plugin/component/component.popup.style.js +1 -1
  17. package/esm/plugin/component/index.d.ts +1 -2
  18. package/esm/plugin/component/index.js +153 -89
  19. package/esm/plugin/const.js +18 -4
  20. package/esm/plugin/paypal/index.d.ts +20 -0
  21. package/esm/plugin/paypal/index.js +389 -0
  22. package/esm/plugin/type.d.ts +2 -2
  23. package/esm/plugin/utils.d.ts +6 -0
  24. package/esm/plugin/utils.js +21 -0
  25. package/esm/request/index.js +8 -14
  26. package/esm/types/index.d.ts +58 -3
  27. package/esm/types/index.js +18 -0
  28. package/esm/util/debug.d.ts +1 -0
  29. package/esm/util/debug.js +9 -0
  30. package/esm/util/index.d.ts +2 -1
  31. package/esm/util/index.js +4 -2
  32. package/esm/util/logger.d.ts +8 -0
  33. package/esm/util/logger.js +34 -3
  34. package/esm/util/storage.d.ts +2 -0
  35. package/esm/util/storage.js +23 -0
  36. package/esm/util/upgrade.d.ts +39 -0
  37. package/esm/util/upgrade.js +115 -0
  38. package/esm/util/versionCompare.d.ts +10 -1
  39. package/esm/util/versionCompare.js +97 -0
  40. package/package.json +1 -1
@@ -17,11 +17,13 @@ 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";
23
24
  import { getType, isJsonString, isPC } from "../../util";
24
25
  import { isLocalMock } from "../../util/mock";
26
+ import { matchVersion } from "../../util/versionCompare";
25
27
  import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
28
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
27
29
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
@@ -52,9 +54,8 @@ var ComponentApp = /*#__PURE__*/function () {
52
54
  _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
53
55
  _defineProperty(this, "_multipleCallbackEvents", void 0);
54
56
  _defineProperty(this, "_merchantAppointParam", void 0);
55
- _defineProperty(this, "_webAppHeartBeatTimeoutId", void 0);
56
57
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
57
- this._appVersion = '1.11.0';
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({
@@ -364,7 +366,7 @@ var ComponentApp = /*#__PURE__*/function () {
364
366
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
365
367
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
366
368
  var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
367
- var envInfo, params, _ref3, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref4, _ref4$productSceneVer, productSceneVersion, _ref4$productScene, productScene, _ref5, _ref5$action, _ref5$action2, _ref5$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
369
+ var envInfo, params, _ref3, _ref3$extendInfo, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, _ref4, skipSdkQuery, skipSdkQueryForm, extendInfoData, ifSkip, _this5$_renderParams6, _this5$_renderParams7, _ref5, _ref5$productSceneVer, productSceneVersion, _ref5$productScene, productScene, _ref6, _ref6$action, _ref6$action2, _ref6$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
368
370
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
369
371
  while (1) switch (_context2.prev = _context2.next) {
370
372
  case 0:
@@ -380,9 +382,10 @@ var ComponentApp = /*#__PURE__*/function () {
380
382
  /**
381
383
  * @description Simulated or unnecessary scenarios
382
384
  */
383
- _ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, extendInfo = _ref3.extendInfo;
385
+ _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;
384
386
  enableVaultingApiOptimize = false;
385
387
  enableEasypayApiOptimize = false;
388
+ _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;
386
389
  try {
387
390
  extendInfoData = JSON.parse(extendInfo);
388
391
  enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
@@ -391,99 +394,128 @@ var ComponentApp = /*#__PURE__*/function () {
391
394
  console.log(error);
392
395
  }
393
396
  if (!isLocalMock()) {
394
- _context2.next = 8;
397
+ _context2.next = 9;
395
398
  break;
396
399
  }
397
400
  return _context2.abrupt("return", resolve({
398
401
  message: 'sdk no need to make query request',
399
402
  success: true
400
403
  }));
401
- case 8:
402
- if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign && (_this5$_renderParams5 = _this5._renderParams) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.action) !== null && _this5$_renderParams5 !== void 0 && _this5$_renderParams5.skipSdkQuery && enableVaultingApiOptimize)) {
403
- _context2.next = 10;
404
+ case 9:
405
+ if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
406
+ _context2.next = 21;
404
407
  break;
405
408
  }
406
- return _context2.abrupt("return", resolve({
409
+ if (!enableVaultingApiOptimize) {
410
+ _context2.next = 21;
411
+ break;
412
+ }
413
+ if (!skipSdkQueryForm) {
414
+ _context2.next = 18;
415
+ break;
416
+ }
417
+ // 优先判断 skipSdkQueryForm
418
+ ifSkip = matchVersion(skipSdkQueryForm, _this5._appVersion);
419
+ if (!ifSkip) {
420
+ _context2.next = 16;
421
+ break;
422
+ }
423
+ resolve({
407
424
  message: 'sdk no need to make query request',
408
425
  success: true
409
- }));
410
- case 10:
426
+ });
427
+ return _context2.abrupt("return");
428
+ case 16:
429
+ _context2.next = 21;
430
+ break;
431
+ case 18:
432
+ if (!skipSdkQuery) {
433
+ _context2.next = 21;
434
+ break;
435
+ }
436
+ resolve({
437
+ message: 'sdk no need to make query request',
438
+ success: true
439
+ });
440
+ return _context2.abrupt("return");
441
+ case 21:
411
442
  if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
412
- _context2.next = 16;
443
+ _context2.next = 27;
413
444
  break;
414
445
  }
415
446
  params.paymentMethodType = 'CARD';
416
- _context2.next = 14;
447
+ _context2.next = 25;
417
448
  return _this5.getDeviceIdAndLog();
418
- case 14:
449
+ case 25:
419
450
  envInfo.deviceId = _context2.sent;
420
451
  if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
421
452
  envInfo.extendInfo = {
422
453
  WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
423
454
  };
424
455
  }
425
- case 16:
456
+ case 27:
426
457
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
427
- _context2.next = 26;
458
+ _context2.next = 37;
428
459
  break;
429
460
  }
430
- _ref4 = params.paymentSessionConfig || {}, _ref4$productSceneVer = _ref4.productSceneVersion, productSceneVersion = _ref4$productSceneVer === void 0 ? '' : _ref4$productSceneVer, _ref4$productScene = _ref4.productScene, productScene = _ref4$productScene === void 0 ? '' : _ref4$productScene;
431
- _ref5 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref5$action = _ref5.action, _ref5$action2 = _ref5$action === void 0 ? {} : _ref5$action, _ref5$action2$autoDeb = _ref5$action2.autoDebitWithToken, autoDebitWithToken = _ref5$action2$autoDeb === void 0 ? false : _ref5$action2$autoDeb;
461
+ _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;
462
+ _ref6 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.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;
432
463
  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)) {
433
- _context2.next = 21;
464
+ _context2.next = 32;
434
465
  break;
435
466
  }
436
467
  return _context2.abrupt("return", resolve({
437
468
  message: 'sdk no need to make query request',
438
469
  success: true
439
470
  }));
440
- case 21:
471
+ case 32:
441
472
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
442
- _context2.next = 23;
473
+ _context2.next = 34;
443
474
  break;
444
475
  }
445
476
  return _context2.abrupt("return", resolve({
446
477
  message: 'sdk no need to make query request',
447
478
  success: true
448
479
  }));
449
- case 23:
450
- _context2.next = 25;
480
+ case 34:
481
+ _context2.next = 36;
451
482
  return _this5.getDeviceIdAndLog();
452
- case 25:
483
+ case 36:
453
484
  envInfo.deviceId = _context2.sent;
454
- case 26:
485
+ case 37:
455
486
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
456
- _context2.next = 36;
487
+ _context2.next = 47;
457
488
  break;
458
489
  }
459
490
  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) || {};
460
491
  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;
461
492
  if (!(signType === 'SMS')) {
462
- _context2.next = 31;
493
+ _context2.next = 42;
463
494
  break;
464
495
  }
465
496
  return _context2.abrupt("return", resolve({
466
497
  message: 'sdk no need to make query request',
467
498
  success: true
468
499
  }));
469
- case 31:
500
+ case 42:
470
501
  if (!(!signType || signType !== 'REDIRECT')) {
471
- _context2.next = 33;
502
+ _context2.next = 44;
472
503
  break;
473
504
  }
474
505
  return _context2.abrupt("return", resolve({
475
506
  success: false
476
507
  }));
477
- case 33:
478
- _context2.next = 35;
508
+ case 44:
509
+ _context2.next = 46;
479
510
  return _this5.getDeviceIdAndLog();
480
- case 35:
511
+ case 46:
481
512
  envInfo.deviceId = _context2.sent;
482
- case 36:
513
+ case 47:
483
514
  _this5.AMSSDK.logger.logInfo({
484
515
  title: 'sdk_event_sdkQuery'
485
516
  }, {
486
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
517
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
518
+ requestBody: params
487
519
  }).send();
488
520
  queryPaymentInfo(params, {
489
521
  env: _this5.AMSSDK.options.env.environment,
@@ -494,6 +526,12 @@ var ComponentApp = /*#__PURE__*/function () {
494
526
  value: Date.now()
495
527
  });
496
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();
497
535
  }).catch(function (err) {
498
536
  if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD, componentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
499
537
  return resolve({
@@ -503,15 +541,15 @@ var ComponentApp = /*#__PURE__*/function () {
503
541
  _this5.dispatchToSDK(EVENT.error.name, {
504
542
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
505
543
  });
506
- reject(err);
507
- }).finally(function () {
508
- _this5.AMSSDK.logger.logInfo({
509
- title: 'sdk_event_sdkQueryEnd'
544
+ _this5.AMSSDK.logger.logError({
545
+ title: 'sdk_event_sdkQuery_failed'
510
546
  }, {
511
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
547
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
548
+ errorReason: err
512
549
  }).send();
550
+ reject(err);
513
551
  });
514
- case 38:
552
+ case 49:
515
553
  case "end":
516
554
  return _context2.stop();
517
555
  }
@@ -528,21 +566,21 @@ var ComponentApp = /*#__PURE__*/function () {
528
566
  }, {
529
567
  key: "createSubmitPromise",
530
568
  value: function createSubmitPromise() {
531
- var _this$_renderParams4,
532
- _this$_renderParams5,
569
+ var _this$_renderParams5,
570
+ _this$_renderParams6,
533
571
  _this6 = this;
534
572
  this._performanceData.push({
535
573
  key: 'sdk_submit_start',
536
574
  value: Date.now()
537
575
  });
538
576
  var params = {
539
- paymentSessionData: this._renderParams && ((_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.sessionData) || '',
540
- 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
541
579
  };
542
580
 
543
581
  // eslint-disable-next-line no-async-promise-executor
544
582
  this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
545
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
583
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
546
584
  var _this6$_renderParams;
547
585
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
548
586
  while (1) switch (_context3.prev = _context3.next) {
@@ -559,7 +597,8 @@ var ComponentApp = /*#__PURE__*/function () {
559
597
  _this6.AMSSDK.logger.logInfo({
560
598
  title: 'sdk_event_submitPay'
561
599
  }, {
562
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
600
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
601
+ requestBody: params
563
602
  }).send();
564
603
  _context3.t0 = submitPayInfo;
565
604
  _context3.t1 = params;
@@ -582,21 +621,23 @@ var ComponentApp = /*#__PURE__*/function () {
582
621
  key: 'sdk_submit_end',
583
622
  value: Date.now()
584
623
  });
585
- if (res !== null && res !== void 0 && res.success) {
586
- resolve(res);
587
- } else {
588
- resolve(res);
589
- }
590
- }).catch(function () {
591
- resolve({
592
- success: false
593
- });
594
- }).finally(function () {
595
624
  _this6.AMSSDK.logger.logInfo({
596
625
  title: 'sdk_event_submitPayEnd'
597
626
  }, {
598
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
627
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
628
+ responseBody: res
599
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
+ });
600
641
  });
601
642
  case 13:
602
643
  case "end":
@@ -605,7 +646,7 @@ var ComponentApp = /*#__PURE__*/function () {
605
646
  }, _callee3);
606
647
  }));
607
648
  return function (_x3) {
608
- return _ref6.apply(this, arguments);
649
+ return _ref7.apply(this, arguments);
609
650
  };
610
651
  }());
611
652
  }
@@ -652,6 +693,7 @@ var ComponentApp = /*#__PURE__*/function () {
652
693
  analytics: {
653
694
  enabled: false
654
695
  },
696
+ productScene: componentSign,
655
697
  productSceneVersion: productSceneVersion,
656
698
  environment: this.AMSSDK.options.env.environment,
657
699
  // TODO 确定一下这个参数是干啥的
@@ -659,7 +701,8 @@ var ComponentApp = /*#__PURE__*/function () {
659
701
  extendInfo: '',
660
702
  locale: '',
661
703
  instanceId: '',
662
- isPreload: 'true'
704
+ isPreload: 'true',
705
+ mid: ''
663
706
  }),
664
707
  path = _getIframeUrl.path,
665
708
  locationSearch = _getIframeUrl.locationSearch;
@@ -689,16 +732,20 @@ var ComponentApp = /*#__PURE__*/function () {
689
732
  value: Date.now()
690
733
  });
691
734
  try {
692
- var _renderParams$payment, _renderParams$payment2;
735
+ var _renderParams$payment, _renderParams$payment2, _renderParams$payment3, _renderParams$payment4;
693
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) || '';
694
- 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;
695
740
  var environment = this.AMSSDK.options.env.environment;
696
741
  this.appDomain = getAppDomain({
697
742
  environment: environment,
698
743
  appVersion: this._appVersion,
699
744
  componentSign: this._componentSign,
745
+ productScene: productScene,
700
746
  productSceneVersion: productSceneVersion,
701
- extendInfo: extendInfo
747
+ extendInfo: extendInfo,
748
+ mid: mid
702
749
  });
703
750
  this.app = createIframe(this.AMSSDK.options.mode, this.platform);
704
751
  var hostSign = ((renderParams === null || renderParams === void 0 ? void 0 : renderParams.sessionData) || '').split('&&')[1] || '';
@@ -706,13 +753,15 @@ var ComponentApp = /*#__PURE__*/function () {
706
753
  renderDisplayType: renderParams.renderDisplayType,
707
754
  componentSign: this._componentSign,
708
755
  analytics: this.AMSSDK.options.analytics,
756
+ productScene: productScene,
709
757
  productSceneVersion: productSceneVersion,
710
758
  environment: environment,
711
759
  appVersion: this._appVersion,
712
760
  extendInfo: extendInfo,
713
761
  locale: this.AMSSDK.options.locale,
714
762
  instanceId: this.AMSSDK._instanceId,
715
- hostSign: hostSign
763
+ hostSign: hostSign,
764
+ mid: mid
716
765
  }),
717
766
  path = _getIframeUrl2.path,
718
767
  locationSearch = _getIframeUrl2.locationSearch;
@@ -1196,9 +1245,9 @@ var ComponentApp = /*#__PURE__*/function () {
1196
1245
  }
1197
1246
  }, {
1198
1247
  key: "handleDeclareInfo",
1199
- value: function handleDeclareInfo(_ref7) {
1200
- var _ref7$closeDialogData = _ref7.closeDialogData,
1201
- closeDialogData = _ref7$closeDialogData === void 0 ? {} : _ref7$closeDialogData;
1248
+ value: function handleDeclareInfo(_ref8) {
1249
+ var _ref8$closeDialogData = _ref8.closeDialogData,
1250
+ closeDialogData = _ref8$closeDialogData === void 0 ? {} : _ref8$closeDialogData;
1202
1251
  _handleDeclareInfo({
1203
1252
  closeDialogData: closeDialogData
1204
1253
  });
@@ -1235,12 +1284,12 @@ var ComponentApp = /*#__PURE__*/function () {
1235
1284
  }
1236
1285
  };
1237
1286
  }
1238
- if (this._webAppHeartBeatTimeoutId) {
1239
- clearTimeout(this._webAppHeartBeatTimeoutId);
1240
- this._webAppHeartBeatTimeoutId = null;
1287
+ if (window._webAppHeartBeatTimeoutId) {
1288
+ clearTimeout(window._webAppHeartBeatTimeoutId);
1289
+ window._webAppHeartBeatTimeoutId = null;
1241
1290
  }
1242
1291
  if (this._webAppHeartBeatTimeoutFn) {
1243
- this._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
1292
+ window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
1244
1293
  }
1245
1294
  setTimeout(function () {
1246
1295
  if (_this8.isAppAttached()) {
@@ -1299,17 +1348,20 @@ var ComponentApp = /*#__PURE__*/function () {
1299
1348
  key: "dispatchToApp",
1300
1349
  value: function dispatchToApp(payload) {
1301
1350
  var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1351
+ var sendLog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1302
1352
  var data = Object.assign({}, payload, {
1303
1353
  name: messageName.SDK_TO_APP,
1304
1354
  mode: this.AMSSDK.options.mode,
1305
1355
  appId: COMPONENTPLUGINID,
1306
1356
  instanceId: this.AMSSDK._instanceId
1307
1357
  });
1308
- this.AMSSDK.logger.logInfo({
1309
- title: 'sdk_event_send_message_to_web'
1310
- }, {
1311
- event: data === null || data === void 0 ? void 0 : data.context.event
1312
- }).send();
1358
+ if (sendLog) {
1359
+ this.AMSSDK.logger.logInfo({
1360
+ title: 'sdk_event_send_message_to_web'
1361
+ }, {
1362
+ event: data === null || data === void 0 ? void 0 : data.context.event
1363
+ }).send();
1364
+ }
1313
1365
  if (targetElement && targetElement.contentWindow) {
1314
1366
  return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
1315
1367
  }
@@ -1344,7 +1396,7 @@ var ComponentApp = /*#__PURE__*/function () {
1344
1396
  key: "sendRenderEvent",
1345
1397
  value: (function () {
1346
1398
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1347
- 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;
1348
1400
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1349
1401
  while (1) switch (_context8.prev = _context8.next) {
1350
1402
  case 0:
@@ -1373,20 +1425,32 @@ var ComponentApp = /*#__PURE__*/function () {
1373
1425
  data: {
1374
1426
  queryResult: res,
1375
1427
  submitResult: submitRes,
1376
- sessionResult: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionMetaData,
1377
- 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,
1378
1430
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
1379
- renderDisplayType: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.renderDisplayType,
1380
- appearance: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.appearance,
1381
- 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,
1382
1434
  merchantAppointParam: this._merchantAppointParam,
1383
1435
  envInfo: {
1384
1436
  screenHeight: screen.height,
1385
1437
  screenWidth: screen.width
1386
- }
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
+ })
1387
1451
  }
1388
1452
  }
1389
- });
1453
+ }, null, true);
1390
1454
  this.AMSSDK.logger.logInfo({
1391
1455
  title: 'sdk_event_renderComponent'
1392
1456
  });
@@ -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
+ }