@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730107332-dev.40

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 (122) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +2 -3
  3. package/esm/component/channel.js +63 -29
  4. package/esm/component/component.inline.style.js +1 -1
  5. package/esm/component/component.popup.style.d.ts +1 -3
  6. package/esm/component/component.popup.style.js +1 -3
  7. package/esm/config/index.d.ts +7 -7
  8. package/esm/config/index.js +10 -10
  9. package/esm/constant/index.d.ts +3 -0
  10. package/esm/constant/index.js +3 -0
  11. package/esm/core/bus/ability/callback.d.ts +9 -0
  12. package/esm/core/bus/ability/callback.js +55 -0
  13. package/esm/core/bus/ability/security.d.ts +10 -0
  14. package/esm/core/bus/ability/security.js +104 -0
  15. package/esm/core/bus/ability/tracker.d.ts +9 -0
  16. package/esm/core/bus/ability/tracker.js +77 -0
  17. package/esm/core/bus/index.d.ts +125 -0
  18. package/esm/core/bus/index.js +366 -0
  19. package/esm/core/bus/interface.d.ts +36 -0
  20. package/esm/core/bus/interface.js +40 -0
  21. package/esm/core/component/address.d.ts +8 -0
  22. package/esm/core/component/address.js +72 -0
  23. package/esm/core/component/appPreloadProcessing.d.ts +1 -0
  24. package/esm/core/component/appPreloadProcessing.js +89 -0
  25. package/esm/core/component/ckp/index.d.ts +27 -0
  26. package/esm/core/component/ckp/index.js +167 -0
  27. package/esm/core/component/element/components/address.d.ts +19 -0
  28. package/esm/core/component/element/components/address.js +68 -0
  29. package/esm/core/component/element/components/auth.d.ts +17 -0
  30. package/esm/core/component/element/components/auth.js +60 -0
  31. package/esm/core/component/element/components/payment.d.ts +19 -0
  32. package/esm/core/component/element/components/payment.js +74 -0
  33. package/esm/core/component/element/index.d.ts +47 -0
  34. package/esm/core/component/element/index.js +816 -0
  35. package/esm/core/component/element/mock.d.ts +4 -0
  36. package/esm/core/component/element/mock.js +491 -0
  37. package/esm/core/component/element/type.d.ts +190 -0
  38. package/esm/core/component/element/type.js +35 -0
  39. package/esm/core/component/element/utils.d.ts +13 -0
  40. package/esm/core/component/element/utils.js +6 -0
  41. package/esm/core/component/index.d.ts +51 -0
  42. package/esm/core/component/index.js +531 -0
  43. package/esm/core/drop-in/index.d.ts +22 -0
  44. package/esm/core/drop-in/index.js +104 -0
  45. package/esm/core/instance/index.d.ts +89 -0
  46. package/esm/core/instance/index.js +499 -0
  47. package/esm/foundation/core/index.d.ts +3 -3
  48. package/esm/foundation/core/index.js +10 -8
  49. package/esm/foundation/index.d.ts +6 -5
  50. package/esm/foundation/product-processor/easysafepay/deps.d.ts +6 -6
  51. package/esm/foundation/product-processor/easysafepay/deps.js +4 -4
  52. package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -3
  53. package/esm/foundation/product-processor/easysafepay/index.js +110 -243
  54. package/esm/foundation/service/api-bus/index.d.ts +2 -2
  55. package/esm/foundation/service/container/index.d.ts +4 -2
  56. package/esm/foundation/service/container/index.js +43 -1
  57. package/esm/foundation/service/event-center.d.ts +6 -4
  58. package/esm/foundation/service/event-center.js +47 -17
  59. package/esm/foundation/service/global-data/index.d.ts +2 -2
  60. package/esm/foundation/service/index.d.ts +2 -2
  61. package/esm/foundation/service/log/index.d.ts +2 -2
  62. package/esm/foundation/service/log/index.js +1 -1
  63. package/esm/foundation/service/requester/deps.d.ts +1 -1
  64. package/esm/foundation/service/requester/requester.d.ts +2 -2
  65. package/esm/foundation/service/security/index.d.ts +2 -2
  66. package/esm/foundation/service/security/index.js +1 -0
  67. package/esm/foundation/utils/redirect_utils.d.ts +5 -0
  68. package/esm/foundation/utils/redirect_utils.js +205 -58
  69. package/esm/foundation/utils/system_events.js +0 -5
  70. package/esm/foundation/utils/web_app_url_utils.js +1 -1
  71. package/esm/index.d.ts +31 -2
  72. package/esm/index.js +146 -6
  73. package/esm/plugin/applepay/component.d.ts +50 -0
  74. package/esm/plugin/applepay/component.js +339 -0
  75. package/esm/plugin/applepay/index.d.ts +17 -0
  76. package/esm/plugin/applepay/index.js +117 -0
  77. package/esm/plugin/applepay/interface.d.ts +161 -0
  78. package/esm/plugin/applepay/interface.js +69 -0
  79. package/esm/plugin/applepay/service.d.ts +54 -0
  80. package/esm/plugin/applepay/service.js +289 -0
  81. package/esm/plugin/component/cashierApp.d.ts +36 -0
  82. package/esm/plugin/component/cashierApp.js +244 -0
  83. package/esm/plugin/component/channel.d.ts +21 -0
  84. package/esm/plugin/component/channel.js +89 -0
  85. package/esm/plugin/component/component.inline.style.d.ts +10 -0
  86. package/esm/plugin/component/component.inline.style.js +121 -0
  87. package/esm/plugin/component/component.popup.style.d.ts +16 -0
  88. package/esm/plugin/component/component.popup.style.js +174 -0
  89. package/esm/plugin/component/index.d.ts +127 -0
  90. package/esm/plugin/component/index.js +1896 -0
  91. package/esm/plugin/component/popupWindow.style.d.ts +11 -0
  92. package/esm/plugin/component/popupWindow.style.js +121 -0
  93. package/esm/plugin/const.d.ts +2 -0
  94. package/esm/plugin/const.js +33 -0
  95. package/esm/plugin/drop-in/index.d.ts +71 -0
  96. package/esm/plugin/drop-in/index.js +324 -0
  97. package/esm/plugin/payment-element/utils.d.ts +2 -0
  98. package/esm/plugin/payment-element/utils.js +6 -0
  99. package/esm/plugin/paypal/index.d.ts +20 -0
  100. package/esm/plugin/paypal/index.js +390 -0
  101. package/esm/plugin/type.d.ts +34 -0
  102. package/esm/plugin/type.js +1 -0
  103. package/esm/plugin/utils.d.ts +6 -0
  104. package/esm/plugin/utils.js +21 -0
  105. package/esm/service/element.d.ts +4 -0
  106. package/esm/service/element.js +51 -0
  107. package/esm/service/index.d.ts +1 -0
  108. package/esm/service/index.js +2 -0
  109. package/esm/types/index.d.ts +228 -26
  110. package/esm/types/index.js +54 -5
  111. package/esm/util/createIframeNode.d.ts +6 -0
  112. package/esm/util/createIframeNode.js +48 -0
  113. package/esm/util/getBackScheme.d.ts +2 -2
  114. package/esm/util/getBackScheme.js +2 -2
  115. package/esm/util/index.d.ts +11 -1
  116. package/esm/util/index.js +84 -3
  117. package/esm/util/intl-callapp/es/index.js +0 -1
  118. package/esm/util/security.d.ts +33 -0
  119. package/esm/util/security.js +182 -0
  120. package/package.json +2 -1
  121. package/esm/foundation/types/index.d.ts +0 -4
  122. package/esm/foundation/types/index.js +0 -4
@@ -22,9 +22,6 @@ export var registerSystemEvents = function registerSystemEvents(eventCenter) {
22
22
  form.submit();
23
23
  }, 0);
24
24
  };
25
- var handleHeartBeat = function handleHeartBeat(data) {
26
- // TODO:
27
- };
28
25
  var handleBeforeSubmit = function handleBeforeSubmit(data) {
29
26
  if (eventCenter.isExist(EVENT.beforeSubmit.name)) {
30
27
  eventCenter.emit(EVENT.beforeSubmit.name, data);
@@ -52,7 +49,6 @@ export var registerSystemEvents = function registerSystemEvents(eventCenter) {
52
49
  });
53
50
  };
54
51
  eventCenter.listen(EVENT.submitForm.name, handleSubmitForm);
55
- eventCenter.listen(EVENT.appHeartBeat.name, handleHeartBeat);
56
52
  eventCenter.listen(EVENT.beforeSubmit.name, handleBeforeSubmit);
57
53
  eventCenter.listen(EVENT.sendBroadcast.name, handleSendBroadcast);
58
54
  // deprecated
@@ -60,7 +56,6 @@ export var registerSystemEvents = function registerSystemEvents(eventCenter) {
60
56
  };
61
57
  export var unRegisterSystemEvents = function unRegisterSystemEvents(eventCenter) {
62
58
  eventCenter.unlisten(EVENT.submitForm.name);
63
- eventCenter.unlisten(EVENT.appHeartBeat.name);
64
59
  eventCenter.unlisten(EVENT.beforeSubmit.name);
65
60
  eventCenter.unlisten(EVENT.sendBroadcast.name);
66
61
  eventCenter.unlisten(EVENT.sendMuitiAppEventToSdk.name);
@@ -98,7 +98,7 @@ export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo)
98
98
  };
99
99
  var getValidProductSceneVersion = function getValidProductSceneVersion(productScene, productSceneVer, paymentMethodCategoryType) {
100
100
  var _supportMapping;
101
- var supportMapping = (_supportMapping = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.NONE, ['']), ComponentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), ComponentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), ComponentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), ComponentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), ComponentSignEnum.EASY_PAY_APM, ['2.0']), ComponentSignEnum.VAULTING_CARD, ['1.0']), ComponentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_supportMapping, ComponentSignEnum.ELEMENT_ADDRESS, ['1.0']));
101
+ var supportMapping = (_supportMapping = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.NONE, ['']), ComponentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), ComponentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), ComponentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), ComponentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), ComponentSignEnum.EASY_PAY_APM, ['2.0']), ComponentSignEnum.VAULTING_CARD, ['1.0']), ComponentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.ELEMENT_ADDRESS, ['1.0']), ComponentSignEnum.CHECKOUT_PAYMENT, ['1.0']));
102
102
  var targetVersions = supportMapping[productScene + '_' + paymentMethodCategoryType];
103
103
  if (!targetVersions) {
104
104
  return '';
package/esm/index.d.ts CHANGED
@@ -1,7 +1,36 @@
1
- import { IcreateComponent, IOptionsParams } from './types';
1
+ import { AddressComponent } from './core/component/address';
2
+ import { ElementComponent } from './core/component/element';
3
+ import { AMSComponent } from './core/component/index';
4
+ import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams } from './types';
5
+ export { AMSCheckoutPage } from './core/component/ckp';
2
6
  export * from './types';
7
+ export declare class AMSCheckout extends AMSComponent {
8
+ constructor(_options: IoptionsParams, channelType?: ComponentSignEnum[], productSceneVersion?: string);
9
+ }
10
+ export declare class AMSAutoDebit extends AMSCheckout {
11
+ constructor(options: IoptionsParams);
12
+ }
13
+ export declare class AMSAutoDebitPay extends AMSCheckout {
14
+ constructor(options: IoptionsParams);
15
+ }
16
+ export declare class AMSCashierPayment extends AMSCheckout {
17
+ constructor(options: IoptionsParams);
18
+ }
19
+ export declare class AMSVaulting extends AMSCheckout {
20
+ constructor(options: IoptionsParams);
21
+ }
22
+ export declare class AntomElement extends AMSCheckout {
23
+ constructor(options: IoptionsParams);
24
+ }
25
+ export declare class AddressElement extends AddressComponent {
26
+ constructor(options: IoptionsAddressParams);
27
+ }
28
+ export declare class Element extends ElementComponent {
29
+ constructor(options: IElementOptions);
30
+ }
31
+ export default AMSCheckout;
3
32
  export declare class AMSEasyPay {
4
33
  private core;
5
- constructor(options: IOptionsParams);
34
+ constructor(options: IoptionsParams);
6
35
  createComponent(params: IcreateComponent): void;
7
36
  }
package/esm/index.js CHANGED
@@ -1,10 +1,19 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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; }
4
+ 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; }
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; }
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
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
8
  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); }
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+ 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
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
+ 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); }; }
13
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
14
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
8
17
  /**
9
18
  * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
10
19
  *
@@ -12,12 +21,143 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
12
21
  * 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
13
22
  * 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.
14
23
  */
15
-
16
- import { AntomSDKCore } from "./foundation/core";
17
- import { EasySafePayProcessor } from "./foundation/product-processor/easysafepay";
18
- import { DisplayTypeEnum } from "./types";
24
+ import { ADDRESSElementAppVersion, AMSAutoDebitAppVersion, AMSCashierPaymentAppVersion, AMSCheckoutAppVersion, AMSPaymentElementAppVersion, AMSVaultingAppVersion } from "./config/index";
25
+ import { AddressComponent } from "./core/component/address";
26
+ import { ElementComponent } from "./core/component/element";
27
+ import { AMSComponent } from "./core/component/index";
28
+ import { ComponentSignEnum, DisplayTypeEnum } from "./types";
19
29
  import { ProductSceneEnum } from "./types/index";
30
+ import { LogConfig, Logger } from "./util/logger";
31
+ var logger = new Logger(LogConfig, true);
32
+ export { AMSCheckoutPage } from "./core/component/ckp";
20
33
  export * from "./types";
34
+ import { AntomSDKCore } from "./foundation/core";
35
+ import { EasySafePayProcessor } from "./foundation/product-processor/easysafepay";
36
+ export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
37
+ _inherits(AMSCheckout, _AMSComponent);
38
+ var _super = _createSuper(AMSCheckout);
39
+ function AMSCheckout(_options, channelType) {
40
+ var _this;
41
+ var productSceneVersion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '1.0';
42
+ _classCallCheck(this, AMSCheckout);
43
+ _this = _super.call(this, _objectSpread({
44
+ appVersion: AMSCheckoutAppVersion
45
+ }, _options));
46
+ _this.preloadComponent(channelType, productSceneVersion);
47
+ return _this;
48
+ }
49
+ return _createClass(AMSCheckout);
50
+ }(AMSComponent);
51
+ export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
52
+ _inherits(AMSAutoDebit, _AMSCheckout);
53
+ var _super2 = _createSuper(AMSAutoDebit);
54
+ function AMSAutoDebit(options) {
55
+ _classCallCheck(this, AMSAutoDebit);
56
+ var _options = Object.assign({}, options, {
57
+ product: ProductSceneEnum.AUTO_DEBIT,
58
+ appVersion: AMSAutoDebitAppVersion
59
+ });
60
+ return _super2.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_WALLET]);
61
+ }
62
+ return _createClass(AMSAutoDebit);
63
+ }(AMSCheckout);
64
+ export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
65
+ _inherits(AMSAutoDebitPay, _AMSCheckout2);
66
+ var _super3 = _createSuper(AMSAutoDebitPay);
67
+ function AMSAutoDebitPay(options) {
68
+ _classCallCheck(this, AMSAutoDebitPay);
69
+ var _options = Object.assign({}, options, {
70
+ product: ProductSceneEnum.AUTO_DEBIT_PAY
71
+ });
72
+ return _super3.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_PAY_WALLET]);
73
+ }
74
+ return _createClass(AMSAutoDebitPay);
75
+ }(AMSCheckout);
76
+ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
77
+ _inherits(AMSCashierPayment, _AMSCheckout3);
78
+ var _super4 = _createSuper(AMSCashierPayment);
79
+ function AMSCashierPayment(options) {
80
+ _classCallCheck(this, AMSCashierPayment);
81
+ var _options = Object.assign({}, options, {
82
+ product: ProductSceneEnum.CASHIER_PAYMENT,
83
+ appVersion: AMSCashierPaymentAppVersion
84
+ });
85
+ var currentChannelType;
86
+ try {
87
+ var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
88
+ var previousChannel = JSON.parse(previousChannelStr) || {};
89
+ var _ref = previousChannel || {},
90
+ _ref$channelType = _ref.channelType,
91
+ channelType = _ref$channelType === void 0 ? '' : _ref$channelType;
92
+ if ([ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM, ComponentSignEnum.CASHIER_PAYMENT_BANK].includes(channelType)) {
93
+ currentChannelType = [channelType];
94
+ } else {
95
+ currentChannelType = [ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM];
96
+ }
97
+ } catch (error) {
98
+ logger.logError({
99
+ title: 'performance_optimization_get_previousChannel_error'
100
+ }, {
101
+ error: error
102
+ });
103
+ }
104
+ return _super4.call(this, _options, currentChannelType);
105
+ }
106
+ return _createClass(AMSCashierPayment);
107
+ }(AMSCheckout);
108
+ export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
109
+ _inherits(AMSVaulting, _AMSCheckout4);
110
+ var _super5 = _createSuper(AMSVaulting);
111
+ function AMSVaulting(options) {
112
+ _classCallCheck(this, AMSVaulting);
113
+ var _options = Object.assign({}, options, {
114
+ product: ProductSceneEnum.VAULTING,
115
+ appVersion: AMSVaultingAppVersion
116
+ });
117
+ return _super5.call(this, _options, [ComponentSignEnum.CASHIER_PAYMENT_CARD]);
118
+ }
119
+ return _createClass(AMSVaulting);
120
+ }(AMSCheckout);
121
+ export var AntomElement = /*#__PURE__*/function (_AMSCheckout5) {
122
+ _inherits(AntomElement, _AMSCheckout5);
123
+ var _super6 = _createSuper(AntomElement);
124
+ function AntomElement(options) {
125
+ _classCallCheck(this, AntomElement);
126
+ var _options = Object.assign({}, options, {
127
+ product: ProductSceneEnum.ELEMENT_PAYMENT,
128
+ appVersion: AMSPaymentElementAppVersion
129
+ });
130
+ return _super6.call(this, _options, [ComponentSignEnum.ELEMENT_PAYMENT]);
131
+ }
132
+ return _createClass(AntomElement);
133
+ }(AMSCheckout);
134
+ export var AddressElement = /*#__PURE__*/function (_AddressComponent) {
135
+ _inherits(AddressElement, _AddressComponent);
136
+ var _super7 = _createSuper(AddressElement);
137
+ function AddressElement(options) {
138
+ _classCallCheck(this, AddressElement);
139
+ var _options = Object.assign({}, options, {
140
+ product: ProductSceneEnum.ELEMENT_ADDRESS,
141
+ appVersion: ADDRESSElementAppVersion
142
+ });
143
+ return _super7.call(this, _options);
144
+ }
145
+ return _createClass(AddressElement);
146
+ }(AddressComponent);
147
+ export var Element = /*#__PURE__*/function (_ElementComponent) {
148
+ _inherits(Element, _ElementComponent);
149
+ var _super8 = _createSuper(Element);
150
+ function Element(options) {
151
+ _classCallCheck(this, Element);
152
+ var _options = Object.assign({}, options, {
153
+ product: ProductSceneEnum.ELEMENT_PAYMENT,
154
+ environment: options.environment
155
+ });
156
+ return _super8.call(this, _options);
157
+ }
158
+ return _createClass(Element);
159
+ }(ElementComponent);
160
+ export default AMSCheckout;
21
161
  export var AMSEasyPay = /*#__PURE__*/function () {
22
162
  function AMSEasyPay(options) {
23
163
  _classCallCheck(this, AMSEasyPay);
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
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
+ * 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
+ */
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_appleDestroyComponent = "sdk_event_appleDestroyComponent"
18
+ }
19
+ /**
20
+ * Apple pay Component
21
+ */
22
+ declare class ApplePayComponent {
23
+ private _applePayService;
24
+ private _parseData;
25
+ private _sessionData;
26
+ private _isFinish;
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;
37
+ /**
38
+ * Is Apple Pay Enabled
39
+ * @param subTypeEnum
40
+ * @returns
41
+ */
42
+ isAppPayEnabled(subTypeEnum?: ApplePaySubTypeEnum): boolean;
43
+ private onEventCallback;
44
+ /**
45
+ * Submit Pay
46
+ * @param paymentSessionData
47
+ */
48
+ submitPay(appendParams: IAppendParams): void;
49
+ }
50
+ export default ApplePayComponent;
@@ -0,0 +1,339 @@
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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
+ 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
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ 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); }
11
+ /**
12
+ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
15
+ * 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
16
+ * 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.
17
+ */
18
+ import { EnvironmentEnum, eventCodeEnum, ProductSceneEnum } from "../../types";
19
+ import ApplePayService from "./service";
20
+ import { getApplePayPaymentSession, submitPayInfo } from "../../service";
21
+ import { BusManager, BusMessage } from "../../core/bus";
22
+ import { SecuritySDKActionEnum } from "../../core/bus/interface";
23
+ export var ApplePayComponentEvent = /*#__PURE__*/function (ApplePayComponentEvent) {
24
+ ApplePayComponentEvent["sdk_event_appleAvailable"] = "sdk_event_appleAvailable";
25
+ ApplePayComponentEvent["sdk_event_appleCreateComponent"] = "sdk_event_appleCreateComponent";
26
+ ApplePayComponentEvent["sdk_event_appleShowPaymentSheet"] = "sdk_event_appleShowPaymentSheet";
27
+ ApplePayComponentEvent["sdk_event_appleOnvalidatemerchant"] = "sdk_event_appleOnvalidatemerchant";
28
+ ApplePayComponentEvent["sdk_event_appleSubmitToken"] = "sdk_event_appleSubmitToken";
29
+ ApplePayComponentEvent["sdk_event_applePaymentResult"] = "sdk_event_applePaymentResult";
30
+ ApplePayComponentEvent["sdk_event_appleDestroyComponent"] = "sdk_event_appleDestroyComponent";
31
+ return ApplePayComponentEvent;
32
+ }({});
33
+
34
+ /**
35
+ * Apple pay Component
36
+ */
37
+ var ApplePayComponent = /*#__PURE__*/function () {
38
+ function ApplePayComponent(options, logger) {
39
+ _classCallCheck(this, ApplePayComponent);
40
+ _defineProperty(this, "_applePayService", void 0);
41
+ _defineProperty(this, "_parseData", void 0);
42
+ _defineProperty(this, "_sessionData", void 0);
43
+ _defineProperty(this, "_isFinish", false);
44
+ _defineProperty(this, "_options", void 0);
45
+ _defineProperty(this, "logger", void 0);
46
+ _defineProperty(this, "isRecurring", false);
47
+ this.logger = logger;
48
+ this._options = Object.assign({
49
+ environment: EnvironmentEnum.prod
50
+ }, options, {
51
+ product: ProductSceneEnum.CARD_APPLE_PAY
52
+ });
53
+ this._applePayService = new ApplePayService(logger);
54
+ }
55
+
56
+ /**
57
+ * Is Apple Pay Enabled
58
+ * @param subTypeEnum
59
+ * @returns
60
+ */
61
+ _createClass(ApplePayComponent, [{
62
+ key: "canMakePayments",
63
+ value: function canMakePayments(subTypeEnum) {
64
+ return ApplePayService.canMakePayments(subTypeEnum);
65
+ }
66
+
67
+ /**
68
+ * Is Apple Pay Enabled
69
+ * @param subTypeEnum
70
+ * @returns
71
+ */
72
+ }, {
73
+ key: "isAppPayEnabled",
74
+ value: function isAppPayEnabled(subTypeEnum) {
75
+ return this.canMakePayments(subTypeEnum);
76
+ }
77
+ }, {
78
+ key: "onEventCallback",
79
+ value: function onEventCallback(state) {
80
+ var _state$result, _state$result2, _this$_options;
81
+ this.logger.logInfo({
82
+ name: 'APPLE_PAY',
83
+ title: ApplePayComponentEvent.sdk_event_applePaymentResult
84
+ }, {
85
+ biz: 'sdk',
86
+ type: 'funnel',
87
+ success: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL === (state === null || state === void 0 ? void 0 : state.code),
88
+ code: state === null || state === void 0 ? void 0 : state.code,
89
+ errorCode: state === null || state === void 0 || (_state$result = state.result) === null || _state$result === void 0 ? void 0 : _state$result.errorCode,
90
+ errorMessage: state === null || state === void 0 || (_state$result2 = state.result) === null || _state$result2 === void 0 ? void 0 : _state$result2.errorMessage,
91
+ recurring: this.isRecurring
92
+ }).send();
93
+ (_this$_options = this._options) === null || _this$_options === void 0 || _this$_options.onEventCallback(state);
94
+ }
95
+
96
+ /**
97
+ * Submit Pay
98
+ * @param paymentSessionData
99
+ */
100
+ }, {
101
+ key: "submitPay",
102
+ value: function submitPay(appendParams) {
103
+ var _appendParams$iframeN,
104
+ _appendParams$iframeN2,
105
+ _this$_parseData,
106
+ _this = this;
107
+ this._isFinish = false;
108
+ this._parseData = appendParams === null || appendParams === void 0 || (_appendParams$iframeN = appendParams.iframeNodesParams) === null || _appendParams$iframeN === void 0 ? void 0 : _appendParams$iframeN.paymentSessionMetaData;
109
+ this._sessionData = appendParams === null || appendParams === void 0 || (_appendParams$iframeN2 = appendParams.iframeNodesParams) === null || _appendParams$iframeN2 === void 0 ? void 0 : _appendParams$iframeN2.sessionData;
110
+ if (!this._parseData || !this._sessionData) {
111
+ this.onEventCallback({
112
+ code: eventCodeEnum.SDK_PAYMENT_FAIL,
113
+ message: 'Abnormal params paymentSessionData'
114
+ });
115
+ this.logger.logError({
116
+ name: 'APPLE_PAY',
117
+ title: 'sessionDataNull',
118
+ msg: 'Abnormal paymentSessionData'
119
+ }, {
120
+ type: 'error',
121
+ biz: 'sdk'
122
+ }).send();
123
+ return;
124
+ }
125
+ this.isRecurring = ((_this$_parseData = this._parseData) === null || _this$_parseData === void 0 || (_this$_parseData = _this$_parseData.paymentSessionFactor) === null || _this$_parseData === void 0 ? void 0 : _this$_parseData.recurringInfo) !== null;
126
+ var getDeviceId = /*#__PURE__*/function () {
127
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
128
+ var _yield$BusManager$pub, _this$_parseData2;
129
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
130
+ while (1) switch (_context.prev = _context.next) {
131
+ case 0:
132
+ _context.next = 2;
133
+ return BusManager.publishForResult(new BusMessage(SecuritySDKActionEnum.getSecurityDeviceId, JSON.stringify({
134
+ deviceIdParameter: {
135
+ productScene: (_this$_parseData2 = _this._parseData) === null || _this$_parseData2 === void 0 || (_this$_parseData2 = _this$_parseData2.paymentSessionConfig) === null || _this$_parseData2 === void 0 ? void 0 : _this$_parseData2.productScene
136
+ }
137
+ })), {
138
+ fallback: ""
139
+ });
140
+ case 2:
141
+ _context.t1 = _yield$BusManager$pub = _context.sent;
142
+ _context.t0 = _context.t1 === null;
143
+ if (_context.t0) {
144
+ _context.next = 6;
145
+ break;
146
+ }
147
+ _context.t0 = _yield$BusManager$pub === void 0;
148
+ case 6:
149
+ if (!_context.t0) {
150
+ _context.next = 10;
151
+ break;
152
+ }
153
+ _context.t2 = void 0;
154
+ _context.next = 11;
155
+ break;
156
+ case 10:
157
+ _context.t2 = _yield$BusManager$pub.getJSONObject();
158
+ case 11:
159
+ return _context.abrupt("return", _context.t2);
160
+ case 12:
161
+ case "end":
162
+ return _context.stop();
163
+ }
164
+ }, _callee);
165
+ }));
166
+ return function getDeviceId() {
167
+ return _ref.apply(this, arguments);
168
+ };
169
+ }();
170
+ /**
171
+ * Get MerchantSession spi
172
+ * @param event
173
+ */
174
+ var getMerchantSession = /*#__PURE__*/function () {
175
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
176
+ var validationUrl, requestParams;
177
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
178
+ while (1) switch (_context2.prev = _context2.next) {
179
+ case 0:
180
+ validationUrl = _ref2.validationUrl;
181
+ // get validateUrl
182
+ requestParams = {
183
+ validateUrl: validationUrl,
184
+ paymentSessionData: _this._sessionData
185
+ }; // get deviceId
186
+ _context2.t0 = getApplePayPaymentSession;
187
+ _context2.t1 = _this._sessionData;
188
+ _context2.t2 = requestParams;
189
+ _context2.t3 = _this._options.environment;
190
+ _context2.next = 8;
191
+ return getDeviceId();
192
+ case 8:
193
+ _context2.t4 = _context2.sent;
194
+ _context2.t5 = {
195
+ deviceId: _context2.t4
196
+ };
197
+ _context2.t6 = {
198
+ env: _context2.t3,
199
+ envInfo: _context2.t5
200
+ };
201
+ _context2.t7 = _this.logger;
202
+ return _context2.abrupt("return", (0, _context2.t0)(_context2.t1, _context2.t2, _context2.t6, _context2.t7).then(function (res) {
203
+ if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
204
+ return Promise.resolve(res.merchantSessionObject);
205
+ }
206
+ return Promise.reject({
207
+ errorCode: res.errorCode,
208
+ errorMessage: res.errorMessage
209
+ });
210
+ }).catch(function (error) {
211
+ return Promise.reject(error);
212
+ }));
213
+ case 13:
214
+ case "end":
215
+ return _context2.stop();
216
+ }
217
+ }, _callee2);
218
+ }));
219
+ return function getMerchantSession(_x) {
220
+ return _ref3.apply(this, arguments);
221
+ };
222
+ }();
223
+
224
+ /**
225
+ * Complete Payment Authorized spi
226
+ * @param tokens
227
+ */
228
+ var completePaymentAuthorized = /*#__PURE__*/function () {
229
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
230
+ var paymentToken, params;
231
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
232
+ while (1) switch (_context3.prev = _context3.next) {
233
+ case 0:
234
+ paymentToken = _ref4.paymentToken;
235
+ params = {
236
+ paymentFactors: {
237
+ instPaymentToken: paymentToken
238
+ },
239
+ paymentSessionData: _this._sessionData
240
+ };
241
+ _context3.t0 = submitPayInfo;
242
+ _context3.t1 = params;
243
+ _context3.t2 = _this._options.environment;
244
+ _context3.next = 7;
245
+ return getDeviceId();
246
+ case 7:
247
+ _context3.t3 = _context3.sent;
248
+ _context3.t4 = {
249
+ deviceId: _context3.t3
250
+ };
251
+ _context3.t5 = {
252
+ env: _context3.t2,
253
+ envInfo: _context3.t4
254
+ };
255
+ _context3.t6 = _this.logger;
256
+ return _context3.abrupt("return", (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
257
+ _this.logger.logInfo({
258
+ name: 'APPLE_PAY',
259
+ title: 'submitPayStatus',
260
+ msg: res === null || res === void 0 ? void 0 : res.errorStatus
261
+ }, {
262
+ biz: 'sdk'
263
+ }).send();
264
+ if (res !== null && res !== void 0 && res.success || (res === null || res === void 0 ? void 0 : res.errorStatus) === 'U') {
265
+ return Promise.resolve(res);
266
+ }
267
+ return Promise.reject({
268
+ errorCode: res.errorCode,
269
+ errorMessage: res.errorMessage
270
+ });
271
+ }).catch(function (error) {
272
+ return Promise.reject(error);
273
+ }));
274
+ case 12:
275
+ case "end":
276
+ return _context3.stop();
277
+ }
278
+ }, _callee3);
279
+ }));
280
+ return function completePaymentAuthorized(_x2) {
281
+ return _ref5.apply(this, arguments);
282
+ };
283
+ }();
284
+ var completeApplePay = function completeApplePay(data) {
285
+ var _data$actionForm;
286
+ _this._isFinish = true;
287
+ _this.onEventCallback({
288
+ code: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL,
289
+ message: 'Payment successful',
290
+ result: {
291
+ redirectUrl: (data === null || data === void 0 || (_data$actionForm = data.actionForm) === null || _data$actionForm === void 0 ? void 0 : _data$actionForm.redirectUrl) || ''
292
+ }
293
+ });
294
+ };
295
+ var logError = function logError(code, msg, error) {
296
+ // log error
297
+ _this.logger.logError({
298
+ name: 'APPLE_PAY',
299
+ title: msg,
300
+ label: msg,
301
+ code: code,
302
+ msg: error
303
+ }, {
304
+ type: 'error',
305
+ biz: 'sdk'
306
+ }).send();
307
+ if (_this._isFinish) {
308
+ return;
309
+ }
310
+ _this._isFinish = true;
311
+ if (error !== null && error !== void 0 && error.errorCode) {
312
+ _this.onEventCallback({
313
+ code: code,
314
+ message: msg,
315
+ result: {
316
+ errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
317
+ errorMessage: error === null || error === void 0 ? void 0 : error.errorMessage
318
+ }
319
+ });
320
+ } else {
321
+ _this.onEventCallback({
322
+ code: code,
323
+ message: msg
324
+ });
325
+ }
326
+ };
327
+ // set Apple Pay params
328
+ this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError);
329
+ // init Apple Pay service
330
+ try {
331
+ this._applePayService.startPay(this._parseData);
332
+ } catch (error) {
333
+ logError(eventCodeEnum.SDK_PAYMENT_ERROR, "appple runtime excepiton", error);
334
+ }
335
+ }
336
+ }]);
337
+ return ApplePayComponent;
338
+ }();
339
+ export default ApplePayComponent;