@alipay/ams-checkout 0.0.1691743027-dev.9 → 0.0.1691995963-dev.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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +15 -1
- package/esm/config/index.js +62 -9
- package/esm/constant/index.d.ts +32 -54
- package/esm/constant/index.js +32 -54
- package/esm/core/component/index.d.ts +9 -23
- package/esm/core/component/index.js +98 -161
- package/esm/core/drop-in/index.d.ts +4 -4
- package/esm/core/drop-in/index.js +3 -3
- package/esm/core/instance/index.d.ts +23 -6
- package/esm/core/instance/index.js +75 -31
- package/esm/index.d.ts +10 -4
- package/esm/index.js +30 -8
- package/esm/plugin/component/cashierApp.d.ts +6 -5
- package/esm/plugin/component/cashierApp.js +64 -48
- package/esm/plugin/component/{component.inline.style.d.ts → component.style.d.ts} +1 -4
- package/esm/plugin/component/component.style.js +15 -0
- package/esm/plugin/component/index.d.ts +33 -30
- package/esm/plugin/component/index.js +349 -248
- package/esm/plugin/drop-in/index.d.ts +5 -3
- package/esm/plugin/drop-in/index.js +3 -3
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +7 -8
- package/esm/request/utils.d.ts +3 -3
- package/esm/request/utils.js +4 -4
- package/esm/service/index.d.ts +2 -2
- package/esm/types/index.d.ts +37 -96
- package/esm/types/index.js +52 -92
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +4 -6
- package/esm/util/index.js +5 -22
- package/esm/util/mock.js +2 -1
- package/package.json +1 -1
- package/esm/config/request.d.ts +0 -21
- package/esm/config/request.js +0 -67
- package/esm/image/skeleton.svg +0 -18
- package/esm/plugin/component/component.inline.style.js +0 -38
- package/esm/plugin/component/component.popup.style.d.ts +0 -12
- package/esm/plugin/component/component.popup.style.js +0 -163
@@ -1,23 +1,13 @@
|
|
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 _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); }
|
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; }
|
15
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
16
4
|
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."); }
|
17
5
|
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); }
|
18
6
|
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; }
|
19
7
|
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; } }
|
20
8
|
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); }); }; }
|
21
11
|
/**
|
22
12
|
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
23
13
|
*
|
@@ -26,20 +16,25 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
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.
|
27
17
|
*/
|
28
18
|
|
29
|
-
import { COMPONENTPLUGINID, ERRORMESSAGE
|
19
|
+
import { COMPONENTPLUGINID, ERRORMESSAGE } from "../../constant";
|
30
20
|
import ComponentApp from "../../plugin/component";
|
31
|
-
import {
|
21
|
+
import { componentNameEnum, mode, networkMode, paymentMethodCategoryTypeEnum, productSceneEnum } from "../../types";
|
32
22
|
import { isPC } from "../../util";
|
33
23
|
import { createIframeNode } from "../../util/createIframeNode";
|
34
|
-
import CoreInstance from "../instance/index";
|
35
24
|
var getComponentSign = function getComponentSign(params) {
|
36
|
-
var
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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 '';
|
43
38
|
};
|
44
39
|
var parsePaymentSessionData = function parsePaymentSessionData(paymentSessionData) {
|
45
40
|
try {
|
@@ -50,7 +45,7 @@ var parsePaymentSessionData = function parsePaymentSessionData(paymentSessionDat
|
|
50
45
|
}
|
51
46
|
};
|
52
47
|
|
53
|
-
// pc easy-pay
|
48
|
+
// pc easy-pay&2.0 走 1.0 的支付逻辑
|
54
49
|
var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
|
55
50
|
if (isPC() && parseData !== null && parseData !== void 0 && parseData.paymentSessionConfig) {
|
56
51
|
var productScene = parseData.paymentSessionConfig.productScene;
|
@@ -59,144 +54,86 @@ var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
|
|
59
54
|
}
|
60
55
|
}
|
61
56
|
};
|
62
|
-
var
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
});
|
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);
|
93
63
|
};
|
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
|
-
}
|
140
64
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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: {}
|
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;
|
194
81
|
}
|
195
|
-
|
196
|
-
|
197
|
-
|
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;
|
103
|
+
}
|
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();
|
198
133
|
}
|
199
|
-
}
|
200
|
-
}
|
201
|
-
return
|
202
|
-
|
134
|
+
}, _callee, this);
|
135
|
+
}));
|
136
|
+
return function createComponent(_x, _x2) {
|
137
|
+
return _ref2.apply(this, arguments);
|
138
|
+
};
|
139
|
+
}();
|
@@ -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 {
|
9
|
-
export declare const mixinDropInConstructor: (options:
|
8
|
+
import { createPaymentParams, optionsParams } from '../../types';
|
9
|
+
export declare const mixinDropInConstructor: (options: optionsParams, context: any) => void;
|
10
10
|
/**
|
11
11
|
* @description Create checkout application
|
12
12
|
* @description drop-in
|
13
13
|
*/
|
14
|
-
export declare const createPayment: (params:
|
14
|
+
export declare const createPayment: (params: createPaymentParams) => Promise<void>;
|
15
15
|
export interface IcreatePaymentFunc {
|
16
|
-
(params:
|
16
|
+
(params: createPaymentParams): 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,
|
14
|
+
import { messageName, networkMode } 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 ===
|
31
|
+
if (this.options.networkMode === networkMode.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.
|
41
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
|
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,
|
1
|
+
import type { AMSCheckoutOptions, callOnError, callOnSizeChanged, checkoutState, optionsParams } from '../../types/index';
|
2
2
|
import { EventCenter } from '../../util/index';
|
3
3
|
export default class AMSSDK {
|
4
4
|
options: AMSCheckoutOptions;
|
5
|
-
checkoutState:
|
6
|
-
|
5
|
+
checkoutState: checkoutState;
|
6
|
+
eventCenter: EventCenter;
|
7
7
|
protected plugins: Map<string, any>;
|
8
8
|
_instanceId: string;
|
9
|
-
constructor(options:
|
9
|
+
constructor(options: optionsParams);
|
10
10
|
/**
|
11
11
|
* @description Destroy and process some contents of the plug-in
|
12
12
|
*/
|
13
|
-
|
13
|
+
destroy(): 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
|
-
|
37
|
+
_getPlugin(pluginId: string): any;
|
38
38
|
/**
|
39
39
|
* @description Execute to open app or jump link
|
40
40
|
*/
|
@@ -47,4 +47,21 @@ 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;
|
50
67
|
}
|
@@ -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 {
|
20
|
+
import { environment, mode, networkMode, osType, terminalType } 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,13 +25,16 @@ 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, "
|
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.
|
34
|
+
this.eventCenter = new EventCenter();
|
35
|
+
this.checkoutState = {
|
36
|
+
paymentMethodType: ''
|
37
|
+
};
|
35
38
|
this._initEvent(options);
|
36
39
|
this._setOptions(options);
|
37
40
|
this.plugins = new Map();
|
@@ -40,8 +43,8 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
40
43
|
* @description Destroy and process some contents of the plug-in
|
41
44
|
*/
|
42
45
|
_createClass(AMSSDK, [{
|
43
|
-
key: "
|
44
|
-
value: function
|
46
|
+
key: "destroy",
|
47
|
+
value: function destroy() {
|
45
48
|
var _iterator = _createForOfIteratorHelper(this.plugins.values()),
|
46
49
|
_step;
|
47
50
|
try {
|
@@ -50,9 +53,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
50
53
|
try {
|
51
54
|
plugin.logoutPlugin();
|
52
55
|
// eslint-disable-next-line no-empty
|
53
|
-
} catch (error) {
|
54
|
-
console.error(error);
|
55
|
-
}
|
56
|
+
} catch (error) {}
|
56
57
|
}
|
57
58
|
} catch (err) {
|
58
59
|
_iterator.e(err);
|
@@ -78,17 +79,17 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
78
79
|
value: function _setEnv(options) {
|
79
80
|
var _queryParse = queryParse(),
|
80
81
|
_moreEnv = _queryParse._moreEnv;
|
81
|
-
if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in
|
82
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.
|
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);
|
83
84
|
options.environment = 'prod';
|
84
85
|
}
|
85
86
|
this.options.env = {
|
86
|
-
terminalType: device.isMobile ?
|
87
|
+
terminalType: device.isMobile ? terminalType.WAP : terminalType.WEB,
|
87
88
|
environment: (options === null || options === void 0 ? void 0 : options.environment) || 'prod'
|
88
89
|
};
|
89
|
-
if (this.options.env.terminalType ===
|
90
|
+
if (this.options.env.terminalType === terminalType.WAP) {
|
90
91
|
// eslint-disable-next-line no-nested-ternary
|
91
|
-
this.options.env.osType = device.iOS ?
|
92
|
+
this.options.env.osType = device.iOS ? osType.IOS : device.Android ? osType.ANDROID : osType.ELSE;
|
92
93
|
}
|
93
94
|
}
|
94
95
|
/**
|
@@ -97,15 +98,15 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
97
98
|
}, {
|
98
99
|
key: "_setMode",
|
99
100
|
value: function _setMode(options) {
|
100
|
-
this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) ||
|
101
|
-
if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in
|
102
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.
|
103
|
-
this.options.mode =
|
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;
|
104
105
|
}
|
105
|
-
this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) ||
|
106
|
-
if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in
|
107
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.
|
108
|
-
this.options.networkMode =
|
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;
|
109
110
|
}
|
110
111
|
}
|
111
112
|
/**
|
@@ -115,28 +116,32 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
115
116
|
key: "_initEvent",
|
116
117
|
value: function _initEvent(options) {
|
117
118
|
if (options !== null && options !== void 0 && options.onError) {
|
118
|
-
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
119
|
+
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
119
120
|
this._overrideSubscription(EVENT.error.name, options.onError, EVENT.error.uniqueKey);
|
120
121
|
}
|
121
122
|
if (options !== null && options !== void 0 && options.onPaymentMethodSelected) {
|
122
|
-
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
123
|
+
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
123
124
|
this._overrideSubscription(EVENT.paymentMethodSelected.name, options.onPaymentMethodSelected, EVENT.paymentMethodSelected.uniqueKey);
|
124
125
|
}
|
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
|
+
}
|
125
130
|
if (options !== null && options !== void 0 && options.onSizeChanged) {
|
126
|
-
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
131
|
+
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
127
132
|
this._overrideSubscription(EVENT.sizeChanged.name, options.onSizeChanged, EVENT.sizeChanged.uniqueKey);
|
128
133
|
}
|
129
134
|
if (options !== null && options !== void 0 && options.onLog) {
|
130
|
-
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
135
|
+
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
131
136
|
this._overrideSubscription(EVENT.log.name, options.onLog, EVENT.log.uniqueKey);
|
132
137
|
}
|
133
138
|
if (options !== null && options !== void 0 && options.onEventCallback) {
|
134
|
-
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
139
|
+
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
135
140
|
this._overrideSubscription(EVENT.eventCallback.name, options.onEventCallback, EVENT.eventCallback.uniqueKey);
|
136
141
|
}
|
137
142
|
if (options !== null && options !== void 0 && options.onClose) {
|
138
|
-
if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
139
|
-
this._overrideSubscription(EVENT.
|
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);
|
140
145
|
}
|
141
146
|
}
|
142
147
|
/**
|
@@ -174,7 +179,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
174
179
|
value: function _redirect(data) {
|
175
180
|
var _this = this;
|
176
181
|
return new Promise(function (resolve, reject) {
|
177
|
-
var isWeb = _this.options.env.terminalType ===
|
182
|
+
var isWeb = _this.options.env.terminalType === terminalType.WEB;
|
178
183
|
var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';
|
179
184
|
var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';
|
180
185
|
var applinkUrl = (data === null || data === void 0 ? void 0 : data.applinkUrl) || '';
|
@@ -223,8 +228,47 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
223
228
|
}, {
|
224
229
|
key: "_overrideSubscription",
|
225
230
|
value: function _overrideSubscription(name, func, funcKey) {
|
226
|
-
this.
|
227
|
-
this.
|
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);
|
228
272
|
}
|
229
273
|
}]);
|
230
274
|
return AMSSDK;
|