@alipay/ams-checkout 0.0.1726734012-dev.17 → 0.0.1726734012-dev.19

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 (38) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +7 -7
  3. package/esm/config/index.js +7 -7
  4. package/esm/constant/index.d.ts +9 -0
  5. package/esm/constant/index.js +9 -0
  6. package/esm/core/component/element/index.d.ts +1 -0
  7. package/esm/core/component/element/index.js +75 -67
  8. package/esm/core/component/element/mock.d.ts +2 -0
  9. package/esm/core/component/element/mock.js +129 -53
  10. package/esm/core/component/element/type.d.ts +2 -2
  11. package/esm/core/component/element/type.js +2 -2
  12. package/esm/core/component/index.d.ts +0 -7
  13. package/esm/core/component/index.js +8 -26
  14. package/esm/core/instance/index.d.ts +1 -1
  15. package/esm/core/instance/index.js +14 -6
  16. package/esm/foundation/core/index.d.ts +0 -6
  17. package/esm/foundation/core/index.js +5 -15
  18. package/esm/foundation/index.d.ts +1 -1
  19. package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -3
  20. package/esm/foundation/product-processor/easysafepay/index.js +30 -79
  21. package/esm/foundation/service/container/index.d.ts +0 -2
  22. package/esm/foundation/service/container/index.js +46 -49
  23. package/esm/foundation/utils/payment_product_utils.d.ts +1 -1
  24. package/esm/foundation/utils/payment_product_utils.js +2 -2
  25. package/esm/foundation/utils/preload_helper.d.ts +21 -0
  26. package/esm/foundation/utils/preload_helper.js +141 -0
  27. package/esm/index.d.ts +7 -8
  28. package/esm/index.js +94 -27
  29. package/esm/plugin/applepay/interface.d.ts +2 -2
  30. package/esm/plugin/component/channel.d.ts +41 -1
  31. package/esm/plugin/component/channel.js +589 -1
  32. package/esm/plugin/component/index.d.ts +1 -1
  33. package/esm/plugin/component/index.js +75 -40
  34. package/esm/types/index.d.ts +36 -2
  35. package/esm/types/index.js +3 -2
  36. package/esm/util/cashierPaymentUtils.d.ts +1 -0
  37. package/esm/util/cashierPaymentUtils.js +15 -0
  38. package/package.json +1 -1
@@ -5,7 +5,7 @@ export declare class ProductInfoCacheUtil {
5
5
  paymentMethodCategoryType: string;
6
6
  hostSign: string;
7
7
  }): void;
8
- static getPreviousProductInfo(productScene: ProductSceneEnum, onError: (msg: string) => void): {
8
+ static getPreviousProductInfo(productScene: ProductSceneEnum): {
9
9
  productSceneVersion: string;
10
10
  paymentMethodCategoryType: string;
11
11
  hostSign: string;
@@ -21,14 +21,14 @@ export var ProductInfoCacheUtil = /*#__PURE__*/function () {
21
21
  }
22
22
  }, {
23
23
  key: "getPreviousProductInfo",
24
- value: function getPreviousProductInfo(productScene, onError) {
24
+ value: function getPreviousProductInfo(productScene) {
25
25
  var key = KEY_PREVIOUS_PRODUCT_INFO + '_' + productScene;
26
26
  var previousProductInfoString = localStorage.getItem(key);
27
27
  if (previousProductInfoString) {
28
28
  try {
29
29
  return JSON.parse(previousProductInfoString);
30
30
  } catch (error) {
31
- onError(error === null || error === void 0 ? void 0 : error.message);
31
+ return null;
32
32
  }
33
33
  }
34
34
  return null;
@@ -0,0 +1,21 @@
1
+ import { PaymentMethodCategoryTypeEnum, ProductSceneEnum } from "../../types";
2
+ import { Security } from '../../util/security';
3
+ export default class PreloadHelper {
4
+ static isWebAppPreloaded: boolean;
5
+ static isSecuritySDKPreloaded: boolean;
6
+ private static securitySdkMap;
7
+ static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
8
+ static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
9
+ static getSecuritySdk(scene: any): Security;
10
+ static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
11
+ preloadUrl: string;
12
+ containerId: string;
13
+ };
14
+ /**
15
+ * @description Obtain risk control configuration in local storage
16
+ */
17
+ static getSecurityConfigStorage(product: ProductSceneEnum): {
18
+ scene: string;
19
+ h5gateway: string;
20
+ };
21
+ }
@@ -0,0 +1,141 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import { sdkVersion } from "../../config";
9
+ import { createPreloadIframe } from "../service/container/utils";
10
+ import { ProductSceneEnum } from "../../types";
11
+ import { getWebAppUrl } from "../utils/web_app_url_utils";
12
+ import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
13
+ import { getWebAppVersion } from "./payment_context_utils";
14
+ import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
15
+ import { getOrSetStorageId, safeJson } from "../../util";
16
+ var MAX_CLEAR_TIME = 10000;
17
+ var PreloadHelper = /*#__PURE__*/function () {
18
+ function PreloadHelper() {
19
+ _classCallCheck(this, PreloadHelper);
20
+ }
21
+ _createClass(PreloadHelper, null, [{
22
+ key: "preloadWebApp",
23
+ value: function preloadWebApp(productScene, paymentMethodCategoryType) {
24
+ var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
25
+ try {
26
+ if (this.isWebAppPreloaded) {
27
+ console.log('[web-sdk] web app already preloaded');
28
+ return;
29
+ }
30
+ var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
31
+ preloadUrl = _this$buildWebAppPrel.preloadUrl,
32
+ containerId = _this$buildWebAppPrel.containerId;
33
+ var preloadIframe = createPreloadIframe(containerId);
34
+ preloadIframe.src = preloadUrl;
35
+ var body = document.body || null;
36
+ if (body) {
37
+ console.log('[web-sdk] preload web app, url: ', preloadUrl);
38
+ body.appendChild(preloadIframe);
39
+ this.isWebAppPreloaded = true;
40
+ }
41
+ setTimeout(function () {
42
+ var container = document.getElementById(containerId);
43
+ if (container) {
44
+ console.log('[web-sdk] remove preload web app');
45
+ document.body.removeChild(container);
46
+ }
47
+ }, MAX_CLEAR_TIME);
48
+ } catch (error) {
49
+ console.error('[web-sdk] preload web app failed', error);
50
+ }
51
+ }
52
+ }, {
53
+ key: "preloadSecuritySDK",
54
+ value: function preloadSecuritySDK(product) {
55
+ var _this = this;
56
+ var securityRegion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'SG';
57
+ try {
58
+ if (this.isSecuritySDKPreloaded) {
59
+ console.log('[web-sdk] security sdk is already loaded');
60
+ return;
61
+ }
62
+ var storage = PreloadHelper.getSecurityConfigStorage(product);
63
+ var scene = storage.scene || getSecurityScene(product);
64
+ var h5gateway = storage.h5gateway || getSecurityHost(securityRegion);
65
+ var securitySdk = new Security({
66
+ scene: scene,
67
+ h5gateway: h5gateway
68
+ });
69
+ debugger;
70
+ securitySdk.initSecurity(function () {
71
+ _this.securitySdkMap.set(scene, securitySdk);
72
+ _this.isSecuritySDKPreloaded = true;
73
+ console.log('[web-sdk] preload security sdk succeed');
74
+ }, function () {
75
+ console.error('[web-sdk] preload security sdk failed');
76
+ });
77
+ } catch (error) {
78
+ console.error('[web-sdk] preload security sdk failed', error);
79
+ }
80
+ }
81
+ }, {
82
+ key: "getSecuritySdk",
83
+ value: function getSecuritySdk(scene) {
84
+ var result = this.securitySdkMap.get(scene);
85
+ return result;
86
+ }
87
+ }, {
88
+ key: "buildWebAppPreloadUrl",
89
+ value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
90
+ var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
91
+ var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
92
+ if (previousProductInfo) {
93
+ productSceneVersion = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.productSceneVersion;
94
+ }
95
+ var containerId = "ams-checkout-component-".concat(productScene, "_").concat(paymentMethodCategoryType);
96
+ var sdkMetaData = {
97
+ productScene: productScene,
98
+ sdkVersion: sdkVersion,
99
+ webAppVersion: ''
100
+ };
101
+ sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
102
+ var preloadUrl = getWebAppUrl({
103
+ environment: environment,
104
+ sdkMetaData: sdkMetaData,
105
+ paymentMethodCategoryType: paymentMethodCategoryType,
106
+ isPreload: true,
107
+ productSceneVersion: productSceneVersion,
108
+ query: undefined
109
+ });
110
+ return {
111
+ preloadUrl: preloadUrl,
112
+ containerId: containerId
113
+ };
114
+ }
115
+
116
+ /**
117
+ * @description Obtain risk control configuration in local storage
118
+ */
119
+ }, {
120
+ key: "getSecurityConfigStorage",
121
+ value: function getSecurityConfigStorage(product) {
122
+ var scene = '';
123
+ var h5gateway = '';
124
+ var securityConfigStorage = getOrSetStorageId(getSecurityConfigStorageKey(product));
125
+ if (securityConfigStorage) {
126
+ var config = safeJson(securityConfigStorage, {});
127
+ scene = config === null || config === void 0 ? void 0 : config.appName;
128
+ h5gateway = config === null || config === void 0 ? void 0 : config.h5gateway;
129
+ }
130
+ return {
131
+ scene: scene,
132
+ h5gateway: h5gateway
133
+ };
134
+ }
135
+ }]);
136
+ return PreloadHelper;
137
+ }();
138
+ _defineProperty(PreloadHelper, "isWebAppPreloaded", false);
139
+ _defineProperty(PreloadHelper, "isSecuritySDKPreloaded", false);
140
+ _defineProperty(PreloadHelper, "securitySdkMap", new Map());
141
+ export { PreloadHelper as default };
package/esm/index.d.ts CHANGED
@@ -1,28 +1,27 @@
1
1
  import { AddressComponent } from './core/component/address';
2
2
  import { ElementComponent } from './core/component/element';
3
3
  import { AMSComponent } from './core/component/index';
4
- import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams } from './types';
4
+ import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
5
5
  export { AMSCheckoutPage } from './core/component/ckp';
6
6
  export * from './types';
7
7
  export declare class AMSCheckout extends AMSComponent {
8
8
  constructor(_options: IoptionsParams, channelType?: ComponentSignEnum[], productSceneVersion?: string);
9
- static preload(_options: {
10
- channelType: ComponentSignEnum[];
11
- productSceneVersion: string;
12
- securityRegion?: 'US' | 'SG' | 'DE';
13
- }): void;
14
9
  }
15
10
  export declare class AMSAutoDebit extends AMSCheckout {
16
11
  constructor(options: IoptionsParams);
12
+ static preload(options?: IPreloadOptions): void;
17
13
  }
18
14
  export declare class AMSAutoDebitPay extends AMSCheckout {
19
15
  constructor(options: IoptionsParams);
16
+ static preload(options?: IPreloadOptions): void;
20
17
  }
21
18
  export declare class AMSCashierPayment extends AMSCheckout {
22
19
  constructor(options: IoptionsParams);
20
+ static preload(options?: IPreloadOptions): void;
23
21
  }
24
22
  export declare class AMSVaulting extends AMSCheckout {
25
23
  constructor(options: IoptionsParams);
24
+ static preload(options?: IPreloadOptions): void;
26
25
  }
27
26
  export declare class AntomElement extends AMSCheckout {
28
27
  constructor(options: IoptionsParams);
@@ -33,11 +32,11 @@ export declare class AddressElement extends AddressComponent {
33
32
  export declare class Element extends ElementComponent {
34
33
  constructor(options: IElementOptions);
35
34
  }
36
- export default AMSCheckout;
37
35
  export declare class AMSEasyPay {
38
36
  private core;
39
37
  constructor(options: IoptionsParams);
40
- static preload(options: IoptionsParams): void;
38
+ static preload(options?: IPreloadOptions): void;
41
39
  createComponent(params: IcreateComponent): void;
42
40
  unmount(): void;
43
41
  }
42
+ export default AMSCheckout;
package/esm/index.js CHANGED
@@ -1,12 +1,15 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
2
5
  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
6
  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; }
4
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
8
  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); } }
7
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
10
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
11
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
13
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
14
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
15
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -25,15 +28,15 @@ import { ADDRESSElementAppVersion, AMSAutoDebitAppVersion, AMSCashierPaymentAppV
25
28
  import { AddressComponent } from "./core/component/address";
26
29
  import { ElementComponent } from "./core/component/element";
27
30
  import { AMSComponent } from "./core/component/index";
28
- import { ComponentSignEnum, DisplayTypeEnum } from "./types";
31
+ import { ComponentSignEnum, DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from "./types";
29
32
  import { ProductSceneEnum } from "./types/index";
30
33
  import { LogConfig, Logger } from "./util/logger";
34
+ import PreloadHelper from "./foundation/utils/preload_helper";
31
35
  var logger = new Logger(LogConfig, true);
32
36
  export { AMSCheckoutPage } from "./core/component/ckp";
33
37
  export * from "./types";
34
38
  import { AntomSDKCore } from "./foundation/core";
35
39
  import { EasySafePayProcessor } from "./foundation/product-processor/easysafepay";
36
- import { uuid } from "./foundation/product-processor/easysafepay/deps";
37
40
  export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
38
41
  _inherits(AMSCheckout, _AMSComponent);
39
42
  var _super = _createSuper(AMSCheckout);
@@ -44,21 +47,10 @@ export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
44
47
  _this = _super.call(this, _objectSpread({
45
48
  appVersion: AMSCheckoutAppVersion
46
49
  }, _options));
47
- if (!AMSComponent.isSuccessfullyPreloaded) {
48
- _this.preloadComponent(channelType, productSceneVersion);
49
- }
50
+ _this.preloadComponent(channelType, productSceneVersion);
50
51
  return _this;
51
52
  }
52
- _createClass(AMSCheckout, null, [{
53
- key: "preload",
54
- value: function preload(_options) {
55
- AMSComponent.isSuccessfullyPreloaded = true;
56
- AMSComponent.preload(_objectSpread(_objectSpread({}, _options), {}, {
57
- appVersion: AMSCheckoutAppVersion
58
- }));
59
- }
60
- }]);
61
- return AMSCheckout;
53
+ return _createClass(AMSCheckout);
62
54
  }(AMSComponent);
63
55
  export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
64
56
  _inherits(AMSAutoDebit, _AMSCheckout);
@@ -71,7 +63,18 @@ export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
71
63
  });
72
64
  return _super2.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_WALLET]);
73
65
  }
74
- return _createClass(AMSAutoDebit);
66
+ _createClass(AMSAutoDebit, null, [{
67
+ key: "preload",
68
+ value: function preload() {
69
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
70
+ securityRegion: 'SG',
71
+ environment: 'prod'
72
+ };
73
+ PreloadHelper.preloadWebApp(ProductSceneEnum.AUTO_DEBIT, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
74
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.AUTO_DEBIT, options.securityRegion);
75
+ }
76
+ }]);
77
+ return AMSAutoDebit;
75
78
  }(AMSCheckout);
76
79
  export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
77
80
  _inherits(AMSAutoDebitPay, _AMSCheckout2);
@@ -83,7 +86,18 @@ export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
83
86
  });
84
87
  return _super3.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_PAY_WALLET]);
85
88
  }
86
- return _createClass(AMSAutoDebitPay);
89
+ _createClass(AMSAutoDebitPay, null, [{
90
+ key: "preload",
91
+ value: function preload() {
92
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
93
+ securityRegion: 'SG',
94
+ environment: 'prod'
95
+ };
96
+ PreloadHelper.preloadWebApp(ProductSceneEnum.AUTO_DEBIT_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
97
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.AUTO_DEBIT_PAY, options.securityRegion);
98
+ }
99
+ }]);
100
+ return AMSAutoDebitPay;
87
101
  }(AMSCheckout);
88
102
  export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
89
103
  _inherits(AMSCashierPayment, _AMSCheckout3);
@@ -115,7 +129,48 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
115
129
  }
116
130
  return _super4.call(this, _options, currentChannelType);
117
131
  }
118
- return _createClass(AMSCashierPayment);
132
+ _createClass(AMSCashierPayment, null, [{
133
+ key: "preload",
134
+ value: function preload() {
135
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
136
+ securityRegion: 'SG',
137
+ environment: 'prod'
138
+ };
139
+ try {
140
+ var channelTypes;
141
+ var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
142
+ var previousChannel = JSON.parse(previousChannelStr) || {};
143
+ var _ref2 = previousChannel || {},
144
+ _ref2$channelType = _ref2.channelType,
145
+ channelType = _ref2$channelType === void 0 ? '' : _ref2$channelType;
146
+ if (ComponentSignEnum.CASHIER_PAYMENT_CARD === channelType) {
147
+ channelTypes = [PaymentMethodCategoryTypeEnum.CARD];
148
+ } else if (ComponentSignEnum.CASHIER_PAYMENT_APM === channelType) {
149
+ channelTypes = [PaymentMethodCategoryTypeEnum.APM];
150
+ } else if (ComponentSignEnum.CASHIER_PAYMENT_BANK === channelType) {
151
+ channelTypes = [PaymentMethodCategoryTypeEnum.BANK];
152
+ } else {
153
+ channelTypes = [PaymentMethodCategoryTypeEnum.CARD, PaymentMethodCategoryTypeEnum.APM];
154
+ }
155
+ var _iterator = _createForOfIteratorHelper(channelTypes),
156
+ _step;
157
+ try {
158
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
159
+ var _channelType = _step.value;
160
+ PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, _channelType, options.environment);
161
+ }
162
+ } catch (err) {
163
+ _iterator.e(err);
164
+ } finally {
165
+ _iterator.f();
166
+ }
167
+ } catch (error) {
168
+ console.error('[web-sdk] preload web app error', error);
169
+ }
170
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.CASHIER_PAYMENT, options.securityRegion);
171
+ }
172
+ }]);
173
+ return AMSCashierPayment;
119
174
  }(AMSCheckout);
120
175
  export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
121
176
  _inherits(AMSVaulting, _AMSCheckout4);
@@ -128,7 +183,18 @@ export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
128
183
  });
129
184
  return _super5.call(this, _options, [ComponentSignEnum.CASHIER_PAYMENT_CARD]);
130
185
  }
131
- return _createClass(AMSVaulting);
186
+ _createClass(AMSVaulting, null, [{
187
+ key: "preload",
188
+ value: function preload() {
189
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
190
+ securityRegion: 'SG',
191
+ environment: 'prod'
192
+ };
193
+ PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, PaymentMethodCategoryTypeEnum.CARD, options.environment);
194
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.VAULTING, options.securityRegion);
195
+ }
196
+ }]);
197
+ return AMSVaulting;
132
198
  }(AMSCheckout);
133
199
  export var AntomElement = /*#__PURE__*/function (_AMSCheckout5) {
134
200
  _inherits(AntomElement, _AMSCheckout5);
@@ -169,7 +235,6 @@ export var Element = /*#__PURE__*/function (_ElementComponent) {
169
235
  }
170
236
  return _createClass(Element);
171
237
  }(ElementComponent);
172
- export default AMSCheckout;
173
238
  export var AMSEasyPay = /*#__PURE__*/function () {
174
239
  function AMSEasyPay(options) {
175
240
  _classCallCheck(this, AMSEasyPay);
@@ -200,12 +265,14 @@ export var AMSEasyPay = /*#__PURE__*/function () {
200
265
  }
201
266
  }], [{
202
267
  key: "preload",
203
- value: function preload(options) {
204
- var core = new AntomSDKCore();
205
- var instanceId = uuid();
206
- var SDkMetaData = core.transferEasyPaySDKVersion();
207
- EasySafePayProcessor.preloadWebApp(options, instanceId, SDkMetaData);
268
+ value: function preload() {
269
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
270
+ securityRegion: 'SG',
271
+ environment: 'prod'
272
+ };
273
+ PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
208
274
  }
209
275
  }]);
210
276
  return AMSEasyPay;
211
- }();
277
+ }();
278
+ export default AMSCheckout;
@@ -37,8 +37,8 @@ export interface IApplePayPaymentContact {
37
37
  countryCode: string;
38
38
  }
39
39
  export type IApplePayLineItemType = 'final' | 'pending';
40
- export type ApplePayPaymentTiming = "immediate" | "recurring" | "deferred" | "automaticReload";
41
- export type ApplePayRecurringPaymentDateUnit = "year" | "month" | "day" | "hour" | "minute";
40
+ export type ApplePayPaymentTiming = 'immediate' | 'recurring' | 'deferred' | 'automaticReload';
41
+ export type ApplePayRecurringPaymentDateUnit = 'year' | 'month' | 'day' | 'hour' | 'minute';
42
42
  /**
43
43
  *
44
44
  {
@@ -1,4 +1,5 @@
1
- import type { EventPayload, IPaymentSessionMetaData } from '../../types';
1
+ import { EventPayloadContext, type EventPayload, type IPaymentMethod, type IPaymentSessionMetaData } from '../../types';
2
+ import { Logger } from '../../util/logger';
2
3
  export type IChannelBehavior = {
3
4
  usePaymentSessionAsQueryResult: boolean;
4
5
  submitPayInSdk: boolean;
@@ -18,4 +19,43 @@ type GetDoubleFaParams = {
18
19
  export declare function getChannelBehavior(paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
19
20
  export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
20
21
  export declare const handleGooglePay: (data: EventPayload) => Promise<unknown>;
22
+ export declare class ApplePayService {
23
+ private APPLESDKURL;
24
+ private applePaySession;
25
+ private paymentSessionData;
26
+ private sessionResult;
27
+ /**
28
+ * @description 支付状态,pending:支付中,normal:正常
29
+ */
30
+ private paymentStatus;
31
+ /**
32
+ * @description paymentRequest
33
+ */
34
+ private paymentRequest;
35
+ private logger;
36
+ private dispatchToApp;
37
+ private paymentMethod;
38
+ constructor({ sessionData, paymentSessionMetaData, paymentMethod, logger, dispatchToApp, }: {
39
+ sessionData: string;
40
+ paymentSessionMetaData: IPaymentSessionMetaData;
41
+ paymentMethod: IPaymentMethod;
42
+ logger: Logger;
43
+ dispatchToApp: (payload: {
44
+ context: EventPayloadContext;
45
+ }) => void;
46
+ });
47
+ private startPay;
48
+ private setApplePayStatus;
49
+ private submitPay;
50
+ submit(): Promise<void>;
51
+ private getDeviceId;
52
+ private initApplePaySession;
53
+ private isCanMakePayments;
54
+ private loadApplePaySdk;
55
+ private abortPaySession;
56
+ private addEventListener;
57
+ private get initSessionParams();
58
+ private get isRequiredParameters();
59
+ private get checkScriptIsLoaded();
60
+ }
21
61
  export {};