@alipay/ams-checkout 1.10.0 → 1.11.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 (40) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/core/bus/ability/callback.d.ts +9 -0
  3. package/esm/core/bus/ability/callback.js +55 -0
  4. package/esm/core/bus/ability/security.d.ts +10 -0
  5. package/esm/core/bus/ability/security.js +104 -0
  6. package/esm/core/bus/ability/tracker.d.ts +9 -0
  7. package/esm/core/bus/ability/tracker.js +77 -0
  8. package/esm/core/bus/index.d.ts +125 -0
  9. package/esm/core/bus/index.js +366 -0
  10. package/esm/core/bus/interface.d.ts +32 -0
  11. package/esm/core/bus/interface.js +35 -0
  12. package/esm/core/component/index.d.ts +20 -1
  13. package/esm/core/component/index.js +270 -23
  14. package/esm/core/instance/index.d.ts +5 -1
  15. package/esm/core/instance/index.js +41 -4
  16. package/esm/index.d.ts +9 -4
  17. package/esm/index.js +56 -21
  18. package/esm/{core/applepay/index.d.ts → plugin/applepay/component.d.ts} +27 -8
  19. package/esm/{core/applepay/index.js → plugin/applepay/component.js} +150 -180
  20. package/esm/plugin/applepay/index.d.ts +17 -0
  21. package/esm/plugin/applepay/index.js +117 -0
  22. package/esm/{common → plugin}/applepay/interface.d.ts +62 -3
  23. package/esm/plugin/applepay/interface.js +69 -0
  24. package/esm/{common/applepay/index.d.ts → plugin/applepay/service.d.ts} +13 -7
  25. package/esm/{common/applepay/index.js → plugin/applepay/service.js} +159 -41
  26. package/esm/plugin/component/cashierApp.d.ts +3 -0
  27. package/esm/plugin/component/cashierApp.js +23 -2
  28. package/esm/plugin/component/index.d.ts +6 -2
  29. package/esm/plugin/component/index.js +126 -44
  30. package/esm/plugin/const.d.ts +2 -0
  31. package/esm/plugin/const.js +19 -0
  32. package/esm/plugin/type.d.ts +33 -0
  33. package/esm/request/index.d.ts +1 -1
  34. package/esm/service/index.d.ts +1 -1
  35. package/esm/types/index.d.ts +63 -6
  36. package/esm/types/index.js +8 -1
  37. package/esm/util/createIframeNode.d.ts +1 -0
  38. package/esm/util/createIframeNode.js +6 -0
  39. package/package.json +1 -1
  40. /package/esm/{common/applepay/interface.js → plugin/type.js} +0 -0
@@ -69,7 +69,11 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
69
69
  extendInfo = iframeParams.extendInfo,
70
70
  locale = iframeParams.locale,
71
71
  instanceId = iframeParams.instanceId,
72
- renderDisplayType = iframeParams.renderDisplayType;
72
+ renderDisplayType = iframeParams.renderDisplayType,
73
+ _iframeParams$isPrelo = iframeParams.isPreload,
74
+ isPreload = _iframeParams$isPrelo === void 0 ? '' : _iframeParams$isPrelo,
75
+ _iframeParams$hostSig = iframeParams.hostSign,
76
+ hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig;
73
77
  var path = getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo || '');
74
78
  var initialScale = 1;
75
79
  var scale = getViewPort('initial-scale') || initialScale;
@@ -90,7 +94,9 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
90
94
  analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
91
95
  sdkVersion: sdkVersion,
92
96
  refUrl: window.location.href,
93
- _componentStartTime: "".concat(Date.now())
97
+ _componentStartTime: "".concat(Date.now()),
98
+ isPreload: isPreload || '',
99
+ hostSign: hostSign || ''
94
100
  });
95
101
  if (LOCAL_MOCK) urlParams.LOCAL_MOCK = LOCAL_MOCK;
96
102
  if (requestHost) urlParams.requestHost = requestHost;
@@ -98,6 +104,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
98
104
  if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
99
105
  if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
100
106
  if (_displayType) urlParams.displayType = _displayType;
107
+ if (isPreload) urlParams.isPreload = isPreload;
101
108
  var locationSearch = serialize(urlParams);
102
109
  return {
103
110
  path: path,
@@ -127,4 +134,18 @@ export var createIframe = function createIframe(mode, platform) {
127
134
  iframe.style.opacity = none;
128
135
  iframe.style.overflow = 'hidden';
129
136
  return iframe;
137
+ };
138
+ export var createPreloadIframe = function createPreloadIframe(channelType, version) {
139
+ var id = "ams-checkout-component-".concat(channelType, "-").concat(version);
140
+ var iframe = document.createElement('iframe');
141
+ var iframeId = id;
142
+ var none = '1px';
143
+ var width = '1px';
144
+ iframe.id = iframeId;
145
+ iframe.style.height = none;
146
+ iframe.style.width = width;
147
+ iframe.style.border = none;
148
+ iframe.style.opacity = '0';
149
+ iframe.style.overflow = 'hidden';
150
+ return iframe;
130
151
  };
@@ -1,6 +1,6 @@
1
1
  import type AMSCheckout from '../../core/instance';
2
2
  import type { eventPayload, eventPayloadContext, IappendIframeNodesParams, IMerchantAppointParam, Iselector } from '../../types';
3
- import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
3
+ import { componentSignEnum, DeviceIdParameter, platformEnum, renderDisplayTypeEnum } from '../../types';
4
4
  type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
5
5
  export default class ComponentApp {
6
6
  app: null | HTMLIFrameElement;
@@ -13,6 +13,7 @@ export default class ComponentApp {
13
13
  private popupApp?;
14
14
  private appDomain;
15
15
  private createIframeNode;
16
+ private createPreloadIframeNode;
16
17
  private _selector;
17
18
  private _appVersion;
18
19
  private _isRetention;
@@ -40,13 +41,15 @@ export default class ComponentApp {
40
41
  * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
41
42
  */
42
43
  setRender(renderFunc: IrenderFuncParams): void;
44
+ setPreloadRender(renderFunc: any): void;
43
45
  private initSecurity;
44
46
  private logDeviceId;
45
- private getDeviceIdAndLog;
47
+ getDeviceIdAndLog(deviceIdParameter?: DeviceIdParameter, isPolling?: boolean): Promise<string>;
46
48
  /**
47
49
  * @description render iframe content
48
50
  */
49
51
  appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void>;
52
+ appendPreloadIframeNodes(componentSign: any, productSceneVersion: any): void;
50
53
  private setParameterDefaultValues;
51
54
  private renderInlineLoading;
52
55
  private renderPopupLoading;
@@ -57,6 +60,7 @@ export default class ComponentApp {
57
60
  private createActionQueryPromise;
58
61
  private createSubmitPromise;
59
62
  private cleanElement;
63
+ private createPreloadApp;
60
64
  /**
61
65
  * @description Create app
62
66
  */
@@ -22,7 +22,7 @@ import { queryPaymentInfo, submitPayInfo } from "../../service";
22
22
  import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
23
23
  import { getType, isJsonString, isPC } from "../../util";
24
24
  import { isLocalMock } from "../../util/mock";
25
- import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
25
+ import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
26
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
27
27
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
28
28
  import { createModal, destroyModal, insertStyleSheet } from "./popupWindow.style";
@@ -40,6 +40,7 @@ var ComponentApp = /*#__PURE__*/function () {
40
40
  _defineProperty(this, "popupApp", void 0);
41
41
  _defineProperty(this, "appDomain", void 0);
42
42
  _defineProperty(this, "createIframeNode", void 0);
43
+ _defineProperty(this, "createPreloadIframeNode", void 0);
43
44
  _defineProperty(this, "_selector", void 0);
44
45
  _defineProperty(this, "_appVersion", void 0);
45
46
  _defineProperty(this, "_isRetention", void 0);
@@ -53,12 +54,15 @@ var ComponentApp = /*#__PURE__*/function () {
53
54
  _defineProperty(this, "_merchantAppointParam", void 0);
54
55
  _defineProperty(this, "_webAppHeartBeatTimeoutId", void 0);
55
56
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
56
- this._appVersion = '1.10.0';
57
+ this._appVersion = '1.11.0';
57
58
  this._isInitComponent = false;
58
59
  this._selector = "#".concat(COMPONENT_SECTION_ID);
59
60
  this.createIframeNode = function () {
60
61
  return Promise.resolve();
61
62
  };
63
+ this.createPreloadIframeNode = function () {
64
+ return Promise.resolve();
65
+ };
62
66
  this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
63
67
  this._isRetention = true;
64
68
  this._appLocationSearch = '';
@@ -119,6 +123,11 @@ var ComponentApp = /*#__PURE__*/function () {
119
123
  value: function setRender(renderFunc) {
120
124
  this.createIframeNode = renderFunc;
121
125
  }
126
+ }, {
127
+ key: "setPreloadRender",
128
+ value: function setPreloadRender(renderFunc) {
129
+ this.createPreloadIframeNode = renderFunc;
130
+ }
122
131
  }, {
123
132
  key: "initSecurity",
124
133
  value: function initSecurity() {
@@ -280,6 +289,18 @@ var ComponentApp = /*#__PURE__*/function () {
280
289
  return Promise.reject(error);
281
290
  });
282
291
  }
292
+ }, {
293
+ key: "appendPreloadIframeNodes",
294
+ value: function appendPreloadIframeNodes(componentSign, productSceneVersion) {
295
+ var virtualPreloadIframe = this.createPreloadApp(componentSign, productSceneVersion);
296
+ this.createPreloadIframeNode(virtualPreloadIframe);
297
+ this.AMSSDK.logger.logInfo({
298
+ title: 'performance_optimization_preload'
299
+ }, {
300
+ componentSign: componentSign,
301
+ productSceneVersion: productSceneVersion
302
+ });
303
+ }
283
304
  }, {
284
305
  key: "setParameterDefaultValues",
285
306
  value: function setParameterDefaultValues(componentSign, renderParams) {
@@ -342,8 +363,8 @@ var ComponentApp = /*#__PURE__*/function () {
342
363
  // eslint-disable-next-line no-async-promise-executor
343
364
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
344
365
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
345
- var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
346
- var envInfo, params, _this5$_renderParams5, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams6, _action$web, _action$wap, action, signType;
366
+ 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;
347
368
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
348
369
  while (1) switch (_context2.prev = _context2.next) {
349
370
  case 0:
@@ -359,78 +380,106 @@ var ComponentApp = /*#__PURE__*/function () {
359
380
  /**
360
381
  * @description Simulated or unnecessary scenarios
361
382
  */
362
- if (!(isLocalMock() || (_this5$_renderParams4 = _this5._renderParams) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.action) !== null && _this5$_renderParams4 !== void 0 && _this5$_renderParams4.skipSdkQuery)) {
363
- _context2.next = 4;
383
+ _ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, extendInfo = _ref3.extendInfo;
384
+ enableVaultingApiOptimize = false;
385
+ enableEasypayApiOptimize = false;
386
+ try {
387
+ extendInfoData = JSON.parse(extendInfo);
388
+ enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
389
+ enableEasypayApiOptimize = extendInfoData.enableEasypayApiOptimize || false;
390
+ } catch (error) {
391
+ console.log(error);
392
+ }
393
+ if (!isLocalMock()) {
394
+ _context2.next = 8;
364
395
  break;
365
396
  }
366
397
  return _context2.abrupt("return", resolve({
367
398
  message: 'sdk no need to make query request',
368
399
  success: true
369
400
  }));
370
- case 4:
371
- if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
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)) {
372
403
  _context2.next = 10;
373
404
  break;
374
405
  }
406
+ return _context2.abrupt("return", resolve({
407
+ message: 'sdk no need to make query request',
408
+ success: true
409
+ }));
410
+ case 10:
411
+ if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
412
+ _context2.next = 16;
413
+ break;
414
+ }
375
415
  params.paymentMethodType = 'CARD';
376
- _context2.next = 8;
416
+ _context2.next = 14;
377
417
  return _this5.getDeviceIdAndLog();
378
- case 8:
418
+ case 14:
379
419
  envInfo.deviceId = _context2.sent;
380
420
  if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
381
421
  envInfo.extendInfo = {
382
422
  WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
383
423
  };
384
424
  }
385
- case 10:
425
+ case 16:
386
426
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
387
- _context2.next = 18;
427
+ _context2.next = 26;
428
+ break;
429
+ }
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;
432
+ 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;
388
434
  break;
389
435
  }
390
- _ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
391
- _ref4 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
436
+ return _context2.abrupt("return", resolve({
437
+ message: 'sdk no need to make query request',
438
+ success: true
439
+ }));
440
+ case 21:
392
441
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
393
- _context2.next = 15;
442
+ _context2.next = 23;
394
443
  break;
395
444
  }
396
445
  return _context2.abrupt("return", resolve({
397
446
  message: 'sdk no need to make query request',
398
447
  success: true
399
448
  }));
400
- case 15:
401
- _context2.next = 17;
449
+ case 23:
450
+ _context2.next = 25;
402
451
  return _this5.getDeviceIdAndLog();
403
- case 17:
452
+ case 25:
404
453
  envInfo.deviceId = _context2.sent;
405
- case 18:
454
+ case 26:
406
455
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
407
- _context2.next = 28;
456
+ _context2.next = 36;
408
457
  break;
409
458
  }
410
- action = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 || (_this5$_renderParams6 = _this5$_renderParams6.paymentSessionMetaData) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.action) || {};
459
+ 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) || {};
411
460
  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;
412
461
  if (!(signType === 'SMS')) {
413
- _context2.next = 23;
462
+ _context2.next = 31;
414
463
  break;
415
464
  }
416
465
  return _context2.abrupt("return", resolve({
417
466
  message: 'sdk no need to make query request',
418
467
  success: true
419
468
  }));
420
- case 23:
469
+ case 31:
421
470
  if (!(!signType || signType !== 'REDIRECT')) {
422
- _context2.next = 25;
471
+ _context2.next = 33;
423
472
  break;
424
473
  }
425
474
  return _context2.abrupt("return", resolve({
426
475
  success: false
427
476
  }));
428
- case 25:
429
- _context2.next = 27;
477
+ case 33:
478
+ _context2.next = 35;
430
479
  return _this5.getDeviceIdAndLog();
431
- case 27:
480
+ case 35:
432
481
  envInfo.deviceId = _context2.sent;
433
- case 28:
482
+ case 36:
434
483
  _this5.AMSSDK.logger.logInfo({
435
484
  title: 'sdk_event_sdkQuery'
436
485
  }, {
@@ -444,11 +493,7 @@ var ComponentApp = /*#__PURE__*/function () {
444
493
  key: 'sdk_action_query_end',
445
494
  value: Date.now()
446
495
  });
447
- if (res !== null && res !== void 0 && res.success) {
448
- resolve(res);
449
- } else {
450
- resolve(res);
451
- }
496
+ resolve(res);
452
497
  }).catch(function (err) {
453
498
  if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD, componentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
454
499
  return resolve({
@@ -466,7 +511,7 @@ var ComponentApp = /*#__PURE__*/function () {
466
511
  paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
467
512
  }).send();
468
513
  });
469
- case 30:
514
+ case 38:
470
515
  case "end":
471
516
  return _context2.stop();
472
517
  }
@@ -478,6 +523,8 @@ var ComponentApp = /*#__PURE__*/function () {
478
523
  }());
479
524
  return this._actionQueryPromise;
480
525
  }
526
+
527
+ // private create
481
528
  }, {
482
529
  key: "createSubmitPromise",
483
530
  value: function createSubmitPromise() {
@@ -495,7 +542,7 @@ var ComponentApp = /*#__PURE__*/function () {
495
542
 
496
543
  // eslint-disable-next-line no-async-promise-executor
497
544
  this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
498
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
545
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
499
546
  var _this6$_renderParams;
500
547
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
501
548
  while (1) switch (_context3.prev = _context3.next) {
@@ -558,7 +605,7 @@ var ComponentApp = /*#__PURE__*/function () {
558
605
  }, _callee3);
559
606
  }));
560
607
  return function (_x3) {
561
- return _ref5.apply(this, arguments);
608
+ return _ref6.apply(this, arguments);
562
609
  };
563
610
  }());
564
611
  }
@@ -593,7 +640,40 @@ var ComponentApp = /*#__PURE__*/function () {
593
640
  console.error(error);
594
641
  }
595
642
  }
596
-
643
+ // 预加载iframe创建
644
+ }, {
645
+ key: "createPreloadApp",
646
+ value: function createPreloadApp(componentSign) {
647
+ var productSceneVersion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.0';
648
+ var preloadIframe = createPreloadIframe(componentSign, productSceneVersion);
649
+ var _getIframeUrl = getIframeUrl({
650
+ renderDisplayType: renderDisplayTypeEnum.popup,
651
+ componentSign: componentSign,
652
+ analytics: {
653
+ enabled: false
654
+ },
655
+ productSceneVersion: productSceneVersion,
656
+ environment: this.AMSSDK.options.env.environment,
657
+ // TODO 确定一下这个参数是干啥的
658
+ appVersion: this._appVersion,
659
+ extendInfo: '',
660
+ locale: '',
661
+ instanceId: '',
662
+ isPreload: 'true'
663
+ }),
664
+ path = _getIframeUrl.path,
665
+ locationSearch = _getIframeUrl.locationSearch;
666
+ preloadIframe.src = "".concat(path, "?").concat(locationSearch);
667
+ if (!path) {
668
+ this.AMSSDK.logger.logError({
669
+ title: 'performance_optimization_preload_path_error'
670
+ }, {
671
+ path: path,
672
+ locationSearch: locationSearch
673
+ });
674
+ }
675
+ return preloadIframe;
676
+ }
597
677
  /**
598
678
  * @description Create app
599
679
  */
@@ -621,7 +701,8 @@ var ComponentApp = /*#__PURE__*/function () {
621
701
  extendInfo: extendInfo
622
702
  });
623
703
  this.app = createIframe(this.AMSSDK.options.mode, this.platform);
624
- var _getIframeUrl = getIframeUrl({
704
+ var hostSign = ((renderParams === null || renderParams === void 0 ? void 0 : renderParams.sessionData) || '').split('&&')[1] || '';
705
+ var _getIframeUrl2 = getIframeUrl({
625
706
  renderDisplayType: renderParams.renderDisplayType,
626
707
  componentSign: this._componentSign,
627
708
  analytics: this.AMSSDK.options.analytics,
@@ -630,10 +711,11 @@ var ComponentApp = /*#__PURE__*/function () {
630
711
  appVersion: this._appVersion,
631
712
  extendInfo: extendInfo,
632
713
  locale: this.AMSSDK.options.locale,
633
- instanceId: this.AMSSDK._instanceId
714
+ instanceId: this.AMSSDK._instanceId,
715
+ hostSign: hostSign
634
716
  }),
635
- path = _getIframeUrl.path,
636
- locationSearch = _getIframeUrl.locationSearch;
717
+ path = _getIframeUrl2.path,
718
+ locationSearch = _getIframeUrl2.locationSearch;
637
719
  this._appLocationSearch = locationSearch;
638
720
  this.app.src = "".concat(path, "?").concat(locationSearch);
639
721
 
@@ -1114,9 +1196,9 @@ var ComponentApp = /*#__PURE__*/function () {
1114
1196
  }
1115
1197
  }, {
1116
1198
  key: "handleDeclareInfo",
1117
- value: function handleDeclareInfo(_ref6) {
1118
- var _ref6$closeDialogData = _ref6.closeDialogData,
1119
- closeDialogData = _ref6$closeDialogData === void 0 ? {} : _ref6$closeDialogData;
1199
+ value: function handleDeclareInfo(_ref7) {
1200
+ var _ref7$closeDialogData = _ref7.closeDialogData,
1201
+ closeDialogData = _ref7$closeDialogData === void 0 ? {} : _ref7$closeDialogData;
1120
1202
  _handleDeclareInfo({
1121
1203
  closeDialogData: closeDialogData
1122
1204
  });
@@ -0,0 +1,2 @@
1
+ import { IExtendPlugin } from './type';
2
+ export declare const ExtendPlugin: IExtendPlugin;
@@ -0,0 +1,19 @@
1
+ import { ApplePayActionEnum, PaymentActionEnum } from "../core/bus/interface";
2
+ import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from "../types/index";
3
+ export var ExtendPlugin = [{
4
+ sessionMatcher: {
5
+ productScene: productSceneEnum.CASHIER_PAYMENT,
6
+ productSceneVersion: ProductSceneVersion.V1,
7
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum.CARD,
8
+ paymentMethodTypes: ["CARD_APPLE_PAY"]
9
+ },
10
+ paymentChannelMatcher: {
11
+ paymentMethod: 'ApplePay'
12
+ },
13
+ busActionNames: {
14
+ canMakePayments: ApplePayActionEnum.canMakePayments,
15
+ optional_init: PaymentActionEnum.optional_init,
16
+ createComponent: ApplePayActionEnum.createComponent,
17
+ destoryComponent: ApplePayActionEnum.destoryComponent
18
+ }
19
+ }];
@@ -0,0 +1,33 @@
1
+ import { BusSubscriber } from '../core/bus';
2
+ import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from '../types';
3
+ export type IExtendPlugin = IExtendPluginItem[];
4
+ export interface ComponentActionNamesType {
5
+ canMakePayments?: string;
6
+ optional_init?: string;
7
+ createComponent?: string;
8
+ mountComponent?: string;
9
+ submit?: string;
10
+ destoryComponent?: string;
11
+ }
12
+ export type IExtendPluginItem = {
13
+ /**
14
+ * 以下为sessionData匹配的场景
15
+ */
16
+ sessionMatcher?: {
17
+ productScene: productSceneEnum;
18
+ productSceneVersion: ProductSceneVersion;
19
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
20
+ paymentMethodTypes: string[];
21
+ };
22
+ /**
23
+ * 用于无sessionData场景,比如:canMakePayments
24
+ */
25
+ paymentChannelMatcher?: {
26
+ paymentMethod: string;
27
+ };
28
+ /**
29
+ * 以下plugin 实现的定义
30
+ */
31
+ busActionNames: ComponentActionNamesType;
32
+ busSubscriber?: BusSubscriber;
33
+ };
@@ -1,5 +1,5 @@
1
1
  import { RequestConfig } from '../types';
2
- import { Logger } from '../util/logger';
2
+ import type { Logger } from '../util/logger';
3
3
  /**
4
4
  *
5
5
  * @param requestData 请求参数
@@ -1,5 +1,5 @@
1
1
  import { ApplePayPaymentSessionRequest, ApplePayPaymentSessionResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
2
- import { Logger } from '../util/logger';
2
+ import type { Logger } from '../util/logger';
3
3
  export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
4
4
  export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
5
5
  export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
@@ -135,16 +135,17 @@ export interface IpaymentSessionMetaData {
135
135
  skipSdkQuery: boolean;
136
136
  };
137
137
  paymentSessionFactor?: {
138
- applePay?: {
138
+ extendInfo?: {
139
139
  merchantCapabilities?: string[];
140
140
  supportedNetworks?: string[];
141
141
  };
142
142
  merchantInfo?: {
143
143
  registeredCountry?: string;
144
144
  partnerId?: string;
145
+ merchantName?: string;
145
146
  };
146
147
  order?: {
147
- orderDescription?: string;
148
+ orderDescription: string;
148
149
  };
149
150
  paymentAmount?: {
150
151
  value?: string;
@@ -153,6 +154,46 @@ export interface IpaymentSessionMetaData {
153
154
  paymentMethodInfo?: {
154
155
  paymentMethodType?: string;
155
156
  };
157
+ paymentMethodViewMetaData?: any;
158
+ paymentRequestId?: string;
159
+ supportedLanguages?: any;
160
+ /**
161
+ * 当前为苹果分期场景的信息
162
+ */
163
+ recurringInfo?: {
164
+ /**
165
+ * 代扣协议开始日期 不传为当前系统时间
166
+ */
167
+ startDate?: number;
168
+ /**
169
+ * 代扣协议结束日期 不传不限制结束时间
170
+ */
171
+ endDate?: number;
172
+ /**
173
+ * 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
174
+ */
175
+ intervalUnit?: string;
176
+ /**
177
+ * 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
178
+ */
179
+ intervalCount?: number;
180
+ /**
181
+ * 分期标题信息
182
+ */
183
+ title?: string;
184
+ /**
185
+ * 分期管理页面
186
+ */
187
+ managementURL?: string;
188
+ /**
189
+ * 苹果通知ipay MAPN信息变更的地址
190
+ */
191
+ tokenNotificationURL?: string;
192
+ /**
193
+ * 分期协议描述
194
+ */
195
+ agreementDescription?: string;
196
+ };
156
197
  };
157
198
  }
158
199
  export declare enum localeEnum {
@@ -198,8 +239,8 @@ export declare enum platformEnum {
198
239
  desktop = "desktop",
199
240
  mobile = "mobile"
200
241
  }
201
- type EventCallbackResult = {
202
- result: {
242
+ export type EventCallbackResult = {
243
+ result?: {
203
244
  resultCode: string;
204
245
  resultStatus: string;
205
246
  resultMessage: string;
@@ -407,9 +448,14 @@ export declare enum eventCodeEnum {
407
448
  SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
408
449
  SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
409
450
  SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS",
410
- SDK_PAYMENT_FINISH = "SDK_PAYMENT_FINISH",
451
+ SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
411
452
  SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
412
- SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL"
453
+ SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
454
+ SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL",
455
+ /**
456
+ * 当前为Apple Pay发起了Pay请求,但是用户关闭了页面
457
+ */
458
+ SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING"
413
459
  }
414
460
  export declare enum RedirectType {
415
461
  ApplinkUrl = "ApplinkUrl",
@@ -430,4 +476,15 @@ export interface CallbackEventInfo {
430
476
  export interface MultipleCallbackEvents {
431
477
  [key: string]: CallbackEventInfo;
432
478
  }
479
+ export type PaymentMethodTypeEnum = 'ApplePay';
480
+ export type ApplePaySubTypeEnum = 'ApplePayRecurringPayment';
481
+ export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
482
+ export declare enum ProductSceneVersion {
483
+ V1 = "1.0",
484
+ V2 = "2.0"
485
+ }
486
+ export type IAppendParams = {
487
+ componentSign: componentSignEnum;
488
+ iframeNodesParams: IappendIframeNodesParams;
489
+ };
433
490
  export {};
@@ -153,9 +153,11 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
153
153
  eventCodeEnum["SDK_CREATECOMPONENT_ERROR"] = "SDK_CREATECOMPONENT_ERROR";
154
154
  eventCodeEnum["SDK_CALL_URL_ERROR"] = "SDK_CALL_URL_ERROR";
155
155
  eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
156
- eventCodeEnum["SDK_PAYMENT_FINISH"] = "SDK_PAYMENT_FINISH";
156
+ eventCodeEnum["SDK_PAYMENT_SUCCESSFUL"] = "SDK_PAYMENT_SUCCESSFUL";
157
157
  eventCodeEnum["SDK_PAYMENT_FAIL"] = "SDK_PAYMENT_FAIL";
158
+ eventCodeEnum["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
158
159
  eventCodeEnum["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
160
+ eventCodeEnum["SDK_PAYMENT_PROCESSING"] = "SDK_PAYMENT_PROCESSING";
159
161
  return eventCodeEnum;
160
162
  }({});
161
163
  export var RedirectType = /*#__PURE__*/function (RedirectType) {
@@ -164,4 +166,9 @@ export var RedirectType = /*#__PURE__*/function (RedirectType) {
164
166
  RedirectType["NormalUrl"] = "NormalUrl";
165
167
  RedirectType["Unknown"] = "Unknown";
166
168
  return RedirectType;
169
+ }({});
170
+ export var ProductSceneVersion = /*#__PURE__*/function (ProductSceneVersion) {
171
+ ProductSceneVersion["V1"] = "1.0";
172
+ ProductSceneVersion["V2"] = "2.0";
173
+ return ProductSceneVersion;
167
174
  }({});
@@ -3,3 +3,4 @@ import { Iselector, renderDisplayTypeEnum } from '../types';
3
3
  * @description context中需要包含app节点,用于插入selector中
4
4
  */
5
5
  export declare const createIframeNode: (context: any, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
6
+ export declare const createPreloadIframeNode: (virtualPreloadIframe: any) => void;
@@ -39,4 +39,10 @@ export var createIframeNode = function createIframeNode(context, selector, rende
39
39
  }
40
40
  resolve();
41
41
  });
42
+ };
43
+ export var createPreloadIframeNode = function createPreloadIframeNode(virtualPreloadIframe) {
44
+ var body = document.body || null;
45
+ if (body) {
46
+ body.appendChild(virtualPreloadIframe);
47
+ }
42
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",