@alipay/ams-checkout 0.0.1710212811-dev.28 → 0.0.1710212811-dev.29

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.
@@ -1,5 +1,5 @@
1
1
  import ComponentApp from '../../plugin/component';
2
- import { componentSignEnum, IAppendParams, IcreateComponent, IoptionsParams, IpaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
2
+ import { componentSignEnum, IcreateComponent, IoptionsParams, IpaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
3
3
  import CoreInstance from '../instance/index';
4
4
  export declare const getComponentSign: (params: IpaymentSessionMetaData) => componentSignEnum;
5
5
  export declare const parseSessionData: (sessionData: string) => [IpaymentSessionMetaData, string];
@@ -7,7 +7,6 @@ export declare class AMSComponent extends CoreInstance {
7
7
  _componentApp: ComponentApp;
8
8
  channelType: componentSignEnum[];
9
9
  productSceneVersion: string;
10
- _appendParams: IAppendParams;
11
10
  constructor(options: IoptionsParams);
12
11
  private parameterInitAndCheck;
13
12
  private pluginAppendIframe;
@@ -29,7 +28,6 @@ export declare class AMSComponent extends CoreInstance {
29
28
  * @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
30
29
  */
31
30
  createComponent(params: IcreateComponent): Promise<void>;
32
- private getBusActionNames;
33
31
  private createComponentProcess;
34
32
  preloadComponent(channelType: any, productSceneVersion: any): void;
35
33
  clearPreloadIframe(isTimeOut?: boolean): void;
@@ -116,7 +116,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
116
116
  _defineProperty(_assertThisInitialized(_this), "_componentApp", void 0);
117
117
  _defineProperty(_assertThisInitialized(_this), "channelType", void 0);
118
118
  _defineProperty(_assertThisInitialized(_this), "productSceneVersion", void 0);
119
- _defineProperty(_assertThisInitialized(_this), "_appendParams", void 0);
120
119
  var ComponentPlugin = new ComponentApp();
121
120
  ComponentPlugin.setRender(createIframeNode);
122
121
  ComponentPlugin.setPreloadRender(createPreloadIframeNode);
@@ -326,32 +325,12 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
326
325
  return _this4.createComponentProcess(appendParams);
327
326
  });
328
327
  }
329
- }, {
330
- key: "getBusActionNames",
331
- value: function getBusActionNames(appendParams) {
332
- var _appendParams$iframeN;
333
- if (!appendParams) {
334
- return null;
335
- }
336
- var actionNames = null;
337
- var paymentSessionConfig = appendParams === null || appendParams === void 0 || (_appendParams$iframeN = appendParams.iframeNodesParams) === null || _appendParams$iframeN === void 0 || (_appendParams$iframeN = _appendParams$iframeN.paymentSessionMetaData) === null || _appendParams$iframeN === void 0 ? void 0 : _appendParams$iframeN.paymentSessionConfig;
338
- if (paymentSessionConfig) {
339
- var _appendParams$iframeN2;
340
- var pluginKey = paymentSessionConfig.productScene + paymentSessionConfig.productSceneVersion + paymentSessionConfig.paymentMethodCategoryType;
341
- var paymentMethodType = appendParams === null || appendParams === void 0 || (_appendParams$iframeN2 = appendParams.iframeNodesParams) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentSessionMetaData) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentSessionFactor) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentMethodInfo) === null || _appendParams$iframeN2 === void 0 ? void 0 : _appendParams$iframeN2.paymentMethodType;
342
- if (paymentMethodType) {
343
- pluginKey = pluginKey + paymentMethodType;
344
- }
345
- actionNames = this._getPlugin(pluginKey);
346
- }
347
- return actionNames;
348
- }
349
328
  }, {
350
329
  key: "createComponentProcess",
351
330
  value: function createComponentProcess(appendParams) {
352
331
  var _this$getBusActionNam;
353
332
  this._appendParams = appendParams;
354
- var actionName = (_this$getBusActionNam = this.getBusActionNames(appendParams)) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.createComponent;
333
+ var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.createComponent;
355
334
  if (actionName && BusManager.isSubscribed(actionName)) {
356
335
  // 执行出错了,在通用拦截器返回
357
336
  BusManager.publish(new BusMessage(actionName, JSON.stringify({
@@ -439,7 +418,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
439
418
  value: function mountComponentProcess(appendParams) {
440
419
  var _this$getBusActionNam2;
441
420
  this._appendParams = appendParams;
442
- var actionName = (_this$getBusActionNam2 = this.getBusActionNames(appendParams)) === null || _this$getBusActionNam2 === void 0 ? void 0 : _this$getBusActionNam2.mountComponent;
421
+ var actionName = (_this$getBusActionNam2 = this.getBusActionNames()) === null || _this$getBusActionNam2 === void 0 ? void 0 : _this$getBusActionNam2.mountComponent;
443
422
  if (actionName && BusManager.isSubscribed(actionName)) {
444
423
  // 执行出错了,在通用拦截器返回
445
424
  BusManager.publish(new BusMessage(actionName, JSON.stringify({
@@ -466,22 +445,24 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
466
445
  try {
467
446
  var _this7$getBusActionNa;
468
447
  var eventCallbackId = uuid();
469
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
470
- _this7._eventCenter.once(eventCallbackId, function (_data) {
471
- resolve(_data);
472
- });
473
448
  _this7.logger.logInfo({
474
449
  title: 'sdk_event_apiSubmit'
475
450
  });
476
- var actionName = (_this7$getBusActionNa = _this7.getBusActionNames(_this7._appendParams)) === null || _this7$getBusActionNa === void 0 ? void 0 : _this7$getBusActionNa.submit;
451
+ var actionName = (_this7$getBusActionNa = _this7.getBusActionNames()) === null || _this7$getBusActionNa === void 0 ? void 0 : _this7$getBusActionNa.submit;
477
452
  if (actionName && BusManager.isSubscribed(actionName)) {
478
453
  // 执行出错了,在通用拦截器返回
479
- BusManager.publish(new BusMessage(actionName, JSON.stringify({
454
+ BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
480
455
  appendParams: _this7._appendParams,
481
456
  options: _this7.originOptions,
482
457
  data: data
483
- })));
458
+ }))).then(function (busMessage) {
459
+ resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
460
+ });
484
461
  } else {
462
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
463
+ _this7._eventCenter.once(eventCallbackId, function (_data) {
464
+ resolve(_data);
465
+ });
485
466
  _this7._componentApp.dispatchToApp({
486
467
  context: {
487
468
  event: 'submitPay',
@@ -1,7 +1,8 @@
1
- import type { AMSCheckoutOptions, InitSecurityConfig, IoptionsParams } from '../../types/index';
1
+ import type { AMSCheckoutOptions, IAppendParams, InitSecurityConfig, IoptionsParams } from '../../types/index';
2
2
  import { EventCenter } from '../../util/index';
3
3
  import { Logger } from '../../util/logger';
4
4
  import { Security } from '../../util/security';
5
+ import { ComponentActionNamesType } from 'src/plugin/type';
5
6
  export default class AMSSDK {
6
7
  options: AMSCheckoutOptions;
7
8
  originOptions: IoptionsParams;
@@ -9,6 +10,7 @@ export default class AMSSDK {
9
10
  _eventCenter: EventCenter;
10
11
  _instanceId: string;
11
12
  _storageId: string;
13
+ _appendParams: IAppendParams;
12
14
  protected securitySdkMap: Map<string, Security>;
13
15
  protected plugins: Map<string, any>;
14
16
  constructor(options: IoptionsParams);
@@ -73,4 +75,5 @@ export default class AMSSDK {
73
75
  * @description Overlay Subscription
74
76
  */
75
77
  protected _overrideSubscription(name: string, func: any, funcKey: string): void;
78
+ protected getBusActionNames(): ComponentActionNamesType;
76
79
  }
@@ -26,6 +26,7 @@ import CallApp from "../../util/intl-callapp/es/main";
26
26
  import { LogConfig, Logger } from "../../util/logger";
27
27
  import { compareVersion } from "../../util/versionCompare";
28
28
  import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security, SecurityRegionEnum } from "../../util/security";
29
+ import { BusManager, BusMessage } from "../bus";
29
30
  var AMSSDK = /*#__PURE__*/function () {
30
31
  function AMSSDK(options) {
31
32
  _classCallCheck(this, AMSSDK);
@@ -35,6 +36,7 @@ var AMSSDK = /*#__PURE__*/function () {
35
36
  _defineProperty(this, "_eventCenter", void 0);
36
37
  _defineProperty(this, "_instanceId", void 0);
37
38
  _defineProperty(this, "_storageId", void 0);
39
+ _defineProperty(this, "_appendParams", void 0);
38
40
  _defineProperty(this, "securitySdkMap", void 0);
39
41
  _defineProperty(this, "plugins", void 0);
40
42
  this._instanceId = uuid();
@@ -103,9 +105,17 @@ var AMSSDK = /*#__PURE__*/function () {
103
105
  }, {
104
106
  key: "unmount",
105
107
  value: function unmount() {
108
+ var _this$getBusActionNam;
106
109
  this.logger.logInfo({
107
110
  title: 'sdk_event_apiOnDestroy'
108
111
  }).send();
112
+ var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.destoryComponent;
113
+ if (actionName && BusManager.isSubscribed(actionName)) {
114
+ // 执行出错了,在通用拦截器返回
115
+ BusManager.publish(new BusMessage(actionName, JSON.stringify({
116
+ options: this.originOptions
117
+ })));
118
+ }
109
119
  var _iterator = _createForOfIteratorHelper(this.plugins.values()),
110
120
  _step;
111
121
  try {
@@ -387,6 +397,27 @@ var AMSSDK = /*#__PURE__*/function () {
387
397
  this._eventCenter.off(name, func, funcKey);
388
398
  this._eventCenter.on(name, func, funcKey);
389
399
  }
400
+ }, {
401
+ key: "getBusActionNames",
402
+ value: function getBusActionNames() {
403
+ var _appendParams$iframeN;
404
+ var appendParams = this._appendParams;
405
+ if (!appendParams) {
406
+ return null;
407
+ }
408
+ var actionNames = null;
409
+ var paymentSessionConfig = appendParams === null || appendParams === void 0 || (_appendParams$iframeN = appendParams.iframeNodesParams) === null || _appendParams$iframeN === void 0 || (_appendParams$iframeN = _appendParams$iframeN.paymentSessionMetaData) === null || _appendParams$iframeN === void 0 ? void 0 : _appendParams$iframeN.paymentSessionConfig;
410
+ if (paymentSessionConfig) {
411
+ var _appendParams$iframeN2;
412
+ var pluginKey = paymentSessionConfig.productScene + paymentSessionConfig.productSceneVersion + paymentSessionConfig.paymentMethodCategoryType;
413
+ var paymentMethodType = appendParams === null || appendParams === void 0 || (_appendParams$iframeN2 = appendParams.iframeNodesParams) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentSessionMetaData) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentSessionFactor) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentMethodInfo) === null || _appendParams$iframeN2 === void 0 ? void 0 : _appendParams$iframeN2.paymentMethodType;
414
+ if (paymentMethodType) {
415
+ pluginKey = pluginKey + paymentMethodType;
416
+ }
417
+ actionNames = this._getPlugin(pluginKey);
418
+ }
419
+ return actionNames;
420
+ }
390
421
  }]);
391
422
  return AMSSDK;
392
423
  }();
@@ -5,8 +5,8 @@ export interface ComponentActionNamesType {
5
5
  canMakePayments?: string;
6
6
  optional_init?: string;
7
7
  createComponent?: string;
8
- submit?: string;
9
8
  mountComponent?: string;
9
+ submit?: string;
10
10
  destoryComponent?: string;
11
11
  }
12
12
  export type IExtendPluginItem = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1710212811-dev.28",
3
+ "version": "0.0.1710212811-dev.29",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",