@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,816 @@
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
3
|
+
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."); }
|
4
|
+
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); }
|
5
|
+
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; }
|
6
|
+
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; } }
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
8
|
+
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; }
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
11
|
+
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; }
|
12
|
+
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; }
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
14
|
+
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); } }
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
16
|
+
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; }
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
18
|
+
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); }
|
19
|
+
import { AntomSDKCore } from "../../../foundation/core";
|
20
|
+
import PackageJson from "../../../../package.json";
|
21
|
+
import { ConnectErrorCode, ElementPaymentEvent, ElementPaymentMethod, EventCallbackCode, ProductSceneEnum } from "../../../types";
|
22
|
+
import { parseSessionData } from "../index";
|
23
|
+
import { ElementAddressComponent } from "./components/address";
|
24
|
+
import { ElementAuthComponent } from "./components/auth";
|
25
|
+
import { ElementPaymentComponent } from "./components/payment";
|
26
|
+
import { EVENT as ConstantEvent } from "../../../constant";
|
27
|
+
// import { oneAccount, sdkAction, submitResult } from './mock';
|
28
|
+
|
29
|
+
import { addressTheme, ELEMENT_ENVIRONMENT, ThemeType } from "./type";
|
30
|
+
var ElementProcessor = /*#__PURE__*/function () {
|
31
|
+
function ElementProcessor(options) {
|
32
|
+
_classCallCheck(this, ElementProcessor);
|
33
|
+
_defineProperty(this, "requestService", void 0);
|
34
|
+
// 接口服务
|
35
|
+
_defineProperty(this, "_options", void 0);
|
36
|
+
this._options = options;
|
37
|
+
}
|
38
|
+
_createClass(ElementProcessor, [{
|
39
|
+
key: "init",
|
40
|
+
value: function init() {
|
41
|
+
var elementContainer = new AntomSDKCore();
|
42
|
+
elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', undefined);
|
43
|
+
elementContainer.init({}, ProductSceneEnum.ELEMENT_PAYMENT);
|
44
|
+
var serviceProvider = elementContainer.getServiceProvider();
|
45
|
+
this.requestService = serviceProvider.getService('Requester');
|
46
|
+
}
|
47
|
+
}, {
|
48
|
+
key: "sdkActionQuery",
|
49
|
+
value: function sdkActionQuery() {
|
50
|
+
var _this = this;
|
51
|
+
return new Promise(function (resolve, reject) {
|
52
|
+
// setTimeout(() => {
|
53
|
+
// resolve(sdkAction)
|
54
|
+
// }, 2000);
|
55
|
+
// return;
|
56
|
+
var hostSign = _this._options.sessionData.split('&&')[1] || '';
|
57
|
+
_this.requestService.request({
|
58
|
+
paymentSessionConfig: _this._options.paymentSessionConfig,
|
59
|
+
paymentSessionData: _this._options.sessionData
|
60
|
+
}, {
|
61
|
+
env: _this._options.environment,
|
62
|
+
envInfo: {
|
63
|
+
locale: _this._options.locale
|
64
|
+
},
|
65
|
+
hostSign: hostSign,
|
66
|
+
timeout: 300000,
|
67
|
+
// TODO dev环境接口超时
|
68
|
+
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
69
|
+
}).then(function (result) {
|
70
|
+
if (!result.success) {
|
71
|
+
reject('sdk.action.query Request Error');
|
72
|
+
}
|
73
|
+
resolve(result);
|
74
|
+
}, function () {
|
75
|
+
reject('sdk.action.query Request Error');
|
76
|
+
});
|
77
|
+
});
|
78
|
+
}
|
79
|
+
}, {
|
80
|
+
key: "oneAccountQuery",
|
81
|
+
value: function oneAccountQuery() {
|
82
|
+
var _this2 = this;
|
83
|
+
return new Promise(function (resolve, reject) {
|
84
|
+
// setTimeout(() => {
|
85
|
+
// resolve(oneAccount)
|
86
|
+
// }, 2000);
|
87
|
+
// return;
|
88
|
+
_this2.requestService.request({
|
89
|
+
paymentSessionConfig: _this2._options.paymentSessionConfig,
|
90
|
+
paymentSessionData: _this2._options.sessionData,
|
91
|
+
accountInfo: {
|
92
|
+
email: ''
|
93
|
+
}
|
94
|
+
}, {
|
95
|
+
env: _this2._options.environment,
|
96
|
+
envInfo: {
|
97
|
+
locale: _this2._options.locale
|
98
|
+
},
|
99
|
+
timeout: 300000,
|
100
|
+
// TODO dev环境接口超时
|
101
|
+
'Operation-Type': 'com.ipay.iexpfront.one.account.query'
|
102
|
+
}).then(function (result) {
|
103
|
+
resolve(result);
|
104
|
+
}, function () {
|
105
|
+
reject('one.account.query Request Error');
|
106
|
+
});
|
107
|
+
});
|
108
|
+
}
|
109
|
+
}, {
|
110
|
+
key: "startBizFlow",
|
111
|
+
value: function startBizFlow() {
|
112
|
+
var _this3 = this;
|
113
|
+
return new Promise(function (resolve) {
|
114
|
+
if (_this3._options.isConnect) {
|
115
|
+
Promise.all([_this3.oneAccountQuery(), _this3.sdkActionQuery()]).then(function (result) {
|
116
|
+
resolve({
|
117
|
+
behaviorType: 'NONE',
|
118
|
+
payload: {},
|
119
|
+
data: {
|
120
|
+
success: true,
|
121
|
+
oneAccountRes: result[0],
|
122
|
+
sdkActionRes: result[1]
|
123
|
+
}
|
124
|
+
});
|
125
|
+
}, function (error) {
|
126
|
+
resolve({
|
127
|
+
behaviorType: 'NONE',
|
128
|
+
payload: {},
|
129
|
+
data: {
|
130
|
+
success: false,
|
131
|
+
errorMsg: error
|
132
|
+
}
|
133
|
+
});
|
134
|
+
});
|
135
|
+
} else {
|
136
|
+
resolve({
|
137
|
+
behaviorType: 'NONE',
|
138
|
+
payload: {},
|
139
|
+
data: {
|
140
|
+
success: true
|
141
|
+
}
|
142
|
+
});
|
143
|
+
}
|
144
|
+
});
|
145
|
+
}
|
146
|
+
}]);
|
147
|
+
return ElementProcessor;
|
148
|
+
}();
|
149
|
+
export var ElementComponent = /*#__PURE__*/function () {
|
150
|
+
// address事件回调
|
151
|
+
|
152
|
+
function ElementComponent(options) {
|
153
|
+
var _this4 = this;
|
154
|
+
_classCallCheck(this, ElementComponent);
|
155
|
+
_defineProperty(this, "parseData", void 0);
|
156
|
+
// sessionData 解析出来的数据
|
157
|
+
_defineProperty(this, "loading", void 0);
|
158
|
+
// mount loading
|
159
|
+
_defineProperty(this, "sessionData", void 0);
|
160
|
+
// sessionData 解析出来的数据
|
161
|
+
_defineProperty(this, "elementContainer", void 0);
|
162
|
+
// element
|
163
|
+
_defineProperty(this, "authBase", void 0);
|
164
|
+
// auth element
|
165
|
+
_defineProperty(this, "addressBase", void 0);
|
166
|
+
// address element
|
167
|
+
_defineProperty(this, "paymentBase", void 0);
|
168
|
+
// payment element
|
169
|
+
_defineProperty(this, "_options", void 0);
|
170
|
+
// element 入参
|
171
|
+
_defineProperty(this, "eventService", void 0);
|
172
|
+
// 消息服务
|
173
|
+
_defineProperty(this, "requestService", void 0);
|
174
|
+
// 接口服务
|
175
|
+
_defineProperty(this, "sdkActionRes", void 0);
|
176
|
+
// sdk aciton接口返回
|
177
|
+
_defineProperty(this, "oneAccountRes", void 0);
|
178
|
+
// one account接口返回
|
179
|
+
_defineProperty(this, "launchSource", void 0);
|
180
|
+
// launch 来源记录
|
181
|
+
_defineProperty(this, "isConnect", void 0);
|
182
|
+
// 当前sessionData是否connect模式
|
183
|
+
_defineProperty(this, "iframeSrc", void 0);
|
184
|
+
// iframe src记录
|
185
|
+
_defineProperty(this, "mountOptions", void 0);
|
186
|
+
// 组件mount配置记录
|
187
|
+
_defineProperty(this, "iframes", void 0);
|
188
|
+
// iframs合集
|
189
|
+
_defineProperty(this, "componentsCount", void 0);
|
190
|
+
// mount 渲染了多少个element
|
191
|
+
_defineProperty(this, "eventCallback", void 0);
|
192
|
+
// 渲染地址组件
|
193
|
+
_defineProperty(this, "mountAddress", function (renderOptions, sdkSelector) {
|
194
|
+
var _renderOptions$appear, _this4$_options;
|
195
|
+
var _mountParams = {
|
196
|
+
appearance: {
|
197
|
+
themeType: addressTheme[(renderOptions === null || renderOptions === void 0 || (_renderOptions$appear = renderOptions.appearance) === null || _renderOptions$appear === void 0 ? void 0 : _renderOptions$appear.theme) || ((_this4$_options = _this4._options) === null || _this4$_options === void 0 || (_this4$_options = _this4$_options.appearance) === null || _this4$_options === void 0 ? void 0 : _this4$_options.theme) || ThemeType.Default]
|
198
|
+
},
|
199
|
+
configParams: _objectSpread({
|
200
|
+
needEditBackBtn: _this4.isConnect,
|
201
|
+
autoSaveAsDefaultAddress: _this4.isConnect,
|
202
|
+
editingNeedShippingQuery: _this4.isConnect,
|
203
|
+
showTitle: _this4.isConnect
|
204
|
+
}, renderOptions.configParams),
|
205
|
+
prefillValue: renderOptions.prefillValue
|
206
|
+
};
|
207
|
+
_this4.mountOptions[ElementPaymentMethod.ADDRESS_ELEMENT] = _mountParams;
|
208
|
+
_this4.addressBase.mount(_this4._options.sessionData, _objectSpread({
|
209
|
+
selector: sdkSelector,
|
210
|
+
elementProps: renderOptions.elementProps
|
211
|
+
}, _mountParams)).then(function (result) {
|
212
|
+
if (!result) {
|
213
|
+
var _this4$_options$onEve, _this4$_options2;
|
214
|
+
(_this4$_options$onEve = (_this4$_options2 = _this4._options).onEventCallback) === null || _this4$_options$onEve === void 0 || _this4$_options$onEve.call(_this4$_options2, {
|
215
|
+
code: EventCallbackCode.Failed,
|
216
|
+
message: 'Address Component loading failed'
|
217
|
+
});
|
218
|
+
return undefined;
|
219
|
+
}
|
220
|
+
_this4.eventService.addIFrame(result);
|
221
|
+
_this4.iframes[ElementPaymentMethod.ADDRESS_ELEMENT] = result;
|
222
|
+
});
|
223
|
+
return {
|
224
|
+
on: function on(event, callback) {
|
225
|
+
_this4.registerEventListener(ElementPaymentMethod.ADDRESS_ELEMENT, event, callback);
|
226
|
+
}
|
227
|
+
};
|
228
|
+
});
|
229
|
+
// 渲染卡支付组件
|
230
|
+
_defineProperty(this, "mountPayment", function (renderOptions, sdkSelector) {
|
231
|
+
var _this4$_options3;
|
232
|
+
var _mountParams = {
|
233
|
+
appearance: renderOptions.appearance || ((_this4$_options3 = _this4._options) === null || _this4$_options3 === void 0 ? void 0 : _this4$_options3.appearance) || {
|
234
|
+
theme: ThemeType.Default
|
235
|
+
}
|
236
|
+
};
|
237
|
+
_this4.mountOptions[ElementPaymentMethod.PAYMENT_ELEMENT] = _mountParams;
|
238
|
+
_this4.paymentBase.mount(_this4._options.sessionData, _objectSpread({
|
239
|
+
selector: sdkSelector,
|
240
|
+
elementProps: renderOptions.elementProps
|
241
|
+
}, _mountParams)).then(function (result) {
|
242
|
+
if (!result) {
|
243
|
+
var _this4$_options$onEve2, _this4$_options4;
|
244
|
+
(_this4$_options$onEve2 = (_this4$_options4 = _this4._options).onEventCallback) === null || _this4$_options$onEve2 === void 0 || _this4$_options$onEve2.call(_this4$_options4, {
|
245
|
+
code: EventCallbackCode.Failed,
|
246
|
+
message: 'Payment Component loading failed'
|
247
|
+
});
|
248
|
+
return undefined;
|
249
|
+
}
|
250
|
+
_this4.eventService.addIFrame(result);
|
251
|
+
_this4.iframes[ElementPaymentMethod.PAYMENT_ELEMENT] = result;
|
252
|
+
});
|
253
|
+
return {};
|
254
|
+
});
|
255
|
+
// submit提交非RISK_REJECT错误
|
256
|
+
_defineProperty(this, "onAfterSubmitFunc", function (target, params) {
|
257
|
+
_this4.eventService.emitAndListen({
|
258
|
+
event: ElementPaymentEvent.AFTER_SUBMIT,
|
259
|
+
data: {
|
260
|
+
target: target,
|
261
|
+
source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
262
|
+
params: params
|
263
|
+
}
|
264
|
+
}, function () {});
|
265
|
+
});
|
266
|
+
// submit提交 失败,清空组件数据
|
267
|
+
_defineProperty(this, "onSubmitRiskFunc", function (target) {
|
268
|
+
_this4.eventService.emitAndListen({
|
269
|
+
event: ElementPaymentEvent.SUBMIT_RISK,
|
270
|
+
data: {
|
271
|
+
target: target,
|
272
|
+
source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
273
|
+
params: {}
|
274
|
+
}
|
275
|
+
}, function () {});
|
276
|
+
});
|
277
|
+
// 发起支付
|
278
|
+
_defineProperty(this, "onSubmit", function (params) {
|
279
|
+
return new Promise(function (resolve) {
|
280
|
+
var paymentSessionConfig = _this4.parseData.paymentSessionConfig;
|
281
|
+
console.log('element submit params ------', _objectSpread({
|
282
|
+
paymentSessionConfig: paymentSessionConfig,
|
283
|
+
paymentSessionData: _this4.sessionData
|
284
|
+
}, params));
|
285
|
+
_this4.requestService.request(_objectSpread({
|
286
|
+
paymentSessionConfig: paymentSessionConfig,
|
287
|
+
paymentSessionData: _this4.sessionData
|
288
|
+
}, params), {
|
289
|
+
env: _this4._options.environment,
|
290
|
+
envInfo: {
|
291
|
+
locale: _this4._options.locale
|
292
|
+
},
|
293
|
+
timeout: 300000,
|
294
|
+
// TODO dev环境submit提交接口超时
|
295
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
296
|
+
}).then(function (result) {
|
297
|
+
var _result$codeFormViews, _result$actionForm;
|
298
|
+
if (result !== null && result !== void 0 && result.codeFormViews && result !== null && result !== void 0 && (_result$codeFormViews = result.codeFormViews) !== null && _result$codeFormViews !== void 0 && (_result$codeFormViews = _result$codeFormViews[0]) !== null && _result$codeFormViews !== void 0 && _result$codeFormViews.codeExpireTime && result !== null && result !== void 0 && result.actionForm && !(result !== null && result !== void 0 && (_result$actionForm = result.actionForm) !== null && _result$actionForm !== void 0 && _result$actionForm.paymentCodeExpireTime)) {
|
299
|
+
var _result$codeFormViews2;
|
300
|
+
result.actionForm.paymentCodeExpireTime = result === null || result === void 0 || (_result$codeFormViews2 = result.codeFormViews) === null || _result$codeFormViews2 === void 0 || (_result$codeFormViews2 = _result$codeFormViews2[0]) === null || _result$codeFormViews2 === void 0 ? void 0 : _result$codeFormViews2.codeExpireTime;
|
301
|
+
}
|
302
|
+
if (result.errorCode === ConnectErrorCode.RISK_REJECT) {
|
303
|
+
_this4.onSubmitRiskFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
|
304
|
+
_this4.onSubmitRiskFunc(ElementPaymentMethod.AUTH_ELEMENT);
|
305
|
+
_this4.onSubmitRiskFunc(ElementPaymentMethod.PAYMENT_ELEMENT);
|
306
|
+
} else {
|
307
|
+
_this4.onAfterSubmitFunc(ElementPaymentMethod.PAYMENT_ELEMENT, result);
|
308
|
+
}
|
309
|
+
resolve({
|
310
|
+
success: result.success,
|
311
|
+
msg: result.errorMessage
|
312
|
+
});
|
313
|
+
}, function () {
|
314
|
+
resolve({
|
315
|
+
success: false,
|
316
|
+
msg: 'submitPayByPaymentSession api error'
|
317
|
+
});
|
318
|
+
// this?._options?.onEventCallback?.({
|
319
|
+
// code: EventCallbackCode.Failed,
|
320
|
+
// message: 'submitPayByPaymentSession api error',
|
321
|
+
// });
|
322
|
+
});
|
323
|
+
});
|
324
|
+
});
|
325
|
+
// 发送validate消息
|
326
|
+
_defineProperty(this, "onValidateFunc", function (target, params) {
|
327
|
+
return new Promise(function (resolve) {
|
328
|
+
_this4.eventService.emitAndListen({
|
329
|
+
event: ElementPaymentEvent.VALIDATE,
|
330
|
+
data: {
|
331
|
+
target: target,
|
332
|
+
source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
333
|
+
params: params
|
334
|
+
}
|
335
|
+
}, function (result) {
|
336
|
+
resolve(result);
|
337
|
+
});
|
338
|
+
});
|
339
|
+
});
|
340
|
+
// 处理validate事件
|
341
|
+
_defineProperty(this, "validatePromiseFuncs", function () {
|
342
|
+
return new Promise( /*#__PURE__*/function () {
|
343
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
|
344
|
+
var params, _result$data, _result$data2, result, _result$data3, _result$data4, _result, _result2$data, _result2$data2, _result2$data3, _result2;
|
345
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
346
|
+
while (1) switch (_context.prev = _context.next) {
|
347
|
+
case 0:
|
348
|
+
params = {};
|
349
|
+
if (!_this4.launchSource.includes(ElementPaymentMethod.AUTH_ELEMENT)) {
|
350
|
+
_context.next = 9;
|
351
|
+
break;
|
352
|
+
}
|
353
|
+
_context.next = 4;
|
354
|
+
return _this4.onValidateFunc(ElementPaymentMethod.AUTH_ELEMENT);
|
355
|
+
case 4:
|
356
|
+
result = _context.sent;
|
357
|
+
console.log('element submit validate auth---------', result);
|
358
|
+
params.accountInfo = (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.data) === null || _result$data === void 0 ? void 0 : _result$data.accountInfo;
|
359
|
+
if (result !== null && result !== void 0 && (_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.success) {
|
360
|
+
_context.next = 9;
|
361
|
+
break;
|
362
|
+
}
|
363
|
+
return _context.abrupt("return", resolve(undefined));
|
364
|
+
case 9:
|
365
|
+
if (!_this4.launchSource.includes(ElementPaymentMethod.ADDRESS_ELEMENT)) {
|
366
|
+
_context.next = 17;
|
367
|
+
break;
|
368
|
+
}
|
369
|
+
_context.next = 12;
|
370
|
+
return _this4.onValidateFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
|
371
|
+
case 12:
|
372
|
+
_result = _context.sent;
|
373
|
+
console.log('element submit validate address---------', _result);
|
374
|
+
params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
|
375
|
+
if (_result !== null && _result !== void 0 && (_result$data4 = _result.data) !== null && _result$data4 !== void 0 && _result$data4.success) {
|
376
|
+
_context.next = 17;
|
377
|
+
break;
|
378
|
+
}
|
379
|
+
return _context.abrupt("return", resolve(undefined));
|
380
|
+
case 17:
|
381
|
+
if (!(_this4.launchSource.includes(ElementPaymentMethod.PAYMENT_ELEMENT) || !_this4.isConnect)) {
|
382
|
+
_context.next = 32;
|
383
|
+
break;
|
384
|
+
}
|
385
|
+
_context.prev = 18;
|
386
|
+
_context.next = 21;
|
387
|
+
return _this4.onValidateFunc(ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
388
|
+
case 21:
|
389
|
+
_result2 = _context.sent;
|
390
|
+
console.log('element submit validate payment---------', _result2, _this4.isConnect);
|
391
|
+
params.paymentFactors = (_result2$data = _result2.data) === null || _result2$data === void 0 || (_result2$data = _result2$data.data) === null || _result2$data === void 0 ? void 0 : _result2$data.paymentFactors;
|
392
|
+
params.paymentMethod = (_result2$data2 = _result2.data) === null || _result2$data2 === void 0 || (_result2$data2 = _result2$data2.data) === null || _result2$data2 === void 0 ? void 0 : _result2$data2.paymentMethod;
|
393
|
+
if (_result2 !== null && _result2 !== void 0 && (_result2$data3 = _result2.data) !== null && _result2$data3 !== void 0 && _result2$data3.success) {
|
394
|
+
_context.next = 27;
|
395
|
+
break;
|
396
|
+
}
|
397
|
+
return _context.abrupt("return", resolve(undefined));
|
398
|
+
case 27:
|
399
|
+
_context.next = 32;
|
400
|
+
break;
|
401
|
+
case 29:
|
402
|
+
_context.prev = 29;
|
403
|
+
_context.t0 = _context["catch"](18);
|
404
|
+
return _context.abrupt("return", resolve(undefined));
|
405
|
+
case 32:
|
406
|
+
// params.paymentFactors = paymentResult.data?.data.paymentFactors;
|
407
|
+
// params.paymentMethod = paymentResult.data?.data.paymentMethod;
|
408
|
+
resolve(params);
|
409
|
+
case 33:
|
410
|
+
case "end":
|
411
|
+
return _context.stop();
|
412
|
+
}
|
413
|
+
}, _callee, null, [[18, 29]]);
|
414
|
+
}));
|
415
|
+
return function (_x) {
|
416
|
+
return _ref.apply(this, arguments);
|
417
|
+
};
|
418
|
+
}());
|
419
|
+
});
|
420
|
+
var env = options.environment || ELEMENT_ENVIRONMENT.PROD;
|
421
|
+
this._options = _objectSpread(_objectSpread({}, options), {}, {
|
422
|
+
environment: env.toLocaleLowerCase()
|
423
|
+
});
|
424
|
+
this.eventCallback = _defineProperty(_defineProperty(_defineProperty({}, ElementPaymentMethod.ADDRESS_ELEMENT, {}), ElementPaymentMethod.AUTH_ELEMENT, {}), ElementPaymentMethod.PAYMENT_ELEMENT, {});
|
425
|
+
this.launchSource = [];
|
426
|
+
this.componentsCount = 0;
|
427
|
+
this.iframes = {};
|
428
|
+
this.mountOptions = {};
|
429
|
+
this.createElement();
|
430
|
+
}
|
431
|
+
|
432
|
+
// 初始化注册
|
433
|
+
_createClass(ElementComponent, [{
|
434
|
+
key: "createElement",
|
435
|
+
value: function createElement() {
|
436
|
+
var _parseData$connectFac,
|
437
|
+
_parseData$paymentSes,
|
438
|
+
_this5 = this;
|
439
|
+
var _parseSessionData = parseSessionData(this._options.sessionData),
|
440
|
+
_parseSessionData2 = _slicedToArray(_parseSessionData, 2),
|
441
|
+
parseData = _parseSessionData2[0],
|
442
|
+
sessionData = _parseSessionData2[1];
|
443
|
+
this.parseData = parseData;
|
444
|
+
this.sessionData = sessionData;
|
445
|
+
this.isConnect = ((_parseData$connectFac = parseData.connectFactor) === null || _parseData$connectFac === void 0 ? void 0 : _parseData$connectFac.enableConnect) && (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
446
|
+
this.elementContainer = new AntomSDKCore();
|
447
|
+
this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor({
|
448
|
+
paymentSessionConfig: parseData.paymentSessionConfig,
|
449
|
+
sessionData: sessionData,
|
450
|
+
environment: this._options.environment,
|
451
|
+
locale: this._options.locale,
|
452
|
+
isConnect: this.isConnect
|
453
|
+
}));
|
454
|
+
this.elementContainer.init({}, ProductSceneEnum.ELEMENT_PAYMENT);
|
455
|
+
this.elementContainer.startBizFlow({
|
456
|
+
paymentSession: this._options.sessionData
|
457
|
+
}).then(function () {
|
458
|
+
var _bizFlowBehavior$data;
|
459
|
+
if (!_this5.isConnect) return;
|
460
|
+
var bizFlowBehavior = _this5.elementContainer.getBizFlowBehavior();
|
461
|
+
if (!(bizFlowBehavior !== null && bizFlowBehavior !== void 0 && (_bizFlowBehavior$data = bizFlowBehavior.data) !== null && _bizFlowBehavior$data !== void 0 && _bizFlowBehavior$data.success)) {
|
462
|
+
var _this5$_options, _this5$_options$onEve, _bizFlowBehavior$data2;
|
463
|
+
_this5 === null || _this5 === void 0 || (_this5$_options = _this5._options) === null || _this5$_options === void 0 || (_this5$_options$onEve = _this5$_options.onEventCallback) === null || _this5$_options$onEve === void 0 || _this5$_options$onEve.call(_this5$_options, {
|
464
|
+
code: EventCallbackCode.Failed,
|
465
|
+
message: (bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data2 = bizFlowBehavior.data) === null || _bizFlowBehavior$data2 === void 0 ? void 0 : _bizFlowBehavior$data2.errorMsg) || 'start biz flow fail, please retry.'
|
466
|
+
});
|
467
|
+
} else {
|
468
|
+
var _bizFlowBehavior$data3, _bizFlowBehavior$data4;
|
469
|
+
_this5.oneAccountRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data3 = bizFlowBehavior.data) === null || _bizFlowBehavior$data3 === void 0 ? void 0 : _bizFlowBehavior$data3.oneAccountRes;
|
470
|
+
_this5.sdkActionRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data4 = bizFlowBehavior.data) === null || _bizFlowBehavior$data4 === void 0 ? void 0 : _bizFlowBehavior$data4.sdkActionRes;
|
471
|
+
_this5.afterInit();
|
472
|
+
}
|
473
|
+
});
|
474
|
+
this.iframeSrc = this.createIframeSrc(this._options.environment, this._options.version);
|
475
|
+
try {
|
476
|
+
// 注册 auth 邮箱模块
|
477
|
+
this.authBase = new ElementAuthComponent();
|
478
|
+
this.authBase.create({
|
479
|
+
environment: this._options.environment,
|
480
|
+
locale: this._options.locale
|
481
|
+
});
|
482
|
+
var serviceProvider = this.elementContainer.getServiceProvider();
|
483
|
+
this.eventService = serviceProvider.getService('EventCenter');
|
484
|
+
this.requestService = serviceProvider.getService('Requester');
|
485
|
+
// 注册 payment 卡支付模块
|
486
|
+
this.paymentBase = new ElementPaymentComponent();
|
487
|
+
this.paymentBase.create({
|
488
|
+
environment: this._options.environment,
|
489
|
+
locale: this._options.locale,
|
490
|
+
appVersion: this._options.version || ''
|
491
|
+
}, this.isConnect);
|
492
|
+
|
493
|
+
// 注册 address 地址模块
|
494
|
+
this.addressBase = new ElementAddressComponent();
|
495
|
+
this.addressBase.create({
|
496
|
+
environment: this._options.environment,
|
497
|
+
locale: this._options.locale,
|
498
|
+
appVersion: this._options.version || ''
|
499
|
+
}, this.isConnect);
|
500
|
+
} catch (error) {
|
501
|
+
var _this$_options$onEven, _this$_options;
|
502
|
+
(_this$_options$onEven = (_this$_options = this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
|
503
|
+
code: EventCallbackCode.Failed,
|
504
|
+
message: 'create sdk fail'
|
505
|
+
});
|
506
|
+
}
|
507
|
+
|
508
|
+
// 注册监听消息
|
509
|
+
this.addListener();
|
510
|
+
}
|
511
|
+
|
512
|
+
// iframe src生成方法
|
513
|
+
}, {
|
514
|
+
key: "createIframeSrc",
|
515
|
+
value: function createIframeSrc() {
|
516
|
+
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ELEMENT_ENVIRONMENT.DEV;
|
517
|
+
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PackageJson.version;
|
518
|
+
var baseUrl = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ELEMENT_ENVIRONMENT.DEV, 'http://dev.page.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.TEST, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.SIT, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PRE, 'https://pre.ac.alipay.com/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PROD, 'https://checkout.antom.com');
|
519
|
+
var _env = (env === null || env === void 0 ? void 0 : env.toLocaleUpperCase()) || ELEMENT_ENVIRONMENT.DEV;
|
520
|
+
var payment = "".concat(baseUrl[_env], "/elements/").concat(version, "/pages/element_payment/index.html");
|
521
|
+
try {
|
522
|
+
var expressCheckout = JSON.parse(JSON.parse(this.parseData.extendInfo).expressCheckout);
|
523
|
+
if (expressCheckout) {
|
524
|
+
payment = "".concat(baseUrl[_env], "/elements/").concat(version, "/pages/express_checkout/index.html");
|
525
|
+
}
|
526
|
+
} catch (error) {}
|
527
|
+
return {
|
528
|
+
auth: "".concat(baseUrl[_env], "/auth-element/").concat(version, "/pages/element_auth/index.html"),
|
529
|
+
address: "".concat(baseUrl[_env], "/element-address/").concat(version, "/pages/address/index.html"),
|
530
|
+
payment: payment
|
531
|
+
};
|
532
|
+
}
|
533
|
+
|
534
|
+
// 循环给所有iframe发同一个消息
|
535
|
+
// private postCommonMessage<T>(event: ElementPaymentEvent, params: T) {
|
536
|
+
// for (let index = 0; index < this.launchSource.length; index++) {
|
537
|
+
// this.eventService.emitAndListen(
|
538
|
+
// {
|
539
|
+
// event: event,
|
540
|
+
// data: {
|
541
|
+
// source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
542
|
+
// target: this.launchSource[0],
|
543
|
+
// params: params,
|
544
|
+
// },
|
545
|
+
// },
|
546
|
+
// () => {},
|
547
|
+
// )
|
548
|
+
// }
|
549
|
+
// }
|
550
|
+
|
551
|
+
// 监听sdk消息
|
552
|
+
}, {
|
553
|
+
key: "addListener",
|
554
|
+
value: function addListener() {
|
555
|
+
var _this6 = this;
|
556
|
+
this.eventService.listen(ElementPaymentEvent.LAUNCH, function (result) {
|
557
|
+
_this6.launchFunc(result);
|
558
|
+
});
|
559
|
+
this.eventService.listen(ElementPaymentEvent.SIZE_CHANGE, function (result) {
|
560
|
+
if (result.target === ElementPaymentMethod.CONTAINER_ELEMENT && result.source === ElementPaymentMethod.AUTH_ELEMENT) {
|
561
|
+
var _this6$authBase;
|
562
|
+
(_this6 === null || _this6 === void 0 ? void 0 : _this6.authBase) && (_this6 === null || _this6 === void 0 || (_this6$authBase = _this6.authBase) === null || _this6$authBase === void 0 ? void 0 : _this6$authBase.update(result.data.height));
|
563
|
+
}
|
564
|
+
});
|
565
|
+
this.eventService.listen(ElementPaymentEvent.CALLBACK, function (result) {
|
566
|
+
var _this6$eventCallback;
|
567
|
+
console.log('antom sdk 组件事件回调');
|
568
|
+
if ((_this6$eventCallback = _this6.eventCallback) !== null && _this6$eventCallback !== void 0 && (_this6$eventCallback = _this6$eventCallback[result.source]) !== null && _this6$eventCallback !== void 0 && _this6$eventCallback[result.event]) {
|
569
|
+
var _this6$eventCallback$, _this6$eventCallback$2;
|
570
|
+
(_this6$eventCallback$ = (_this6$eventCallback$2 = _this6.eventCallback[result.source])[result.event]) === null || _this6$eventCallback$ === void 0 || _this6$eventCallback$.call(_this6$eventCallback$2, result.data);
|
571
|
+
}
|
572
|
+
});
|
573
|
+
this.eventService.listen(ConstantEvent.close.name, function () {
|
574
|
+
_this6.unmount();
|
575
|
+
});
|
576
|
+
this.eventService.listen(ConstantEvent.redirect.name, function (data, res) {
|
577
|
+
data.isDestroy && _this6.unmount();
|
578
|
+
});
|
579
|
+
this.eventService.listen(ElementPaymentEvent.LOG, function (result) {
|
580
|
+
console.log('antom sdk 组件日志回调');
|
581
|
+
});
|
582
|
+
}
|
583
|
+
|
584
|
+
// launch消息处理
|
585
|
+
}, {
|
586
|
+
key: "launchFunc",
|
587
|
+
value: function launchFunc() {
|
588
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
589
|
+
var eventSource = Object.keys(ElementPaymentMethod);
|
590
|
+
var source = data.source,
|
591
|
+
target = data.target;
|
592
|
+
if (eventSource.includes(source) && target === ElementPaymentMethod.CONTAINER_ELEMENT) {
|
593
|
+
if (this.launchSource.every(function (item) {
|
594
|
+
return item !== source;
|
595
|
+
})) {
|
596
|
+
this.launchSource.push(source);
|
597
|
+
this.afterInit();
|
598
|
+
}
|
599
|
+
}
|
600
|
+
}
|
601
|
+
}, {
|
602
|
+
key: "showIframe",
|
603
|
+
value: function showIframe() {
|
604
|
+
var _this$paymentBase, _this$addressBase, _this$authBase, _this$_options$loadin;
|
605
|
+
this.loading = false;
|
606
|
+
(this === null || this === void 0 ? void 0 : this.paymentBase) && (this === null || this === void 0 || (_this$paymentBase = this.paymentBase) === null || _this$paymentBase === void 0 ? void 0 : _this$paymentBase.update());
|
607
|
+
(this === null || this === void 0 ? void 0 : this.addressBase) && (this === null || this === void 0 || (_this$addressBase = this.addressBase) === null || _this$addressBase === void 0 ? void 0 : _this$addressBase.update());
|
608
|
+
(this === null || this === void 0 ? void 0 : this.authBase) && (this === null || this === void 0 || (_this$authBase = this.authBase) === null || _this$authBase === void 0 ? void 0 : _this$authBase.update());
|
609
|
+
if ((_this$_options$loadin = this._options.loading) !== null && _this$_options$loadin !== void 0 && _this$_options$loadin.onEndLoading) {
|
610
|
+
var _this$_options$loadin2, _this$_options$loadin3;
|
611
|
+
(_this$_options$loadin2 = this._options.loading) === null || _this$_options$loadin2 === void 0 || (_this$_options$loadin3 = _this$_options$loadin2.onEndLoading) === null || _this$_options$loadin3 === void 0 || _this$_options$loadin3.call(_this$_options$loadin2);
|
612
|
+
}
|
613
|
+
}
|
614
|
+
}, {
|
615
|
+
key: "afterInit",
|
616
|
+
value: function afterInit() {
|
617
|
+
if (this.launchSource.length === this.componentsCount && this.sdkActionRes && this.oneAccountRes && this.isConnect) {
|
618
|
+
this.sendRenderData();
|
619
|
+
this.showIframe();
|
620
|
+
}
|
621
|
+
}
|
622
|
+
|
623
|
+
// 发送初始化数据
|
624
|
+
}, {
|
625
|
+
key: "sendRenderData",
|
626
|
+
value: function sendRenderData() {
|
627
|
+
var _this7 = this;
|
628
|
+
var baseData = {
|
629
|
+
originActionQueryResult: this.sdkActionRes,
|
630
|
+
originOneAccountQueryResult: this.oneAccountRes,
|
631
|
+
paymentSessionData: this._options.sessionData,
|
632
|
+
sessionResult: this.parseData || {}
|
633
|
+
};
|
634
|
+
this.launchSource.forEach(function (target) {
|
635
|
+
var _this7$mountOptions;
|
636
|
+
var params = _objectSpread(_objectSpread({}, (_this7$mountOptions = _this7.mountOptions) === null || _this7$mountOptions === void 0 ? void 0 : _this7$mountOptions[target]), baseData);
|
637
|
+
if (target === ElementPaymentMethod.ADDRESS_ELEMENT) {
|
638
|
+
params.prefillValue = _this7.oneAccountRes.shippings || [];
|
639
|
+
} else if (target === ElementPaymentMethod.PAYMENT_ELEMENT) {
|
640
|
+
params.queryResult = _this7.sdkActionRes;
|
641
|
+
}
|
642
|
+
_this7.eventService.emitAndListen({
|
643
|
+
event: ElementPaymentEvent.INITIAL_DATA_READY,
|
644
|
+
data: {
|
645
|
+
target: target,
|
646
|
+
source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
647
|
+
params: params
|
648
|
+
}
|
649
|
+
}, function () {});
|
650
|
+
});
|
651
|
+
}
|
652
|
+
|
653
|
+
// 注销所有消息监听,这里需要和addListener里面监听的事件对应
|
654
|
+
}, {
|
655
|
+
key: "removeListener",
|
656
|
+
value: function removeListener() {
|
657
|
+
this.eventService.unlisten(ElementPaymentEvent.SIGN_OUT);
|
658
|
+
this.eventService.unlisten(ElementPaymentEvent.CAPTURE_ASSET);
|
659
|
+
this.eventService.unlisten(ElementPaymentEvent.LAUNCH);
|
660
|
+
this.eventService.unlisten(ElementPaymentEvent.SIZE_CHANGE);
|
661
|
+
}
|
662
|
+
|
663
|
+
// 注册组件事件监听
|
664
|
+
}, {
|
665
|
+
key: "registerEventListener",
|
666
|
+
value: function registerEventListener(source, event, callback) {
|
667
|
+
this.eventCallback[source][event] = callback;
|
668
|
+
}
|
669
|
+
|
670
|
+
// 渲染邮箱组件
|
671
|
+
}, {
|
672
|
+
key: "mountAuth",
|
673
|
+
value: function mountAuth(renderOptions, sdkSelector) {
|
674
|
+
var _this$_options2,
|
675
|
+
_renderOptions$elemen,
|
676
|
+
_this8 = this;
|
677
|
+
var _mountParams = {
|
678
|
+
appearance: renderOptions.appearance || ((_this$_options2 = this._options) === null || _this$_options2 === void 0 ? void 0 : _this$_options2.appearance) || {
|
679
|
+
theme: ThemeType.Default
|
680
|
+
}
|
681
|
+
};
|
682
|
+
this.mountOptions[ElementPaymentMethod.AUTH_ELEMENT] = _mountParams;
|
683
|
+
var link = renderOptions === null || renderOptions === void 0 || (_renderOptions$elemen = renderOptions.elementProps) === null || _renderOptions$elemen === void 0 ? void 0 : _renderOptions$elemen.elementLink;
|
684
|
+
var params = window.location.href.split('?')[1];
|
685
|
+
var url = link.indexOf('?') === -1 ? "".concat(link, "?").concat(params) : link;
|
686
|
+
this.authBase.mount({
|
687
|
+
selector: sdkSelector,
|
688
|
+
url: url
|
689
|
+
}).then(function (result) {
|
690
|
+
if (!result) {
|
691
|
+
var _this8$_options$onEve, _this8$_options;
|
692
|
+
(_this8$_options$onEve = (_this8$_options = _this8._options).onEventCallback) === null || _this8$_options$onEve === void 0 || _this8$_options$onEve.call(_this8$_options, {
|
693
|
+
code: EventCallbackCode.Failed,
|
694
|
+
message: 'Auth Component loading failed'
|
695
|
+
});
|
696
|
+
return undefined;
|
697
|
+
}
|
698
|
+
_this8.eventService.addIFrame(result);
|
699
|
+
_this8.iframes[ElementPaymentMethod.AUTH_ELEMENT] = result;
|
700
|
+
});
|
701
|
+
return {};
|
702
|
+
}
|
703
|
+
}, {
|
704
|
+
key: "mount",
|
705
|
+
value: function mount(renderOptions, sdkSelector) {
|
706
|
+
if (typeof sdkSelector === 'string') {
|
707
|
+
var _this$_options$loadin4, _renderOptions$debugP, _renderOptions$debugP2;
|
708
|
+
var element = document.querySelector(sdkSelector);
|
709
|
+
if (!element) {
|
710
|
+
var _this$_options$onEven2, _this$_options3;
|
711
|
+
(_this$_options$onEven2 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options3, {
|
712
|
+
code: EventCallbackCode.Failed,
|
713
|
+
message: 'Unable to obtain selector'
|
714
|
+
});
|
715
|
+
return undefined;
|
716
|
+
}
|
717
|
+
this.componentsCount = this.componentsCount + 1;
|
718
|
+
if (!this.loading && (_this$_options$loadin4 = this._options.loading) !== null && _this$_options$loadin4 !== void 0 && _this$_options$loadin4.onStartLoading && this.isConnect) {
|
719
|
+
var _this$_options$loadin5, _this$_options$loadin6;
|
720
|
+
(_this$_options$loadin5 = this._options.loading) === null || _this$_options$loadin5 === void 0 || (_this$_options$loadin6 = _this$_options$loadin5.onStartLoading) === null || _this$_options$loadin6 === void 0 || _this$_options$loadin6.call(_this$_options$loadin5);
|
721
|
+
}
|
722
|
+
var elementLink = renderOptions !== null && renderOptions !== void 0 && (_renderOptions$debugP = renderOptions.debugProps) !== null && _renderOptions$debugP !== void 0 && _renderOptions$debugP.localLink ? renderOptions === null || renderOptions === void 0 || (_renderOptions$debugP2 = renderOptions.debugProps) === null || _renderOptions$debugP2 === void 0 ? void 0 : _renderOptions$debugP2.localLink : this.iframeSrc[renderOptions.type];
|
723
|
+
renderOptions.elementProps = {
|
724
|
+
elementLink: elementLink
|
725
|
+
};
|
726
|
+
this.loading = true;
|
727
|
+
if (renderOptions.type === 'auth') {
|
728
|
+
return this.mountAuth(renderOptions, sdkSelector);
|
729
|
+
}
|
730
|
+
if (renderOptions.type === 'address') {
|
731
|
+
return this.mountAddress(renderOptions, sdkSelector);
|
732
|
+
}
|
733
|
+
if (renderOptions.type === 'payment') {
|
734
|
+
return this.mountPayment(renderOptions, sdkSelector);
|
735
|
+
}
|
736
|
+
} else {
|
737
|
+
this._options.onEventCallback({
|
738
|
+
code: EventCallbackCode.Failed,
|
739
|
+
message: 'Invalid argument for mount method'
|
740
|
+
});
|
741
|
+
return undefined;
|
742
|
+
}
|
743
|
+
}
|
744
|
+
|
745
|
+
// 注销单个iframe,暂时没有用到
|
746
|
+
}, {
|
747
|
+
key: "removeIframe",
|
748
|
+
value: function removeIframe(sdk) {
|
749
|
+
if (sdk && this.launchSource.some(function (source) {
|
750
|
+
return source === sdk;
|
751
|
+
})) {
|
752
|
+
this.launchSource = this.launchSource.filter(function (source) {
|
753
|
+
return source !== sdk;
|
754
|
+
});
|
755
|
+
this.componentsCount = this.componentsCount - 1;
|
756
|
+
this.eventService.removeIFrame(this.iframes[sdk]);
|
757
|
+
}
|
758
|
+
}
|
759
|
+
|
760
|
+
// 暴露出去的注销组件方法
|
761
|
+
}, {
|
762
|
+
key: "unmount",
|
763
|
+
value: function unmount() {
|
764
|
+
var _this$authBase2, _this$authBase2$unmou, _this$addressBase2, _this$addressBase2$un, _this$paymentBase2, _this$paymentBase2$un;
|
765
|
+
(_this$authBase2 = this.authBase) === null || _this$authBase2 === void 0 || (_this$authBase2$unmou = _this$authBase2.unmount) === null || _this$authBase2$unmou === void 0 || _this$authBase2$unmou.call(_this$authBase2);
|
766
|
+
(_this$addressBase2 = this.addressBase) === null || _this$addressBase2 === void 0 || (_this$addressBase2$un = _this$addressBase2.unmount) === null || _this$addressBase2$un === void 0 || _this$addressBase2$un.call(_this$addressBase2);
|
767
|
+
(_this$paymentBase2 = this.paymentBase) === null || _this$paymentBase2 === void 0 || (_this$paymentBase2$un = _this$paymentBase2.unmount) === null || _this$paymentBase2$un === void 0 || _this$paymentBase2$un.call(_this$paymentBase2);
|
768
|
+
this.launchSource = [];
|
769
|
+
this.componentsCount = 0;
|
770
|
+
this.eventService.destroy();
|
771
|
+
this.removeListener();
|
772
|
+
}
|
773
|
+
}, {
|
774
|
+
key: "submitPayment",
|
775
|
+
value: // 暴露出去的submit方法
|
776
|
+
function () {
|
777
|
+
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
778
|
+
var _this$_options$loadin7, _this$_options$loadin10;
|
779
|
+
var _this$_options$loadin8, _this$_options$loadin9, validateRes, _this$_options$loadin11, _this$_options$loadin12;
|
780
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
781
|
+
while (1) switch (_context2.prev = _context2.next) {
|
782
|
+
case 0:
|
783
|
+
// this.onAfterSubmitFunc(ElementPaymentMethod.PAYMENT_ELEMENT, submitResult);
|
784
|
+
// return
|
785
|
+
if ((_this$_options$loadin7 = this._options.loading) !== null && _this$_options$loadin7 !== void 0 && _this$_options$loadin7.onStartLoading) {
|
786
|
+
(_this$_options$loadin8 = this._options.loading) === null || _this$_options$loadin8 === void 0 || (_this$_options$loadin9 = _this$_options$loadin8.onStartLoading) === null || _this$_options$loadin9 === void 0 || _this$_options$loadin9.call(_this$_options$loadin8);
|
787
|
+
}
|
788
|
+
_context2.next = 3;
|
789
|
+
return this.validatePromiseFuncs();
|
790
|
+
case 3:
|
791
|
+
validateRes = _context2.sent;
|
792
|
+
if (!validateRes) {
|
793
|
+
_context2.next = 7;
|
794
|
+
break;
|
795
|
+
}
|
796
|
+
_context2.next = 7;
|
797
|
+
return this.onSubmit(validateRes);
|
798
|
+
case 7:
|
799
|
+
if ((_this$_options$loadin10 = this._options.loading) !== null && _this$_options$loadin10 !== void 0 && _this$_options$loadin10.onEndLoading) {
|
800
|
+
(_this$_options$loadin11 = this._options.loading) === null || _this$_options$loadin11 === void 0 || (_this$_options$loadin12 = _this$_options$loadin11.onEndLoading) === null || _this$_options$loadin12 === void 0 || _this$_options$loadin12.call(_this$_options$loadin11);
|
801
|
+
}
|
802
|
+
return _context2.abrupt("return");
|
803
|
+
case 9:
|
804
|
+
case "end":
|
805
|
+
return _context2.stop();
|
806
|
+
}
|
807
|
+
}, _callee2, this);
|
808
|
+
}));
|
809
|
+
function submitPayment() {
|
810
|
+
return _submitPayment.apply(this, arguments);
|
811
|
+
}
|
812
|
+
return submitPayment;
|
813
|
+
}()
|
814
|
+
}]);
|
815
|
+
return ElementComponent;
|
816
|
+
}();
|