@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730107332-dev.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.d.ts +2 -3
- package/esm/component/channel.js +63 -29
- package/esm/component/component.inline.style.js +1 -1
- package/esm/component/component.popup.style.d.ts +1 -3
- package/esm/component/component.popup.style.js +1 -3
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +10 -10
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/core/bus/ability/callback.js +55 -0
- package/esm/core/bus/ability/security.d.ts +10 -0
- package/esm/core/bus/ability/security.js +104 -0
- package/esm/core/bus/ability/tracker.d.ts +9 -0
- package/esm/core/bus/ability/tracker.js +77 -0
- package/esm/core/bus/index.d.ts +125 -0
- package/esm/core/bus/index.js +366 -0
- package/esm/core/bus/interface.d.ts +36 -0
- package/esm/core/bus/interface.js +40 -0
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/core/component/appPreloadProcessing.js +89 -0
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +167 -0
- package/esm/core/component/element/components/address.d.ts +19 -0
- package/esm/core/component/element/components/address.js +68 -0
- package/esm/core/component/element/components/auth.d.ts +17 -0
- package/esm/core/component/element/components/auth.js +60 -0
- package/esm/core/component/element/components/payment.d.ts +19 -0
- package/esm/core/component/element/components/payment.js +74 -0
- package/esm/core/component/element/index.d.ts +47 -0
- package/esm/core/component/element/index.js +816 -0
- package/esm/core/component/element/mock.d.ts +4 -0
- package/esm/core/component/element/mock.js +491 -0
- package/esm/core/component/element/type.d.ts +190 -0
- package/esm/core/component/element/type.js +35 -0
- package/esm/core/component/element/utils.d.ts +13 -0
- package/esm/core/component/element/utils.js +6 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +531 -0
- package/esm/core/drop-in/index.d.ts +22 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +89 -0
- package/esm/core/instance/index.js +499 -0
- package/esm/foundation/core/index.d.ts +3 -3
- package/esm/foundation/core/index.js +10 -8
- package/esm/foundation/index.d.ts +6 -5
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +6 -6
- package/esm/foundation/product-processor/easysafepay/deps.js +4 -4
- package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -3
- package/esm/foundation/product-processor/easysafepay/index.js +110 -243
- package/esm/foundation/service/api-bus/index.d.ts +2 -2
- package/esm/foundation/service/container/index.d.ts +4 -2
- package/esm/foundation/service/container/index.js +43 -1
- package/esm/foundation/service/event-center.d.ts +6 -4
- package/esm/foundation/service/event-center.js +47 -17
- package/esm/foundation/service/global-data/index.d.ts +2 -2
- package/esm/foundation/service/index.d.ts +2 -2
- package/esm/foundation/service/log/index.d.ts +2 -2
- package/esm/foundation/service/log/index.js +1 -1
- package/esm/foundation/service/requester/deps.d.ts +1 -1
- package/esm/foundation/service/requester/requester.d.ts +2 -2
- package/esm/foundation/service/security/index.d.ts +2 -2
- package/esm/foundation/service/security/index.js +1 -0
- package/esm/foundation/utils/redirect_utils.d.ts +5 -0
- package/esm/foundation/utils/redirect_utils.js +205 -58
- package/esm/foundation/utils/system_events.js +0 -5
- package/esm/foundation/utils/web_app_url_utils.js +1 -1
- package/esm/index.d.ts +31 -2
- package/esm/index.js +146 -6
- package/esm/plugin/applepay/component.d.ts +50 -0
- package/esm/plugin/applepay/component.js +339 -0
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/plugin/applepay/interface.d.ts +161 -0
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/plugin/applepay/service.d.ts +54 -0
- package/esm/plugin/applepay/service.js +289 -0
- package/esm/plugin/component/cashierApp.d.ts +36 -0
- package/esm/plugin/component/cashierApp.js +244 -0
- package/esm/plugin/component/channel.d.ts +21 -0
- package/esm/plugin/component/channel.js +89 -0
- package/esm/plugin/component/component.inline.style.d.ts +10 -0
- package/esm/plugin/component/component.inline.style.js +121 -0
- package/esm/plugin/component/component.popup.style.d.ts +16 -0
- package/esm/plugin/component/component.popup.style.js +174 -0
- package/esm/plugin/component/index.d.ts +127 -0
- package/esm/plugin/component/index.js +1896 -0
- package/esm/plugin/component/popupWindow.style.d.ts +11 -0
- package/esm/plugin/component/popupWindow.style.js +121 -0
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/drop-in/index.d.ts +71 -0
- package/esm/plugin/drop-in/index.js +324 -0
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +6 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +390 -0
- package/esm/plugin/type.d.ts +34 -0
- package/esm/plugin/type.js +1 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/service/element.d.ts +4 -0
- package/esm/service/element.js +51 -0
- package/esm/service/index.d.ts +1 -0
- package/esm/service/index.js +2 -0
- package/esm/types/index.d.ts +228 -26
- package/esm/types/index.js +54 -5
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +2 -2
- package/esm/util/getBackScheme.js +2 -2
- package/esm/util/index.d.ts +11 -1
- package/esm/util/index.js +84 -3
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/util/security.d.ts +33 -0
- package/esm/util/security.js +182 -0
- package/package.json +2 -1
- package/esm/foundation/types/index.d.ts +0 -4
- package/esm/foundation/types/index.js +0 -4
@@ -0,0 +1,531 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
5
|
+
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); } }
|
6
|
+
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); }); }; }
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
10
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
12
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
13
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
15
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
17
|
+
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; }
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
19
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
20
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
21
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
22
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
23
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
24
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
25
|
+
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."); }
|
26
|
+
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); }
|
27
|
+
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; }
|
28
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
29
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
30
|
+
/**
|
31
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
32
|
+
*
|
33
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
34
|
+
* 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
|
35
|
+
* 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.
|
36
|
+
*/
|
37
|
+
import { v4 as uuid } from 'uuid';
|
38
|
+
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
39
|
+
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
40
|
+
import ComponentApp from "../../plugin/component";
|
41
|
+
import { ExtendPlugin } from "../../plugin/const";
|
42
|
+
import { PaypalBusSubscriber } from "../../plugin/paypal";
|
43
|
+
import { ComponentSignEnum, ComponentSignEnumV2, EnvironmentEnum, modeEnum, networkModeEnum, ProductSceneEnum, DisplayTypeEnum } from "../../types";
|
44
|
+
import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
|
45
|
+
import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
|
46
|
+
import { getSecurityConfigStorageKey } from "../../util/security";
|
47
|
+
import { BusManager, BusMessage } from "../bus";
|
48
|
+
import { SDKCallbackBusSubscriber } from "../bus/ability/callback";
|
49
|
+
import { SecurityBusSubscriber } from "../bus/ability/security";
|
50
|
+
import { TrackerBusSubscriber } from "../bus/ability/tracker";
|
51
|
+
import CoreInstance from "../instance/index";
|
52
|
+
import { loadChannelPneumaticControl } from "./appPreloadProcessing";
|
53
|
+
export var getComponentSign = function getComponentSign(params) {
|
54
|
+
var _params$paymentSessio = params.paymentSessionConfig,
|
55
|
+
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
56
|
+
_params$paymentSessio3 = _params$paymentSessio2.productScene,
|
57
|
+
productScene = _params$paymentSessio3 === void 0 ? '' : _params$paymentSessio3,
|
58
|
+
_params$paymentSessio4 = _params$paymentSessio2.paymentMethodCategoryType,
|
59
|
+
paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
|
60
|
+
if (productScene && paymentMethodCategoryType) return "".concat(productScene, "_").concat(paymentMethodCategoryType);
|
61
|
+
if (productScene) return "".concat(productScene);
|
62
|
+
return ComponentSignEnum.NONE;
|
63
|
+
};
|
64
|
+
export var parseSessionData = function parseSessionData(sessionData) {
|
65
|
+
try {
|
66
|
+
return [JSON.parse(parseBase64ToString(sessionData.split('&&')[3])), sessionData.split('&&').slice(0, 3).join('&&')];
|
67
|
+
} catch (error) {
|
68
|
+
console.error('Parsing sessionData is abnormal and may affect the payment link. Please ensure to use the new version of SDK.');
|
69
|
+
return [{}, sessionData];
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
// pc easy-pay execute 1.0 Process
|
74
|
+
var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
|
75
|
+
if (isPC() && parseData !== null && parseData !== void 0 && parseData.paymentSessionConfig) {
|
76
|
+
var productScene = parseData.paymentSessionConfig.productScene;
|
77
|
+
if (productScene === ProductSceneEnum.EASY_PAY) {
|
78
|
+
var _parseData$paymentMet;
|
79
|
+
// 非TOSS渠道,在PC场景需要改成1.0
|
80
|
+
if ('BANKTRANSFER_QUICKPAY' !== (parseData === null || parseData === void 0 || (_parseData$paymentMet = parseData.paymentMethodInfoView) === null || _parseData$paymentMet === void 0 ? void 0 : _parseData$paymentMet.paymentMethodType)) {
|
81
|
+
parseData.paymentSessionConfig.productSceneVersion = '1.0';
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
};
|
86
|
+
var handleSessionData = function handleSessionData(originSessionData) {
|
87
|
+
var _parseSessionData = parseSessionData(originSessionData),
|
88
|
+
_parseSessionData2 = _slicedToArray(_parseSessionData, 2),
|
89
|
+
parseData = _parseSessionData2[0],
|
90
|
+
sessionData = _parseSessionData2[1];
|
91
|
+
resetEasyPaySceneVersion(parseData);
|
92
|
+
return [parseData !== null && parseData !== void 0 ? parseData : {}, sessionData];
|
93
|
+
};
|
94
|
+
var handleParams = function handleParams(params, _this) {
|
95
|
+
var _params = Object.assign({
|
96
|
+
paymentSessionMetaData: {},
|
97
|
+
renderDisplayType: DisplayTypeEnum.popup
|
98
|
+
}, params);
|
99
|
+
var _handleSessionData = handleSessionData(_params.sessionData || (_params === null || _params === void 0 ? void 0 : _params.paymentSessionData)),
|
100
|
+
_handleSessionData2 = _slicedToArray(_handleSessionData, 2),
|
101
|
+
parseData = _handleSessionData2[0],
|
102
|
+
sessionData = _handleSessionData2[1];
|
103
|
+
var componentSign = getComponentSign(parseData);
|
104
|
+
if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign) && _params.renderDisplayType === DisplayTypeEnum.popup) {
|
105
|
+
return Promise.reject({
|
106
|
+
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
|
107
|
+
message: "unsupported payment method"
|
108
|
+
});
|
109
|
+
}
|
110
|
+
if (_this.options.product === ProductSceneEnum.ELEMENT_ADDRESS) {
|
111
|
+
componentSign = ComponentSignEnum.ELEMENT_ADDRESS;
|
112
|
+
}
|
113
|
+
if (componentSign === ComponentSignEnum.NONE) {
|
114
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
115
|
+
return Promise.reject({
|
116
|
+
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
|
117
|
+
message: "Abnormal response data, interface failure, or unsupported payment method"
|
118
|
+
});
|
119
|
+
}
|
120
|
+
if (parseData && parseData !== null && parseData !== void 0 && parseData.securityConfig) {
|
121
|
+
var _parseData$paymentSes;
|
122
|
+
var product = parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene;
|
123
|
+
getOrSetStorageId(getSecurityConfigStorageKey(product), JSON.stringify(parseData === null || parseData === void 0 ? void 0 : parseData.securityConfig));
|
124
|
+
}
|
125
|
+
_params.sessionData = sessionData;
|
126
|
+
_params.paymentSessionMetaData = parseData;
|
127
|
+
return Promise.resolve({
|
128
|
+
iframeNodesParams: _params,
|
129
|
+
componentSign: componentSign
|
130
|
+
});
|
131
|
+
};
|
132
|
+
export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
133
|
+
_inherits(AMSComponent, _CoreInstance);
|
134
|
+
var _super = _createSuper(AMSComponent);
|
135
|
+
function AMSComponent(options) {
|
136
|
+
var _this2;
|
137
|
+
_classCallCheck(this, AMSComponent);
|
138
|
+
_this2 = _super.call(this, options);
|
139
|
+
// Instantiate the plug-in and set render
|
140
|
+
_defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
|
141
|
+
_defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
|
142
|
+
_defineProperty(_assertThisInitialized(_this2), "timer", void 0);
|
143
|
+
var ComponentPlugin = new ComponentApp({
|
144
|
+
appVersion: options.appVersion
|
145
|
+
});
|
146
|
+
ComponentPlugin.setRender(createIframeNode);
|
147
|
+
ComponentPlugin.setPreloadRender(createPreloadIframeNode);
|
148
|
+
// Register Cashier Application Plug in
|
149
|
+
_this2._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
|
150
|
+
_this2._componentApp = _this2._getPlugin(COMPONENTPLUGINID);
|
151
|
+
_this2.registerBusAbility();
|
152
|
+
return _this2;
|
153
|
+
}
|
154
|
+
_createClass(AMSComponent, [{
|
155
|
+
key: "parameterInitAndCheck",
|
156
|
+
value: function parameterInitAndCheck(_ref) {
|
157
|
+
var params = _ref.params,
|
158
|
+
selector = _ref.selector,
|
159
|
+
renderDisplayType = _ref.renderDisplayType;
|
160
|
+
this.options.mode = modeEnum.component;
|
161
|
+
this.options.networkMode = this.options.networkMode || networkModeEnum.session;
|
162
|
+
var _params = Object.assign({
|
163
|
+
selector: selector,
|
164
|
+
renderDisplayType: renderDisplayType
|
165
|
+
}, params);
|
166
|
+
if (this.options.product !== ProductSceneEnum.ELEMENT_ADDRESS && _params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
|
167
|
+
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
|
168
|
+
}
|
169
|
+
if (this.options.networkMode === networkModeEnum.proxy) {
|
170
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
|
171
|
+
return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
|
172
|
+
}
|
173
|
+
return Promise.resolve(_params);
|
174
|
+
}
|
175
|
+
}, {
|
176
|
+
key: "pluginAppendIframe",
|
177
|
+
value: function () {
|
178
|
+
var _pluginAppendIframe = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(appendParams) {
|
179
|
+
var _ref2, paymentSessionMetaData, _ref3, paymentSessionFactor;
|
180
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
181
|
+
while (1) switch (_context.prev = _context.next) {
|
182
|
+
case 0:
|
183
|
+
_context.prev = 0;
|
184
|
+
_ref2 = appendParams || {}, paymentSessionMetaData = _ref2.iframeNodesParams.paymentSessionMetaData;
|
185
|
+
_ref3 = paymentSessionMetaData || {}, paymentSessionFactor = _ref3.paymentSessionFactor;
|
186
|
+
_context.next = 5;
|
187
|
+
return loadChannelPneumaticControl(paymentSessionFactor, this.logger);
|
188
|
+
case 5:
|
189
|
+
return _context.abrupt("return", this._componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams));
|
190
|
+
case 8:
|
191
|
+
_context.prev = 8;
|
192
|
+
_context.t0 = _context["catch"](0);
|
193
|
+
return _context.abrupt("return", Promise.reject(_context.t0));
|
194
|
+
case 11:
|
195
|
+
case "end":
|
196
|
+
return _context.stop();
|
197
|
+
}
|
198
|
+
}, _callee, this, [[0, 8]]);
|
199
|
+
}));
|
200
|
+
function pluginAppendIframe(_x) {
|
201
|
+
return _pluginAppendIframe.apply(this, arguments);
|
202
|
+
}
|
203
|
+
return pluginAppendIframe;
|
204
|
+
}()
|
205
|
+
}, {
|
206
|
+
key: "savePreviousChannel",
|
207
|
+
value: function savePreviousChannel(iframeNodesParams) {
|
208
|
+
var _ref4 = iframeNodesParams || {},
|
209
|
+
_ref4$paymentSessionM = _ref4.paymentSessionMetaData.paymentSessionConfig,
|
210
|
+
_ref4$paymentSessionM2 = _ref4$paymentSessionM.productScene,
|
211
|
+
productScene = _ref4$paymentSessionM2 === void 0 ? '' : _ref4$paymentSessionM2,
|
212
|
+
_ref4$paymentSessionM3 = _ref4$paymentSessionM.paymentMethodCategoryType,
|
213
|
+
paymentMethodCategoryType = _ref4$paymentSessionM3 === void 0 ? '' : _ref4$paymentSessionM3,
|
214
|
+
_ref4$paymentSessionM4 = _ref4$paymentSessionM.productSceneVersion,
|
215
|
+
productSceneVersion = _ref4$paymentSessionM4 === void 0 ? '' : _ref4$paymentSessionM4;
|
216
|
+
var channelType = "".concat(productScene, "_").concat(paymentMethodCategoryType);
|
217
|
+
if (productScene && paymentMethodCategoryType && productSceneVersion) {
|
218
|
+
if (Array.isArray(this.channelType) && this.channelType.includes(channelType) && this.productSceneVersion === productSceneVersion) {
|
219
|
+
this.logger.logInfo({
|
220
|
+
title: 'preload_match'
|
221
|
+
}, {
|
222
|
+
preloadChannel: this.channelType,
|
223
|
+
preloadVersion: this.productSceneVersion,
|
224
|
+
sessionDataChannel: channelType,
|
225
|
+
sessionDataVersion: productSceneVersion
|
226
|
+
});
|
227
|
+
} else {
|
228
|
+
this.logger.logInfo({
|
229
|
+
title: 'preload_no_match'
|
230
|
+
}, {
|
231
|
+
preloadChannel: this.channelType,
|
232
|
+
preloadVersion: this.productSceneVersion,
|
233
|
+
sessionDataChannel: channelType,
|
234
|
+
sessionDataVersion: productSceneVersion
|
235
|
+
});
|
236
|
+
}
|
237
|
+
var previousChannel = {
|
238
|
+
channelType: channelType === ComponentSignEnum.VAULTING_CARD ? ComponentSignEnum.CASHIER_PAYMENT_CARD : channelType,
|
239
|
+
productSceneVersion: productSceneVersion
|
240
|
+
};
|
241
|
+
localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
|
242
|
+
}
|
243
|
+
}
|
244
|
+
/**
|
245
|
+
* 初始化 Bus总线的能力
|
246
|
+
*/
|
247
|
+
}, {
|
248
|
+
key: "registerBusAbility",
|
249
|
+
value: function registerBusAbility() {
|
250
|
+
var _this$originOptions,
|
251
|
+
_this3 = this;
|
252
|
+
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== EnvironmentEnum.prod, this.logger);
|
253
|
+
BusManager.clear();
|
254
|
+
BusManager.addInterceptor({
|
255
|
+
onPublishException: function onPublishException(message, e) {
|
256
|
+
_this3.logger.logError({
|
257
|
+
title: 'onBusPublishException'
|
258
|
+
}, _objectSpread(_objectSpread({}, message), {}, {
|
259
|
+
errorMessage: JSON.stringify(e)
|
260
|
+
}));
|
261
|
+
}
|
262
|
+
});
|
263
|
+
// subscribe basic ablility
|
264
|
+
BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
|
265
|
+
var _this3$_componentApp;
|
266
|
+
(_this3$_componentApp = _this3._componentApp) === null || _this3$_componentApp === void 0 || (_this3$_componentApp = _this3$_componentApp.AMSSDK) === null || _this3$_componentApp === void 0 || _this3$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
|
267
|
+
}));
|
268
|
+
BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
|
269
|
+
var _this3$_componentApp2;
|
270
|
+
return (_this3$_componentApp2 = _this3._componentApp) === null || _this3$_componentApp2 === void 0 ? void 0 : _this3$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
|
271
|
+
}));
|
272
|
+
BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
273
|
+
// subscribe plugin
|
274
|
+
BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
|
275
|
+
BusManager.subscribe(new PaypalBusSubscriber(this.logger));
|
276
|
+
|
277
|
+
// register bus plugin
|
278
|
+
ExtendPlugin.forEach(function (item) {
|
279
|
+
var _item$busActionNames;
|
280
|
+
if (item !== null && item !== void 0 && item.busSubscriber) {
|
281
|
+
BusManager.subscribe(item === null || item === void 0 ? void 0 : item.busSubscriber);
|
282
|
+
}
|
283
|
+
var paymentChannelMatcher = item.paymentChannelMatcher;
|
284
|
+
if (paymentChannelMatcher) {
|
285
|
+
_this3._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
|
286
|
+
}
|
287
|
+
var sessionMatcher = item.sessionMatcher;
|
288
|
+
if (sessionMatcher) {
|
289
|
+
var pluginKey = sessionMatcher.productScene + sessionMatcher.productSceneVersion + sessionMatcher.paymentMethodCategoryType;
|
290
|
+
if (sessionMatcher.paymentMethodTypes) {
|
291
|
+
sessionMatcher.paymentMethodTypes.forEach(function (paymentMethodType) {
|
292
|
+
var subPluginKey = pluginKey + paymentMethodType;
|
293
|
+
_this3._registerPlugin(subPluginKey, item.busActionNames);
|
294
|
+
});
|
295
|
+
} else {
|
296
|
+
_this3._registerPlugin(pluginKey, item.busActionNames);
|
297
|
+
}
|
298
|
+
}
|
299
|
+
var optInit = item === null || item === void 0 || (_item$busActionNames = item.busActionNames) === null || _item$busActionNames === void 0 ? void 0 : _item$busActionNames.optional_init;
|
300
|
+
if (optInit) {
|
301
|
+
BusManager.publish(new BusMessage(optInit, JSON.stringify(_this3.originOptions)));
|
302
|
+
}
|
303
|
+
});
|
304
|
+
}
|
305
|
+
/**
|
306
|
+
* To determine whether the corresponding payment method is available,
|
307
|
+
* only the channel described in the document will be called, and it will be returned as available by default
|
308
|
+
* @param paymentMethod - described in the document
|
309
|
+
* @param subPaymentMethod - described in the document
|
310
|
+
* @returns
|
311
|
+
*/
|
312
|
+
}, {
|
313
|
+
key: "canMakePayments",
|
314
|
+
value: function canMakePayments(paymentMethod, subPaymentMethod) {
|
315
|
+
var _this4 = this;
|
316
|
+
// 判断支付方式是否可用
|
317
|
+
return new Promise(function (resolve) {
|
318
|
+
var _this4$_getPlugin;
|
319
|
+
if (!paymentMethod) {
|
320
|
+
return resolve(true);
|
321
|
+
}
|
322
|
+
var actionName = (_this4$_getPlugin = _this4._getPlugin(paymentMethod)) === null || _this4$_getPlugin === void 0 ? void 0 : _this4$_getPlugin.canMakePayments;
|
323
|
+
if (actionName && BusManager.isSubscribed(actionName)) {
|
324
|
+
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
325
|
+
paymentMethod: paymentMethod,
|
326
|
+
subPaymentMethod: subPaymentMethod
|
327
|
+
})), {
|
328
|
+
fallback: false
|
329
|
+
}).then(function (message) {
|
330
|
+
resolve(message.getJSONObject());
|
331
|
+
}).catch(function (e) {
|
332
|
+
_this4.logger.logInfo({
|
333
|
+
title: 'canMakePayments_error'
|
334
|
+
}, {
|
335
|
+
params: JSON.stringify(e)
|
336
|
+
});
|
337
|
+
resolve(false);
|
338
|
+
});
|
339
|
+
} else {
|
340
|
+
resolve(true);
|
341
|
+
}
|
342
|
+
});
|
343
|
+
}
|
344
|
+
/**
|
345
|
+
* @description Create component application
|
346
|
+
* @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
347
|
+
*/
|
348
|
+
}, {
|
349
|
+
key: "createComponent",
|
350
|
+
value: function createComponent(params) {
|
351
|
+
var _this5 = this;
|
352
|
+
this.clearPreloadIframe();
|
353
|
+
this.logger.setComponentStartTime(Date.now());
|
354
|
+
return this.parameterInitAndCheck({
|
355
|
+
params: params,
|
356
|
+
renderDisplayType: DisplayTypeEnum.popup
|
357
|
+
}).then(function (_params) {
|
358
|
+
return handleParams(_params, _this5);
|
359
|
+
}).catch(function (error) {
|
360
|
+
_this5.logger.logError({
|
361
|
+
title: 'sdk_error_parameter'
|
362
|
+
}, {
|
363
|
+
params: JSON.stringify(params)
|
364
|
+
}).send();
|
365
|
+
_this5._eventCenter.emit(EVENT.error.name, error);
|
366
|
+
return Promise.reject(error);
|
367
|
+
}).then(function (appendParams) {
|
368
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
369
|
+
_this5.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
370
|
+
return _this5.createComponentProcess(appendParams);
|
371
|
+
});
|
372
|
+
}
|
373
|
+
}, {
|
374
|
+
key: "createComponentProcess",
|
375
|
+
value: function createComponentProcess(appendParams) {
|
376
|
+
var _this$getBusActionNam;
|
377
|
+
this._appendParams = appendParams;
|
378
|
+
var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.createComponent;
|
379
|
+
if (actionName && BusManager.isSubscribed(actionName)) {
|
380
|
+
// 执行出错了,在通用拦截器返回
|
381
|
+
BusManager.publish(new BusMessage(actionName, JSON.stringify({
|
382
|
+
appendParams: appendParams,
|
383
|
+
options: this.originOptions
|
384
|
+
})));
|
385
|
+
return Promise.resolve();
|
386
|
+
}
|
387
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
388
|
+
this.savePreviousChannel(iframeNodesParams);
|
389
|
+
return this.pluginAppendIframe(appendParams);
|
390
|
+
}
|
391
|
+
}, {
|
392
|
+
key: "preloadComponent",
|
393
|
+
value: function preloadComponent(channelType, productSceneVersion) {
|
394
|
+
var _this6 = this;
|
395
|
+
this.channelType = channelType;
|
396
|
+
this.productSceneVersion = productSceneVersion;
|
397
|
+
var MAX_CLEAR_TIME = 10000;
|
398
|
+
if (Array.isArray(channelType)) {
|
399
|
+
for (var i = 0; i < channelType.length; i++) {
|
400
|
+
this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
|
401
|
+
}
|
402
|
+
} else {
|
403
|
+
this.logger.logError({
|
404
|
+
title: 'performance_optimization_channelType_error'
|
405
|
+
}, {
|
406
|
+
channelType: channelType
|
407
|
+
});
|
408
|
+
}
|
409
|
+
this.timer = setTimeout(function () {
|
410
|
+
_this6.clearPreloadIframe(true);
|
411
|
+
}, MAX_CLEAR_TIME);
|
412
|
+
}
|
413
|
+
}, {
|
414
|
+
key: "clearPreloadIframe",
|
415
|
+
value: function clearPreloadIframe() {
|
416
|
+
var isTimeOut = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
417
|
+
!isTimeOut && clearTimeout(this.timer);
|
418
|
+
if (Array.isArray(this.channelType)) {
|
419
|
+
for (var i = 0; i < this.channelType.length; i++) {
|
420
|
+
var iframe = document.getElementById("ams-checkout-component-".concat(this.channelType[i], "-").concat(this.productSceneVersion));
|
421
|
+
iframe && document.body.removeChild(iframe);
|
422
|
+
}
|
423
|
+
}
|
424
|
+
if (!isTimeOut) {
|
425
|
+
this.logger.logInfo({
|
426
|
+
title: 'performance_optimization_clearPreloadIframe'
|
427
|
+
});
|
428
|
+
} else {
|
429
|
+
this.logger.logInfo({
|
430
|
+
title: 'performance_optimization_clearPreloadIframe_timeout'
|
431
|
+
});
|
432
|
+
}
|
433
|
+
}
|
434
|
+
/**
|
435
|
+
* @description Create and render components in the specified element area
|
436
|
+
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
437
|
+
* @param selector - Necessary element selector ID
|
438
|
+
*/
|
439
|
+
}, {
|
440
|
+
key: "mountComponent",
|
441
|
+
value: function mountComponent(params, selector) {
|
442
|
+
var _this7 = this;
|
443
|
+
this.clearPreloadIframe();
|
444
|
+
this.logger.setComponentStartTime(Date.now());
|
445
|
+
return this.parameterInitAndCheck({
|
446
|
+
params: params,
|
447
|
+
renderDisplayType: DisplayTypeEnum.inline,
|
448
|
+
selector: selector
|
449
|
+
}).then(function (_params) {
|
450
|
+
return handleParams(_params, _this7);
|
451
|
+
}).catch(function (error) {
|
452
|
+
_this7.logger.logError({
|
453
|
+
title: 'sdk_error_parameter'
|
454
|
+
}, {
|
455
|
+
params: JSON.stringify(params)
|
456
|
+
}).send();
|
457
|
+
_this7._eventCenter.emit(EVENT.error.name, error);
|
458
|
+
return Promise.reject(error);
|
459
|
+
}).then(function (appendParams) {
|
460
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
461
|
+
_this7.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
462
|
+
return _this7.mountComponentProcess(appendParams);
|
463
|
+
});
|
464
|
+
}
|
465
|
+
}, {
|
466
|
+
key: "mountComponentProcess",
|
467
|
+
value: function mountComponentProcess(appendParams) {
|
468
|
+
var _this$getBusActionNam2;
|
469
|
+
this._appendParams = appendParams;
|
470
|
+
var actionName = (_this$getBusActionNam2 = this.getBusActionNames()) === null || _this$getBusActionNam2 === void 0 ? void 0 : _this$getBusActionNam2.mountComponent;
|
471
|
+
if (actionName && BusManager.isSubscribed(actionName)) {
|
472
|
+
// 执行出错了,在通用拦截器返回
|
473
|
+
BusManager.publish(new BusMessage(actionName, JSON.stringify({
|
474
|
+
appendParams: appendParams,
|
475
|
+
options: this.originOptions
|
476
|
+
})));
|
477
|
+
return Promise.resolve();
|
478
|
+
}
|
479
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
480
|
+
if (this.options.product !== ProductSceneEnum.ELEMENT_ADDRESS) {
|
481
|
+
this.savePreviousChannel(iframeNodesParams);
|
482
|
+
}
|
483
|
+
return this.pluginAppendIframe(appendParams);
|
484
|
+
}
|
485
|
+
/**
|
486
|
+
* @description Execute payment submission process
|
487
|
+
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
488
|
+
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
489
|
+
*/
|
490
|
+
}, {
|
491
|
+
key: "submit",
|
492
|
+
value: function submit(data) {
|
493
|
+
var _this8 = this;
|
494
|
+
return new Promise(function (resolve, reject) {
|
495
|
+
try {
|
496
|
+
var _this8$getBusActionNa;
|
497
|
+
var eventCallbackId = uuid();
|
498
|
+
_this8.logger.logInfo({
|
499
|
+
title: 'sdk_event_apiSubmit'
|
500
|
+
});
|
501
|
+
var actionName = (_this8$getBusActionNa = _this8.getBusActionNames()) === null || _this8$getBusActionNa === void 0 ? void 0 : _this8$getBusActionNa.submit;
|
502
|
+
if (actionName && BusManager.isSubscribed(actionName)) {
|
503
|
+
// 执行出错了,在通用拦截器返回
|
504
|
+
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
505
|
+
appendParams: _this8._appendParams,
|
506
|
+
options: _this8.originOptions,
|
507
|
+
data: data
|
508
|
+
}))).then(function (busMessage) {
|
509
|
+
resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
|
510
|
+
});
|
511
|
+
} else {
|
512
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
513
|
+
_this8._eventCenter.once(eventCallbackId, function (_data) {
|
514
|
+
resolve(_data);
|
515
|
+
});
|
516
|
+
_this8._componentApp.dispatchToApp({
|
517
|
+
context: {
|
518
|
+
event: 'submitPay',
|
519
|
+
eventCallbackId: eventCallbackId,
|
520
|
+
data: data
|
521
|
+
}
|
522
|
+
});
|
523
|
+
}
|
524
|
+
} catch (error) {
|
525
|
+
reject(error);
|
526
|
+
}
|
527
|
+
});
|
528
|
+
}
|
529
|
+
}]);
|
530
|
+
return AMSComponent;
|
531
|
+
}(CoreInstance);
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { IcreatePaymentParams, IoptionsParams } from '../../types';
|
2
|
+
export declare const mixinDropInConstructor: (options: IoptionsParams, context: any) => void;
|
3
|
+
/**
|
4
|
+
* @description Create checkout application
|
5
|
+
* @description drop-in
|
6
|
+
*/
|
7
|
+
export declare const createPayment: (params: IcreatePaymentParams) => Promise<void>;
|
8
|
+
export interface IcreatePaymentFunc {
|
9
|
+
(params: IcreatePaymentParams): Promise<void>;
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* @description Take action on the interface result of payment submission
|
13
|
+
* @description drop-in
|
14
|
+
*/
|
15
|
+
export declare const confirmPayment: (result: any) => Promise<void>;
|
16
|
+
export interface IconfirmPaymentFunc {
|
17
|
+
(result: any): Promise<void>;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* @description Subscribe to the message of the cashier application plug-in
|
21
|
+
*/
|
22
|
+
export declare const _subscribeFromCheckoutPlugin: () => void;
|