@alipay/ams-checkout 1.10.1 → 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 (36) 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 +15 -1
  13. package/esm/core/component/index.js +185 -28
  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 +0 -3
  17. package/esm/index.js +8 -18
  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/index.d.ts +2 -2
  27. package/esm/plugin/component/index.js +10 -10
  28. package/esm/plugin/const.d.ts +2 -0
  29. package/esm/plugin/const.js +19 -0
  30. package/esm/plugin/type.d.ts +33 -0
  31. package/esm/request/index.d.ts +1 -1
  32. package/esm/service/index.d.ts +1 -1
  33. package/esm/types/index.d.ts +60 -6
  34. package/esm/types/index.js +8 -1
  35. package/package.json +1 -1
  36. /package/esm/{common/applepay/interface.js → plugin/type.js} +0 -0
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
5
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -28,11 +30,17 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
30
  import { v4 as uuid } from 'uuid';
29
31
  import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
30
32
  import ComponentApp from "../../plugin/component";
31
- import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
33
+ import { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
32
34
  import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
33
35
  import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
34
36
  import { getSecurityConfigStorageKey } from "../../util/security";
35
37
  import CoreInstance from "../instance/index";
38
+ import { BusManager, BusMessage } from "../bus";
39
+ import { SDKCallbackBusSubscriber } from "../bus/ability/callback";
40
+ import { ApplePayBusSubscriber } from "../../plugin/applepay";
41
+ import { SecurityBusSubscriber } from "../bus/ability/security";
42
+ import { TrackerBusSubscriber } from "../bus/ability/tracker";
43
+ import { ExtendPlugin } from "../../plugin/const";
36
44
  export var getComponentSign = function getComponentSign(params) {
37
45
  var _params$paymentSessio = params.paymentSessionConfig,
38
46
  _params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
@@ -114,6 +122,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
114
122
  // Register Cashier Application Plug in
115
123
  _this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
116
124
  _this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
125
+ _this.registerBusAbility();
117
126
  return _this;
118
127
  }
119
128
  _createClass(AMSComponent, [{
@@ -188,6 +197,108 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
188
197
  localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
189
198
  }
190
199
  }
200
+
201
+ /**
202
+ * 初始化 Bus总线的能力
203
+ */
204
+ }, {
205
+ key: "registerBusAbility",
206
+ value: function registerBusAbility() {
207
+ var _this$originOptions,
208
+ _this2 = this;
209
+ BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod, this.logger);
210
+ BusManager.clear();
211
+ BusManager.addInterceptor({
212
+ onPublishException: function onPublishException(message, e) {
213
+ _this2.logger.logError({
214
+ title: 'onBusPublishException'
215
+ }, _objectSpread(_objectSpread({}, message), {}, {
216
+ errorMessage: JSON.stringify(e)
217
+ }));
218
+ }
219
+ });
220
+ // subscribe basic ablility
221
+ BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
222
+ var _this2$_componentApp;
223
+ (_this2$_componentApp = _this2._componentApp) === null || _this2$_componentApp === void 0 || (_this2$_componentApp = _this2$_componentApp.AMSSDK) === null || _this2$_componentApp === void 0 || _this2$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
224
+ }));
225
+ BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
226
+ var _this2$_componentApp2;
227
+ return (_this2$_componentApp2 = _this2._componentApp) === null || _this2$_componentApp2 === void 0 ? void 0 : _this2$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
228
+ }));
229
+ BusManager.subscribe(new TrackerBusSubscriber(this.logger));
230
+ // subscribe plugin
231
+ BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
232
+
233
+ // register bus plugin
234
+ ExtendPlugin.forEach(function (item) {
235
+ var _item$busActionNames;
236
+ if (item !== null && item !== void 0 && item.busSubscriber) {
237
+ BusManager.subscribe(item === null || item === void 0 ? void 0 : item.busSubscriber);
238
+ }
239
+ var paymentChannelMatcher = item.paymentChannelMatcher;
240
+ if (paymentChannelMatcher) {
241
+ _this2._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
242
+ }
243
+ var sessionMatcher = item.sessionMatcher;
244
+ if (sessionMatcher) {
245
+ var pluginKey = sessionMatcher.productScene + sessionMatcher.productSceneVersion + sessionMatcher.paymentMethodCategoryType;
246
+ if (sessionMatcher.paymentMethodTypes) {
247
+ sessionMatcher.paymentMethodTypes.forEach(function (paymentMethodType) {
248
+ var subPluginKey = pluginKey + paymentMethodType;
249
+ _this2._registerPlugin(subPluginKey, item.busActionNames);
250
+ });
251
+ } else {
252
+ _this2._registerPlugin(pluginKey, item.busActionNames);
253
+ }
254
+ }
255
+ var optInit = item === null || item === void 0 || (_item$busActionNames = item.busActionNames) === null || _item$busActionNames === void 0 ? void 0 : _item$busActionNames.optional_init;
256
+ if (optInit) {
257
+ BusManager.publish(new BusMessage(optInit, JSON.stringify(_this2.originOptions)));
258
+ }
259
+ });
260
+ }
261
+
262
+ /**
263
+ * To determine whether the corresponding payment method is available,
264
+ * only the channel described in the document will be called, and it will be returned as available by default
265
+ * @param paymentMethod - described in the document
266
+ * @param subPaymentMethod - described in the document
267
+ * @returns
268
+ */
269
+ }, {
270
+ key: "canMakePayments",
271
+ value: function canMakePayments(paymentMethod, subPaymentMethod) {
272
+ var _this3 = this;
273
+ // 判断支付方式是否可用
274
+ return new Promise(function (resolve) {
275
+ var _this3$_getPlugin;
276
+ if (!paymentMethod) {
277
+ return resolve(true);
278
+ }
279
+ var actionName = (_this3$_getPlugin = _this3._getPlugin(paymentMethod)) === null || _this3$_getPlugin === void 0 ? void 0 : _this3$_getPlugin.canMakePayments;
280
+ if (actionName && BusManager.isSubscribed(actionName)) {
281
+ BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
282
+ paymentMethod: paymentMethod,
283
+ subPaymentMethod: subPaymentMethod
284
+ })), {
285
+ fallback: false
286
+ }).then(function (message) {
287
+ resolve(message.getJSONObject());
288
+ }).catch(function (e) {
289
+ _this3.logger.logInfo({
290
+ title: 'canMakePayments_error'
291
+ }, {
292
+ params: JSON.stringify(e)
293
+ });
294
+ resolve(false);
295
+ });
296
+ } else {
297
+ resolve(true);
298
+ }
299
+ });
300
+ }
301
+
191
302
  /**
192
303
  * @description Create component application
193
304
  * @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.
@@ -195,7 +306,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
195
306
  }, {
196
307
  key: "createComponent",
197
308
  value: function createComponent(params) {
198
- var _this2 = this;
309
+ var _this4 = this;
199
310
  this.clearPreloadIframe();
200
311
  return this.parameterInitAndCheck({
201
312
  params: params,
@@ -203,23 +314,39 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
203
314
  }).then(function (_params) {
204
315
  return handleParams(_params);
205
316
  }).catch(function (error) {
206
- _this2.logger.logError({
317
+ _this4.logger.logError({
207
318
  title: 'sdk_error_parameter'
208
319
  }, {
209
320
  params: JSON.stringify(params)
210
321
  }).send();
211
- _this2._eventCenter.emit(EVENT.error.name, error);
322
+ _this4._eventCenter.emit(EVENT.error.name, error);
212
323
  return Promise.reject(error);
213
324
  }).then(function (appendParams) {
214
- var iframeNodesParams = appendParams.iframeNodesParams;
215
- _this2.savePreviousChannel(iframeNodesParams);
216
- return _this2.pluginAppendIframe(appendParams);
325
+ return _this4.createComponentProcess(appendParams);
217
326
  });
218
327
  }
328
+ }, {
329
+ key: "createComponentProcess",
330
+ value: function createComponentProcess(appendParams) {
331
+ var _this$getBusActionNam;
332
+ this._appendParams = appendParams;
333
+ var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.createComponent;
334
+ if (actionName && BusManager.isSubscribed(actionName)) {
335
+ // 执行出错了,在通用拦截器返回
336
+ BusManager.publish(new BusMessage(actionName, JSON.stringify({
337
+ appendParams: appendParams,
338
+ options: this.originOptions
339
+ })));
340
+ return Promise.resolve();
341
+ }
342
+ var iframeNodesParams = appendParams.iframeNodesParams;
343
+ this.savePreviousChannel(iframeNodesParams);
344
+ return this.pluginAppendIframe(appendParams);
345
+ }
219
346
  }, {
220
347
  key: "preloadComponent",
221
348
  value: function preloadComponent(channelType, productSceneVersion) {
222
- var _this3 = this;
349
+ var _this5 = this;
223
350
  this.channelType = channelType;
224
351
  this.productSceneVersion = productSceneVersion;
225
352
  var MAX_CLEAR_TIME = 10000;
@@ -235,7 +362,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
235
362
  });
236
363
  }
237
364
  setTimeout(function () {
238
- _this3.clearPreloadIframe(true);
365
+ _this5.clearPreloadIframe(true);
239
366
  }, MAX_CLEAR_TIME);
240
367
  }
241
368
  }, {
@@ -266,7 +393,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
266
393
  }, {
267
394
  key: "mountComponent",
268
395
  value: function mountComponent(params, selector) {
269
- var _this4 = this;
396
+ var _this6 = this;
270
397
  this.clearPreloadIframe();
271
398
  return this.parameterInitAndCheck({
272
399
  params: params,
@@ -275,19 +402,36 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
275
402
  }).then(function (_params) {
276
403
  return handleParams(_params);
277
404
  }).catch(function (error) {
278
- _this4.logger.logError({
405
+ _this6.logger.logError({
279
406
  title: 'sdk_error_parameter'
280
407
  }, {
281
408
  params: JSON.stringify(params)
282
409
  }).send();
283
- _this4._eventCenter.emit(EVENT.error.name, error);
410
+ _this6._eventCenter.emit(EVENT.error.name, error);
284
411
  return Promise.reject(error);
285
412
  }).then(function (appendParams) {
286
- var iframeNodesParams = appendParams.iframeNodesParams;
287
- _this4.savePreviousChannel(iframeNodesParams);
288
- return _this4.pluginAppendIframe(appendParams);
413
+ return _this6.mountComponentProcess(appendParams);
289
414
  });
290
415
  }
416
+ }, {
417
+ key: "mountComponentProcess",
418
+ value: function mountComponentProcess(appendParams) {
419
+ var _this$getBusActionNam2;
420
+ this._appendParams = appendParams;
421
+ var actionName = (_this$getBusActionNam2 = this.getBusActionNames()) === null || _this$getBusActionNam2 === void 0 ? void 0 : _this$getBusActionNam2.mountComponent;
422
+ if (actionName && BusManager.isSubscribed(actionName)) {
423
+ // 执行出错了,在通用拦截器返回
424
+ BusManager.publish(new BusMessage(actionName, JSON.stringify({
425
+ appendParams: appendParams,
426
+ options: this.originOptions
427
+ })));
428
+ return Promise.resolve();
429
+ }
430
+ var iframeNodesParams = appendParams.iframeNodesParams;
431
+ this.savePreviousChannel(iframeNodesParams);
432
+ return this.pluginAppendIframe(appendParams);
433
+ }
434
+
291
435
  /**
292
436
  * @description Execute payment submission process
293
437
  * @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
@@ -296,24 +440,37 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
296
440
  }, {
297
441
  key: "submit",
298
442
  value: function submit(data) {
299
- var _this5 = this;
443
+ var _this7 = this;
300
444
  return new Promise(function (resolve, reject) {
301
445
  try {
446
+ var _this7$getBusActionNa;
302
447
  var eventCallbackId = uuid();
303
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
304
- _this5._eventCenter.once(eventCallbackId, function (_data) {
305
- resolve(_data);
306
- });
307
- _this5._componentApp.dispatchToApp({
308
- context: {
309
- event: 'submitPay',
310
- eventCallbackId: eventCallbackId,
311
- data: data
312
- }
313
- });
314
- _this5.logger.logInfo({
448
+ _this7.logger.logInfo({
315
449
  title: 'sdk_event_apiSubmit'
316
450
  });
451
+ var actionName = (_this7$getBusActionNa = _this7.getBusActionNames()) === null || _this7$getBusActionNa === void 0 ? void 0 : _this7$getBusActionNa.submit;
452
+ if (actionName && BusManager.isSubscribed(actionName)) {
453
+ // 执行出错了,在通用拦截器返回
454
+ BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
455
+ appendParams: _this7._appendParams,
456
+ options: _this7.originOptions,
457
+ data: data
458
+ }))).then(function (busMessage) {
459
+ resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
460
+ });
461
+ } else {
462
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
463
+ _this7._eventCenter.once(eventCallbackId, function (_data) {
464
+ resolve(_data);
465
+ });
466
+ _this7._componentApp.dispatchToApp({
467
+ context: {
468
+ event: 'submitPay',
469
+ eventCallbackId: eventCallbackId,
470
+ data: data
471
+ }
472
+ });
473
+ }
317
474
  } catch (error) {
318
475
  reject(error);
319
476
  }
@@ -1,13 +1,16 @@
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;
8
+ originOptions: IoptionsParams;
7
9
  logger: Logger;
8
10
  _eventCenter: EventCenter;
9
11
  _instanceId: string;
10
12
  _storageId: string;
13
+ _appendParams: IAppendParams;
11
14
  protected securitySdkMap: Map<string, Security>;
12
15
  protected plugins: Map<string, any>;
13
16
  constructor(options: IoptionsParams);
@@ -72,4 +75,5 @@ export default class AMSSDK {
72
75
  * @description Overlay Subscription
73
76
  */
74
77
  protected _overrideSubscription(name: string, func: any, funcKey: string): void;
78
+ protected getBusActionNames(): ComponentActionNamesType;
75
79
  }
@@ -26,17 +26,21 @@ 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);
32
33
  _defineProperty(this, "options", void 0);
34
+ _defineProperty(this, "originOptions", void 0);
33
35
  _defineProperty(this, "logger", void 0);
34
36
  _defineProperty(this, "_eventCenter", void 0);
35
37
  _defineProperty(this, "_instanceId", void 0);
36
38
  _defineProperty(this, "_storageId", void 0);
39
+ _defineProperty(this, "_appendParams", void 0);
37
40
  _defineProperty(this, "securitySdkMap", void 0);
38
41
  _defineProperty(this, "plugins", void 0);
39
42
  this._instanceId = uuid();
43
+ this.originOptions = options;
40
44
  this.options = {};
41
45
  this._eventCenter = new EventCenter();
42
46
  this._initEvent(options);
@@ -101,17 +105,27 @@ var AMSSDK = /*#__PURE__*/function () {
101
105
  }, {
102
106
  key: "unmount",
103
107
  value: function unmount() {
108
+ var _this$getBusActionNam;
104
109
  this.logger.logInfo({
105
110
  title: 'sdk_event_apiOnDestroy'
106
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
+ }
107
119
  var _iterator = _createForOfIteratorHelper(this.plugins.values()),
108
120
  _step;
109
121
  try {
110
122
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
111
123
  var plugin = _step.value;
112
124
  try {
113
- plugin.logoutPlugin();
114
- // eslint-disable-next-line no-empty
125
+ if (plugin.logoutPlugin) {
126
+ plugin.logoutPlugin();
127
+ // eslint-disable-next-line no-empty
128
+ }
115
129
  } catch (error) {
116
130
  console.error(error);
117
131
  }
@@ -302,7 +316,9 @@ var AMSSDK = /*#__PURE__*/function () {
302
316
  value: function _registerPlugin(pluginId, plugin) {
303
317
  this.plugins.set(pluginId, plugin);
304
318
  try {
305
- plugin.applyPlugin(this);
319
+ if (plugin.applyPlugin) {
320
+ plugin.applyPlugin(this);
321
+ }
306
322
  } catch (error) {
307
323
  this.plugins.delete(pluginId);
308
324
  if (getType(error) === 'error') throw error;
@@ -316,7 +332,7 @@ var AMSSDK = /*#__PURE__*/function () {
316
332
  key: "_getPlugin",
317
333
  value: function _getPlugin(pluginId) {
318
334
  if (!this.plugins.has(pluginId)) {
319
- console.warn("".concat(pluginId, "Plugin unregistered"));
335
+ console.warn("".concat(pluginId, " Plugin unregistered"));
320
336
  return null;
321
337
  }
322
338
  return this.plugins.get(pluginId);
@@ -381,6 +397,27 @@ var AMSSDK = /*#__PURE__*/function () {
381
397
  this._eventCenter.off(name, func, funcKey);
382
398
  this._eventCenter.on(name, func, funcKey);
383
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
+ }
384
421
  }]);
385
422
  return AMSSDK;
386
423
  }();
package/esm/index.d.ts CHANGED
@@ -5,15 +5,12 @@
5
5
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
6
6
  * 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.
7
7
  */
8
- import ApplePayComponent from './core/applepay';
9
8
  import { AMSComponent } from './core/component/index';
10
9
  import { IoptionsParams, componentSignEnum } from './types';
11
10
  export * from './types';
12
11
  export declare class AMSCheckout extends AMSComponent {
13
12
  constructor(_options: any, channelType?: componentSignEnum[], productSceneVersion?: string);
14
13
  }
15
- export declare class AMSApplePay extends ApplePayComponent {
16
- }
17
14
  export declare class AMSAutoDebit extends AMSCheckout {
18
15
  constructor(options: IoptionsParams);
19
16
  }
package/esm/index.js CHANGED
@@ -18,7 +18,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
18
18
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
19
19
  * 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.
20
20
  */
21
- import ApplePayComponent from "./core/applepay";
22
21
  import { AMSComponent } from "./core/component/index";
23
22
  import { componentSignEnum } from "./types";
24
23
  import { productSceneEnum } from "./types/index";
@@ -38,30 +37,21 @@ export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
38
37
  }
39
38
  return _createClass(AMSCheckout);
40
39
  }(AMSComponent);
41
- export var AMSApplePay = /*#__PURE__*/function (_ApplePayComponent) {
42
- _inherits(AMSApplePay, _ApplePayComponent);
43
- var _super2 = _createSuper(AMSApplePay);
44
- function AMSApplePay() {
45
- _classCallCheck(this, AMSApplePay);
46
- return _super2.apply(this, arguments);
47
- }
48
- return _createClass(AMSApplePay);
49
- }(ApplePayComponent);
50
40
  export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
51
41
  _inherits(AMSAutoDebit, _AMSCheckout);
52
- var _super3 = _createSuper(AMSAutoDebit);
42
+ var _super2 = _createSuper(AMSAutoDebit);
53
43
  function AMSAutoDebit(options) {
54
44
  _classCallCheck(this, AMSAutoDebit);
55
45
  var _options = Object.assign({}, options, {
56
46
  product: productSceneEnum.AUTO_DEBIT
57
47
  });
58
- return _super3.call(this, _options, [componentSignEnum.AUTO_DEBIT_WALLET]);
48
+ return _super2.call(this, _options, [componentSignEnum.AUTO_DEBIT_WALLET]);
59
49
  }
60
50
  return _createClass(AMSAutoDebit);
61
51
  }(AMSCheckout);
62
52
  export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout2) {
63
53
  _inherits(AMSEasyPay, _AMSCheckout2);
64
- var _super4 = _createSuper(AMSEasyPay);
54
+ var _super3 = _createSuper(AMSEasyPay);
65
55
  function AMSEasyPay(options) {
66
56
  _classCallCheck(this, AMSEasyPay);
67
57
  var _options = Object.assign({}, options, {
@@ -86,13 +76,13 @@ export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout2) {
86
76
  error: error
87
77
  });
88
78
  }
89
- return _super4.call(this, _options, [componentSignEnum.EASY_PAY_WALLET], currentProductSceneVersion);
79
+ return _super3.call(this, _options, [componentSignEnum.EASY_PAY_WALLET], currentProductSceneVersion);
90
80
  }
91
81
  return _createClass(AMSEasyPay);
92
82
  }(AMSCheckout);
93
83
  export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
94
84
  _inherits(AMSCashierPayment, _AMSCheckout3);
95
- var _super5 = _createSuper(AMSCashierPayment);
85
+ var _super4 = _createSuper(AMSCashierPayment);
96
86
  function AMSCashierPayment(options) {
97
87
  _classCallCheck(this, AMSCashierPayment);
98
88
  var _options = Object.assign({}, options, {
@@ -117,19 +107,19 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
117
107
  error: error
118
108
  });
119
109
  }
120
- return _super5.call(this, _options, currentChannelType);
110
+ return _super4.call(this, _options, currentChannelType);
121
111
  }
122
112
  return _createClass(AMSCashierPayment);
123
113
  }(AMSCheckout);
124
114
  export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
125
115
  _inherits(AMSVaulting, _AMSCheckout4);
126
- var _super6 = _createSuper(AMSVaulting);
116
+ var _super5 = _createSuper(AMSVaulting);
127
117
  function AMSVaulting(options) {
128
118
  _classCallCheck(this, AMSVaulting);
129
119
  var _options = Object.assign({}, options, {
130
120
  product: productSceneEnum.VAULTING
131
121
  });
132
- return _super6.call(this, _options, [componentSignEnum.CASHIER_PAYMENT_CARD]);
122
+ return _super5.call(this, _options, [componentSignEnum.CASHIER_PAYMENT_CARD]);
133
123
  }
134
124
  return _createClass(AMSVaulting);
135
125
  }(AMSCheckout);
@@ -5,27 +5,46 @@
5
5
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
6
6
  * 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.
7
7
  */
8
- import { IApplePayOptionsParams } from '../../types';
9
- import CoreInstance from '../instance';
8
+ import { ApplePaySubTypeEnum, IAppendParams, IApplePayOptionsParams } from '../../types';
9
+ import type { Logger } from '../../util/logger';
10
+ export declare enum ApplePayComponentEvent {
11
+ sdk_event_appleAvailable = "sdk_event_appleAvailable",
12
+ sdk_event_appleCreateComponent = "sdk_event_appleCreateComponent",
13
+ sdk_event_appleShowPaymentSheet = "sdk_event_appleShowPaymentSheet",
14
+ sdk_event_appleOnvalidatemerchant = "sdk_event_appleOnvalidatemerchant",
15
+ sdk_event_appleSubmitToken = "sdk_event_appleSubmitToken",
16
+ sdk_event_applePaymentResult = "sdk_event_applePaymentResult",
17
+ sdk_event_appleDestoryComponent = "sdk_event_appleDestoryComponent"
18
+ }
10
19
  /**
11
20
  * Apple pay Component
12
21
  */
13
- declare class ApplePayComponent extends CoreInstance {
22
+ declare class ApplePayComponent {
14
23
  private _applePayService;
15
24
  private _parseData;
16
25
  private _sessionData;
17
26
  private _isFinish;
18
- constructor(options: IApplePayOptionsParams);
19
- private getDeviceIdAndLog;
20
- private logDeviceId;
27
+ private _options;
28
+ private logger;
29
+ private isRecurring;
30
+ constructor(options: IApplePayOptionsParams, logger: Logger);
31
+ /**
32
+ * Is Apple Pay Enabled
33
+ * @param subTypeEnum
34
+ * @returns
35
+ */
36
+ canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): boolean;
21
37
  /**
22
38
  * Is Apple Pay Enabled
39
+ * @param subTypeEnum
40
+ * @returns
23
41
  */
24
- isAppPayEnabled(): boolean;
42
+ isAppPayEnabled(subTypeEnum?: ApplePaySubTypeEnum): boolean;
43
+ private onEventCallback;
25
44
  /**
26
45
  * Submit Pay
27
46
  * @param paymentSessionData
28
47
  */
29
- submitPay(paymentSessionData: string): void;
48
+ submitPay(appendParams: IAppendParams): void;
30
49
  }
31
50
  export default ApplePayComponent;