@alipay/ams-checkout 1.3.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +1 -15
  3. package/esm/config/index.js +9 -62
  4. package/esm/config/request.d.ts +21 -0
  5. package/esm/config/request.js +67 -0
  6. package/esm/constant/index.d.ts +54 -32
  7. package/esm/constant/index.js +54 -32
  8. package/esm/core/component/index.d.ts +23 -9
  9. package/esm/core/component/index.js +161 -98
  10. package/esm/core/drop-in/index.d.ts +4 -4
  11. package/esm/core/drop-in/index.js +3 -3
  12. package/esm/core/instance/index.d.ts +6 -23
  13. package/esm/core/instance/index.js +31 -75
  14. package/esm/image/skeleton.svg +18 -0
  15. package/esm/index.d.ts +4 -10
  16. package/esm/index.js +8 -30
  17. package/esm/plugin/component/cashierApp.d.ts +5 -6
  18. package/esm/plugin/component/cashierApp.js +48 -64
  19. package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +4 -1
  20. package/esm/plugin/component/component.inline.style.js +38 -0
  21. package/esm/plugin/component/component.popup.style.d.ts +12 -0
  22. package/esm/plugin/component/component.popup.style.js +163 -0
  23. package/esm/plugin/component/index.d.ts +30 -33
  24. package/esm/plugin/component/index.js +248 -349
  25. package/esm/plugin/drop-in/index.d.ts +3 -5
  26. package/esm/plugin/drop-in/index.js +3 -3
  27. package/esm/request/index.d.ts +2 -2
  28. package/esm/request/index.js +8 -7
  29. package/esm/request/utils.d.ts +3 -3
  30. package/esm/request/utils.js +4 -4
  31. package/esm/service/index.d.ts +2 -2
  32. package/esm/types/index.d.ts +96 -37
  33. package/esm/types/index.js +92 -52
  34. package/esm/util/createIframeNode.d.ts +3 -3
  35. package/esm/util/createIframeNode.js +8 -8
  36. package/esm/util/index.d.ts +6 -4
  37. package/esm/util/index.js +22 -5
  38. package/esm/util/mock.js +1 -2
  39. package/package.json +1 -1
  40. package/esm/plugin/component/component.style.js +0 -15
@@ -1,13 +1,23 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
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 _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); }
6
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7
+ 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); }; }
8
+ 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); }
9
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10
+ 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; } }
11
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12
+ 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; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
3
15
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
16
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
17
  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); }
6
18
  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; }
7
19
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
8
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
- 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); } }
10
- 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); }); }; }
11
21
  /**
12
22
  * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
13
23
  *
@@ -16,25 +26,20 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
16
26
  * 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
27
  */
18
28
 
19
- import { COMPONENTPLUGINID, ERRORMESSAGE } from "../../constant";
29
+ import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
20
30
  import ComponentApp from "../../plugin/component";
21
- import { componentNameEnum, mode, networkMode, paymentMethodCategoryTypeEnum, productSceneEnum } from "../../types";
31
+ import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
22
32
  import { isPC } from "../../util";
23
33
  import { createIframeNode } from "../../util/createIframeNode";
34
+ import CoreInstance from "../instance/index";
24
35
  var getComponentSign = function getComponentSign(params) {
25
- var _ref = params || {},
26
- _ref$paymentSessionCo = _ref.paymentSessionConfig,
27
- _ref$paymentSessionCo2 = _ref$paymentSessionCo === void 0 ? {} : _ref$paymentSessionCo,
28
- _ref$paymentSessionCo3 = _ref$paymentSessionCo2.productScene,
29
- productScene = _ref$paymentSessionCo3 === void 0 ? '' : _ref$paymentSessionCo3,
30
- _ref$paymentSessionCo4 = _ref$paymentSessionCo2.paymentMethodCategoryType,
31
- paymentMethodCategoryType = _ref$paymentSessionCo4 === void 0 ? '' : _ref$paymentSessionCo4;
32
- if (productScene === productSceneEnum.EASY_PAY) return componentNameEnum.easyPay;
33
- if (productScene === productSceneEnum.CASHIER_PAYMENT && paymentMethodCategoryType === paymentMethodCategoryTypeEnum.CARD) return componentNameEnum.card;
34
- if (productScene === productSceneEnum.AUTO_DEBIT) {
35
- return componentNameEnum.autoDebit;
36
- }
37
- return '';
36
+ var _params$paymentSessio = params.paymentSessionConfig,
37
+ _params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
38
+ _params$paymentSessio3 = _params$paymentSessio2.productScene,
39
+ productScene = _params$paymentSessio3 === void 0 ? '' : _params$paymentSessio3,
40
+ _params$paymentSessio4 = _params$paymentSessio2.paymentMethodCategoryType,
41
+ paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
42
+ return productScene && paymentMethodCategoryType ? "".concat(productScene, "_").concat(paymentMethodCategoryType) : componentSignEnum.NONE;
38
43
  };
39
44
  var parsePaymentSessionData = function parsePaymentSessionData(paymentSessionData) {
40
45
  try {
@@ -45,7 +50,7 @@ var parsePaymentSessionData = function parsePaymentSessionData(paymentSessionDat
45
50
  }
46
51
  };
47
52
 
48
- // pc easy-pay&2.0 1.0 的支付逻辑
53
+ // pc easy-pay execute 1.0 Process
49
54
  var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
50
55
  if (isPC() && parseData !== null && parseData !== void 0 && parseData.paymentSessionConfig) {
51
56
  var productScene = parseData.paymentSessionConfig.productScene;
@@ -54,86 +59,144 @@ var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
54
59
  }
55
60
  }
56
61
  };
57
- export var mixinComponentConstructor = function mixinComponentConstructor(options, context) {
58
- // Instantiate the plug-in and set render
59
- var ComponentPlugin = new ComponentApp();
60
- ComponentPlugin.setRender(createIframeNode);
61
- // Register Cashier Application Plug in
62
- context._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
62
+ var handlePaymentSessionData = function handlePaymentSessionData(originPaymentSessionData) {
63
+ var _parsePaymentSessionD = parsePaymentSessionData(originPaymentSessionData),
64
+ _parsePaymentSessionD2 = _slicedToArray(_parsePaymentSessionD, 2),
65
+ parseData = _parsePaymentSessionD2[0],
66
+ paymentSessionData = _parsePaymentSessionD2[1];
67
+ resetEasyPaySceneVersion(parseData);
68
+ return [parseData, paymentSessionData];
69
+ };
70
+ var handleParams = function handleParams(params) {
71
+ var _params = Object.assign({
72
+ paymentSessionMetaData: {},
73
+ renderDisplayType: renderDisplayTypeEnum.popup
74
+ }, params);
75
+ var _handlePaymentSession = handlePaymentSessionData(_params.paymentSessionData),
76
+ _handlePaymentSession2 = _slicedToArray(_handlePaymentSession, 2),
77
+ parseData = _handlePaymentSession2[0],
78
+ paymentSessionData = _handlePaymentSession2[1];
79
+ var componentSign = getComponentSign(parseData);
80
+ if (componentSign === componentSignEnum.NONE) {
81
+ // eslint-disable-next-line prefer-promise-reject-errors
82
+ return Promise.reject({
83
+ code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
84
+ message: "Abnormal response data, interface failure, or unsupported payment method"
85
+ });
86
+ }
87
+ _params.paymentSessionData = paymentSessionData;
88
+ _params.paymentSessionMetaData = parseData;
89
+ return Promise.resolve({
90
+ iframeNodesParams: _params,
91
+ componentSign: componentSign
92
+ });
63
93
  };
94
+ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
95
+ _inherits(AMSComponent, _CoreInstance);
96
+ var _super = _createSuper(AMSComponent);
97
+ function AMSComponent(options) {
98
+ var _this;
99
+ _classCallCheck(this, AMSComponent);
100
+ _this = _super.call(this, options);
101
+ // Instantiate the plug-in and set render
102
+ _defineProperty(_assertThisInitialized(_this), "_componentApp", void 0);
103
+ var ComponentPlugin = new ComponentApp();
104
+ ComponentPlugin.setRender(createIframeNode);
105
+ // Register Cashier Application Plug in
106
+ _this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
107
+ _this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
108
+ return _this;
109
+ }
110
+ _createClass(AMSComponent, [{
111
+ key: "parameterInitAndCheck",
112
+ value: function parameterInitAndCheck(_ref) {
113
+ var params = _ref.params,
114
+ selector = _ref.selector,
115
+ renderDisplayType = _ref.renderDisplayType;
116
+ this.options.mode = modeEnum.component;
117
+ this.options.networkMode = this.options.networkMode || networkModeEnum.session;
118
+ var _params = Object.assign({
119
+ selector: selector,
120
+ renderDisplayType: renderDisplayType
121
+ }, params);
122
+ if (_params && !_params.paymentSessionData) {
123
+ return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
124
+ }
125
+ if (this.options.networkMode === networkModeEnum.proxy) {
126
+ console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
127
+ return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
128
+ }
129
+ return Promise.resolve(_params);
130
+ }
131
+ }, {
132
+ key: "pluginAppendIframe",
133
+ value: function pluginAppendIframe(appendParams) {
134
+ try {
135
+ return this._componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
136
+ } catch (error) {
137
+ return Promise.reject(error);
138
+ }
139
+ }
64
140
 
65
- /**
66
- * @description Create component application
67
- * @description component
68
- */
69
- export var createComponent = /*#__PURE__*/function () {
70
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(componentNameOrParams, params) {
71
- var _this = this;
72
- var _params;
73
- return _regeneratorRuntime().wrap(function _callee$(_context) {
74
- while (1) switch (_context.prev = _context.next) {
75
- case 0:
76
- this.options.mode = mode.component;
77
- this.options.networkMode = this.options.networkMode || networkMode.session;
78
- if (!(typeof componentNameOrParams === 'string' && params)) {
79
- _context.next = 8;
80
- break;
81
- }
82
- _params = params;
83
- if (componentNameOrParams in componentNameEnum) {
84
- _context.next = 6;
85
- break;
86
- }
87
- return _context.abrupt("return", Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR));
88
- case 6:
89
- _context.next = 9;
90
- break;
91
- case 8:
92
- _params = componentNameOrParams;
93
- case 9:
94
- if (!(_params && !_params.paymentSessionData)) {
95
- _context.next = 11;
96
- break;
97
- }
98
- return _context.abrupt("return", Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR));
99
- case 11:
100
- if (!(this.options.networkMode === networkMode.proxy)) {
101
- _context.next = 16;
102
- break;
141
+ /**
142
+ * @description Create component application
143
+ * @param params - The data source created by the component, necessary paymentSessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
144
+ */
145
+ }, {
146
+ key: "createComponent",
147
+ value: function createComponent(params) {
148
+ var _this2 = this;
149
+ return this.parameterInitAndCheck({
150
+ params: params,
151
+ renderDisplayType: renderDisplayTypeEnum.popup
152
+ }).then(function (_params) {
153
+ return handleParams(_params);
154
+ }).catch(function (error) {
155
+ _this2._eventCenter.emit(EVENT.error.name, error);
156
+ return Promise.reject(error);
157
+ }).then(function (appendParams) {
158
+ return _this2.pluginAppendIframe(appendParams);
159
+ });
160
+ }
161
+ /**
162
+ * @description Create and render components in the specified element area
163
+ * @param params - The data source created by the component, necessary paymentSessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
164
+ */
165
+ }, {
166
+ key: "mountComponent",
167
+ value: function mountComponent(params, selector) {
168
+ var _this3 = this;
169
+ return this.parameterInitAndCheck({
170
+ params: params,
171
+ renderDisplayType: renderDisplayTypeEnum.inline,
172
+ selector: selector
173
+ }).then(function (_params) {
174
+ return handleParams(_params);
175
+ }).catch(function (error) {
176
+ _this3._eventCenter.emit(EVENT.error.name, error);
177
+ return Promise.reject(error);
178
+ }).then(function (appendParams) {
179
+ return _this3.pluginAppendIframe(appendParams);
180
+ });
181
+ }
182
+ /**
183
+ * @description Execute payment submission process
184
+ * @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
185
+ */
186
+ }, {
187
+ key: "submit",
188
+ value: function submit() {
189
+ try {
190
+ this._componentApp.dispatchToApp({
191
+ context: {
192
+ event: 'submitPay',
193
+ data: {}
103
194
  }
104
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
105
- return _context.abrupt("return", Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT));
106
- case 16:
107
- return _context.abrupt("return", new Promise(function (resolve, reject) {
108
- var _parsePaymentSessionD = parsePaymentSessionData(_params.paymentSessionData),
109
- _parsePaymentSessionD2 = _slicedToArray(_parsePaymentSessionD, 2),
110
- parseData = _parsePaymentSessionD2[0],
111
- paymentSessionData = _parsePaymentSessionD2[1];
112
- resetEasyPaySceneVersion(parseData);
113
- var componentName = typeof componentNameOrParams === 'string' ? componentNameOrParams : getComponentSign(parseData);
114
- if (componentName === '') {
115
- // eslint-disable-next-line prefer-promise-reject-errors
116
- reject("".concat(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.errorCode, "\uFF1AAbnormal response data, interface failure, or unsupported payment method"));
117
- return;
118
- }
119
- _params.paymentSessionData = paymentSessionData;
120
- _params.paymentSessionMetaData = parseData;
121
- try {
122
- var componentApp = _this._getPlugin(COMPONENTPLUGINID);
123
- componentApp.appendIframeNodes(componentName, _params).then(function () {
124
- resolve();
125
- });
126
- } catch (error) {
127
- reject(error);
128
- }
129
- }));
130
- case 17:
131
- case "end":
132
- return _context.stop();
195
+ });
196
+ } catch (error) {
197
+ console.error(error);
133
198
  }
134
- }, _callee, this);
135
- }));
136
- return function createComponent(_x, _x2) {
137
- return _ref2.apply(this, arguments);
138
- };
139
- }();
199
+ }
200
+ }]);
201
+ return AMSComponent;
202
+ }(CoreInstance);
@@ -5,15 +5,15 @@
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 { createPaymentParams, optionsParams } from '../../types';
9
- export declare const mixinDropInConstructor: (options: optionsParams, context: any) => void;
8
+ import { IcreatePaymentParams, IoptionsParams } from '../../types';
9
+ export declare const mixinDropInConstructor: (options: IoptionsParams, context: any) => void;
10
10
  /**
11
11
  * @description Create checkout application
12
12
  * @description drop-in
13
13
  */
14
- export declare const createPayment: (params: createPaymentParams) => Promise<void>;
14
+ export declare const createPayment: (params: IcreatePaymentParams) => Promise<void>;
15
15
  export interface IcreatePaymentFunc {
16
- (params: createPaymentParams): Promise<void>;
16
+ (params: IcreatePaymentParams): Promise<void>;
17
17
  }
18
18
  /**
19
19
  * @description Take action on the interface result of payment submission
@@ -11,7 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
11
 
12
12
  import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
13
13
  import CheckoutApp from "../../plugin/drop-in";
14
- import { messageName, networkMode } from "../../types";
14
+ import { messageName, networkModeEnum } from "../../types";
15
15
  import { createIframeNode } from "../../util/createIframeNode";
16
16
  export var mixinDropInConstructor = function mixinDropInConstructor(options, context) {
17
17
  // Instantiate the plug-in and set render
@@ -28,7 +28,7 @@ export var mixinDropInConstructor = function mixinDropInConstructor(options, con
28
28
  */
29
29
  export var createPayment = function createPayment(params) {
30
30
  var _this = this;
31
- if (this.options.networkMode === networkMode.proxy) {
31
+ if (this.options.networkMode === networkModeEnum.proxy) {
32
32
  return new Promise(function (resolve, reject) {
33
33
  try {
34
34
  var checkoutApp = _this._getPlugin(BASEPLUGINID);
@@ -38,7 +38,7 @@ export var createPayment = function createPayment(params) {
38
38
  }
39
39
  });
40
40
  } else {
41
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
41
+ console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
42
42
  return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
43
43
  }
44
44
  };
@@ -1,16 +1,16 @@
1
- import type { AMSCheckoutOptions, callOnError, callOnSizeChanged, checkoutState, optionsParams } from '../../types/index';
1
+ import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams } from '../../types/index';
2
2
  import { EventCenter } from '../../util/index';
3
3
  export default class AMSSDK {
4
4
  options: AMSCheckoutOptions;
5
- checkoutState: checkoutState;
6
- eventCenter: EventCenter;
5
+ checkoutState: IcheckoutState;
6
+ _eventCenter: EventCenter;
7
7
  protected plugins: Map<string, any>;
8
8
  _instanceId: string;
9
- constructor(options: optionsParams);
9
+ constructor(options: IoptionsParams);
10
10
  /**
11
11
  * @description Destroy and process some contents of the plug-in
12
12
  */
13
- destroy(): void;
13
+ unmount(): void;
14
14
  /**
15
15
  * @description Set the sdk basic configuration
16
16
  */
@@ -34,7 +34,7 @@ export default class AMSSDK {
34
34
  /**
35
35
  * @description Get Plug-in
36
36
  */
37
- _getPlugin(pluginId: string): any;
37
+ protected _getPlugin(pluginId: string): any;
38
38
  /**
39
39
  * @description Execute to open app or jump link
40
40
  */
@@ -47,21 +47,4 @@ export default class AMSSDK {
47
47
  * @description Overlay Subscription
48
48
  */
49
49
  protected _overrideSubscription(name: string, func: any, funcKey: string): void;
50
- /**
51
- * @description Create an event handler, called when an error occurs in AMSCheckout.
52
- */
53
- onError(event: callOnError): void;
54
- /**
55
- * @description Create an event handler, called when the checkout view is available for interaction.
56
- * mode: dropin
57
- */
58
- /**
59
- * @description Create an event handler, called after the user selects the payment method
60
- * mode: dropin
61
- */
62
- /**
63
- * @description Create an event handler
64
- */
65
- onSizeChanged(event: callOnSizeChanged): void;
66
- onLog(event: callOnSizeChanged): void;
67
50
  }
@@ -17,7 +17,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
17
17
  */
18
18
  import { v4 as uuid } from 'uuid';
19
19
  import { ERRORMESSAGE, EVENT } from "../../constant";
20
- import { environment, mode, networkMode, osType, terminalType } from "../../types/index";
20
+ import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
21
21
  import { device, EventCenter, getType, queryParse } from "../../util/index";
22
22
  import CallApp from "../../util/intl-callapp/es/main";
23
23
  var AMSSDK = /*#__PURE__*/function () {
@@ -25,16 +25,13 @@ var AMSSDK = /*#__PURE__*/function () {
25
25
  _classCallCheck(this, AMSSDK);
26
26
  _defineProperty(this, "options", void 0);
27
27
  _defineProperty(this, "checkoutState", void 0);
28
- _defineProperty(this, "eventCenter", void 0);
28
+ _defineProperty(this, "_eventCenter", void 0);
29
29
  _defineProperty(this, "plugins", void 0);
30
30
  _defineProperty(this, "_instanceId", void 0);
31
31
  this._instanceId = uuid();
32
32
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
33
33
  this.options = {};
34
- this.eventCenter = new EventCenter();
35
- this.checkoutState = {
36
- paymentMethodType: ''
37
- };
34
+ this._eventCenter = new EventCenter();
38
35
  this._initEvent(options);
39
36
  this._setOptions(options);
40
37
  this.plugins = new Map();
@@ -43,8 +40,8 @@ var AMSSDK = /*#__PURE__*/function () {
43
40
  * @description Destroy and process some contents of the plug-in
44
41
  */
45
42
  _createClass(AMSSDK, [{
46
- key: "destroy",
47
- value: function destroy() {
43
+ key: "unmount",
44
+ value: function unmount() {
48
45
  var _iterator = _createForOfIteratorHelper(this.plugins.values()),
49
46
  _step;
50
47
  try {
@@ -53,7 +50,9 @@ var AMSSDK = /*#__PURE__*/function () {
53
50
  try {
54
51
  plugin.logoutPlugin();
55
52
  // eslint-disable-next-line no-empty
56
- } catch (error) {}
53
+ } catch (error) {
54
+ console.error(error);
55
+ }
57
56
  }
58
57
  } catch (err) {
59
58
  _iterator.e(err);
@@ -79,17 +78,17 @@ var AMSSDK = /*#__PURE__*/function () {
79
78
  value: function _setEnv(options) {
80
79
  var _queryParse = queryParse(),
81
80
  _moreEnv = _queryParse._moreEnv;
82
- if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in environment) && _moreEnv !== 'true') {
83
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.errorMessage);
81
+ if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in environmentEnum) && _moreEnv !== 'true') {
82
+ console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.message);
84
83
  options.environment = 'prod';
85
84
  }
86
85
  this.options.env = {
87
- terminalType: device.isMobile ? terminalType.WAP : terminalType.WEB,
86
+ terminalType: device.isMobile ? terminalTypeEnum.WAP : terminalTypeEnum.WEB,
88
87
  environment: (options === null || options === void 0 ? void 0 : options.environment) || 'prod'
89
88
  };
90
- if (this.options.env.terminalType === terminalType.WAP) {
89
+ if (this.options.env.terminalType === terminalTypeEnum.WAP) {
91
90
  // eslint-disable-next-line no-nested-ternary
92
- this.options.env.osType = device.iOS ? osType.IOS : device.Android ? osType.ANDROID : osType.ELSE;
91
+ this.options.env.osType = device.iOS ? osTypeEnum.IOS : device.Android ? osTypeEnum.ANDROID : osTypeEnum.ELSE;
93
92
  }
94
93
  }
95
94
  /**
@@ -98,15 +97,15 @@ var AMSSDK = /*#__PURE__*/function () {
98
97
  }, {
99
98
  key: "_setMode",
100
99
  value: function _setMode(options) {
101
- this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) || mode.dropin;
102
- if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in mode)) {
103
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.errorMessage);
104
- this.options.mode = mode.component;
100
+ this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) || modeEnum.component;
101
+ if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in modeEnum)) {
102
+ console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.message);
103
+ this.options.mode = modeEnum.component;
105
104
  }
106
- this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) || networkMode.session;
107
- if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in networkMode)) {
108
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
109
- this.options.networkMode = networkMode.proxy;
105
+ this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) || networkModeEnum.session;
106
+ if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in networkModeEnum)) {
107
+ console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
108
+ this.options.networkMode = networkModeEnum.proxy;
110
109
  }
111
110
  }
112
111
  /**
@@ -116,32 +115,28 @@ var AMSSDK = /*#__PURE__*/function () {
116
115
  key: "_initEvent",
117
116
  value: function _initEvent(options) {
118
117
  if (options !== null && options !== void 0 && options.onError) {
119
- if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
118
+ if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
120
119
  this._overrideSubscription(EVENT.error.name, options.onError, EVENT.error.uniqueKey);
121
120
  }
122
121
  if (options !== null && options !== void 0 && options.onPaymentMethodSelected) {
123
- if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
122
+ if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
124
123
  this._overrideSubscription(EVENT.paymentMethodSelected.name, options.onPaymentMethodSelected, EVENT.paymentMethodSelected.uniqueKey);
125
124
  }
126
- if (options !== null && options !== void 0 && options.onReady) {
127
- if (getType(options.onReady) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
128
- this._overrideSubscription(EVENT.ready.name, options.onReady, EVENT.ready.uniqueKey);
129
- }
130
125
  if (options !== null && options !== void 0 && options.onSizeChanged) {
131
- if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
126
+ if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
132
127
  this._overrideSubscription(EVENT.sizeChanged.name, options.onSizeChanged, EVENT.sizeChanged.uniqueKey);
133
128
  }
134
129
  if (options !== null && options !== void 0 && options.onLog) {
135
- if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
130
+ if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
136
131
  this._overrideSubscription(EVENT.log.name, options.onLog, EVENT.log.uniqueKey);
137
132
  }
138
133
  if (options !== null && options !== void 0 && options.onEventCallback) {
139
- if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
134
+ if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
140
135
  this._overrideSubscription(EVENT.eventCallback.name, options.onEventCallback, EVENT.eventCallback.uniqueKey);
141
136
  }
142
137
  if (options !== null && options !== void 0 && options.onClose) {
143
- if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
144
- this._overrideSubscription(EVENT.onClose.name, options.onClose, EVENT.onClose.uniqueKey);
138
+ if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
139
+ this._overrideSubscription(EVENT.close.name, options.onClose, EVENT.close.uniqueKey);
145
140
  }
146
141
  }
147
142
  /**
@@ -179,7 +174,7 @@ var AMSSDK = /*#__PURE__*/function () {
179
174
  value: function _redirect(data) {
180
175
  var _this = this;
181
176
  return new Promise(function (resolve, reject) {
182
- var isWeb = _this.options.env.terminalType === terminalType.WEB;
177
+ var isWeb = _this.options.env.terminalType === terminalTypeEnum.WEB;
183
178
  var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';
184
179
  var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';
185
180
  var applinkUrl = (data === null || data === void 0 ? void 0 : data.applinkUrl) || '';
@@ -228,47 +223,8 @@ var AMSSDK = /*#__PURE__*/function () {
228
223
  }, {
229
224
  key: "_overrideSubscription",
230
225
  value: function _overrideSubscription(name, func, funcKey) {
231
- this.eventCenter.off(name, func, funcKey);
232
- this.eventCenter.on(name, func, funcKey);
233
- }
234
- /**
235
- * @description Create an event handler, called when an error occurs in AMSCheckout.
236
- */
237
- }, {
238
- key: "onError",
239
- value: function onError(event) {
240
- this._overrideSubscription(EVENT.error.name, event, EVENT.error.uniqueKey);
241
- }
242
- /**
243
- * @description Create an event handler, called when the checkout view is available for interaction.
244
- * mode: dropin
245
- */
246
- // onReady(event: () => void) {
247
- // this._overrideSubscription(EVENT.ready.name, event, EVENT.ready.uniqueKey);
248
- // }
249
- /**
250
- * @description Create an event handler, called after the user selects the payment method
251
- * mode: dropin
252
- */
253
- // onPaymentMethodSelected(event: callonPaymentMethodSelected) {
254
- // this._overrideSubscription(
255
- // EVENT.paymentMethodSelected.name,
256
- // event,
257
- // EVENT.paymentMethodSelected.uniqueKey,
258
- // );
259
- // }
260
- /**
261
- * @description Create an event handler
262
- */
263
- }, {
264
- key: "onSizeChanged",
265
- value: function onSizeChanged(event) {
266
- this._overrideSubscription(EVENT.sizeChanged.name, event, EVENT.sizeChanged.uniqueKey);
267
- }
268
- }, {
269
- key: "onLog",
270
- value: function onLog(event) {
271
- this._overrideSubscription(EVENT.log.name, event, EVENT.log.uniqueKey);
226
+ this._eventCenter.off(name, func, funcKey);
227
+ this._eventCenter.on(name, func, funcKey);
272
228
  }
273
229
  }]);
274
230
  return AMSSDK;