@alipay/ams-checkout 1.23.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +10 -10
- package/esm/constant/index.d.ts +6 -0
- package/esm/constant/index.js +8 -0
- package/esm/core/bus/ability/globalData.d.ts +10 -0
- package/esm/core/bus/ability/globalData.js +89 -0
- package/esm/core/bus/ability/request.d.ts +10 -0
- package/esm/core/bus/ability/request.js +151 -0
- package/esm/core/bus/interface.d.ts +12 -0
- package/esm/core/bus/interface.js +16 -2
- package/esm/core/component/address.d.ts +2 -2
- package/esm/core/component/appPreloadProcessing.js +2 -0
- package/esm/core/component/ckp/index.d.ts +3 -3
- package/esm/core/component/ckp/index.js +6 -5
- 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 +184 -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 +5 -5
- package/esm/core/component/index.js +20 -16
- package/esm/core/drop-in/index.d.ts +2 -2
- package/esm/core/drop-in/index.js +2 -2
- package/esm/core/instance/index.d.ts +5 -5
- package/esm/core/instance/index.js +11 -10
- package/esm/foundation/core/index.d.ts +26 -0
- package/esm/foundation/core/index.js +301 -0
- package/esm/foundation/index.d.ts +72 -0
- package/esm/foundation/index.js +42 -0
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +15 -0
- package/esm/foundation/product-processor/easysafepay/deps.js +9 -0
- package/esm/foundation/product-processor/easysafepay/index.d.ts +26 -0
- package/esm/foundation/product-processor/easysafepay/index.js +536 -0
- package/esm/foundation/service/container/index.d.ts +28 -0
- package/esm/foundation/service/container/index.js +256 -0
- package/esm/foundation/service/container/popup.d.ts +17 -0
- package/esm/foundation/service/container/popup.js +103 -0
- package/esm/foundation/service/container/utils.d.ts +7 -0
- package/esm/foundation/service/container/utils.js +48 -0
- package/esm/foundation/service/event-bus/ability/callback.d.ts +9 -0
- package/esm/foundation/service/event-bus/ability/callback.js +55 -0
- package/esm/foundation/service/event-bus/ability/globalData.d.ts +10 -0
- package/esm/foundation/service/event-bus/ability/globalData.js +89 -0
- package/esm/foundation/service/event-bus/ability/request.d.ts +10 -0
- package/esm/foundation/service/event-bus/ability/request.js +151 -0
- package/esm/foundation/service/event-bus/ability/security.d.ts +12 -0
- package/esm/foundation/service/event-bus/ability/security.js +151 -0
- package/esm/foundation/service/event-bus/ability/tracker.d.ts +9 -0
- package/esm/foundation/service/event-bus/ability/tracker.js +80 -0
- package/esm/foundation/service/event-bus/busManager.d.ts +127 -0
- package/esm/foundation/service/event-bus/busManager.js +398 -0
- package/esm/foundation/service/event-bus/index.d.ts +20 -0
- package/esm/foundation/service/event-bus/index.js +88 -0
- package/esm/foundation/service/event-center.d.ts +75 -0
- package/esm/foundation/service/event-center.js +244 -0
- package/esm/foundation/service/global-data/index.d.ts +11 -0
- package/esm/foundation/service/global-data/index.js +69 -0
- package/esm/foundation/service/index.d.ts +19 -0
- package/esm/foundation/service/index.js +82 -0
- package/esm/foundation/service/log/index.d.ts +43 -0
- package/esm/foundation/service/log/index.js +235 -0
- package/esm/foundation/service/log/types.d.ts +32 -0
- package/esm/foundation/service/log/types.js +1 -0
- package/esm/foundation/service/requester/deps.d.ts +17 -0
- package/esm/foundation/service/requester/deps.js +11 -0
- package/esm/foundation/service/requester/requester.d.ts +22 -0
- package/esm/foundation/service/requester/requester.js +211 -0
- package/esm/foundation/service/security/index.d.ts +26 -0
- package/esm/foundation/service/security/index.js +216 -0
- package/esm/{util → foundation/service/security}/security.d.ts +2 -2
- package/esm/{util → foundation/service/security}/security.js +3 -3
- package/esm/foundation/types/index.d.ts +4 -0
- package/esm/foundation/types/index.js +4 -0
- package/esm/foundation/utils/gray_scale_utils.d.ts +7 -0
- package/esm/foundation/utils/gray_scale_utils.js +40 -0
- package/esm/foundation/utils/payment_context_utils.d.ts +13 -0
- package/esm/foundation/utils/payment_context_utils.js +57 -0
- package/esm/foundation/utils/redirect_utils.d.ts +6 -0
- package/esm/foundation/utils/redirect_utils.js +99 -0
- package/esm/foundation/utils/system_events.d.ts +4 -0
- package/esm/foundation/utils/system_events.js +71 -0
- package/esm/foundation/utils/web_app_url_utils.d.ts +37 -0
- package/esm/foundation/utils/web_app_url_utils.js +97 -0
- package/esm/index.d.ts +16 -10
- package/esm/index.js +70 -59
- package/esm/plugin/applepay/component.js +3 -3
- package/esm/plugin/applepay/service.d.ts +2 -2
- package/esm/plugin/applepay/service.js +2 -2
- package/esm/plugin/component/cashierApp.d.ts +7 -5
- package/esm/plugin/component/cashierApp.js +16 -8
- package/esm/plugin/component/channel.d.ts +4 -4
- package/esm/plugin/component/component.inline.style.d.ts +4 -4
- package/esm/plugin/component/component.inline.style.js +10 -7
- package/esm/plugin/component/component.popup.style.d.ts +15 -6
- package/esm/plugin/component/component.popup.style.js +33 -15
- package/esm/plugin/component/index.d.ts +8 -7
- package/esm/plugin/component/index.js +153 -98
- package/esm/plugin/const.js +5 -5
- package/esm/plugin/drop-in/index.d.ts +5 -5
- package/esm/plugin/drop-in/index.js +7 -7
- package/esm/plugin/payment-element/utils.d.ts +1 -1
- package/esm/plugin/payment-element/utils.js +2 -1
- package/esm/plugin/type.d.ts +4 -4
- 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 +240 -38
- package/esm/types/index.js +103 -59
- package/esm/util/createIframeNode.d.ts +2 -2
- package/esm/util/createIframeNode.js +3 -3
- package/esm/util/index.d.ts +1 -1
- package/esm/util/index.js +3 -4
- package/package.json +2 -1
@@ -0,0 +1,536 @@
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
5
|
+
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."); }
|
6
|
+
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); }
|
7
|
+
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; }
|
8
|
+
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; } }
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
10
|
+
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; }
|
11
|
+
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); } }
|
12
|
+
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); }); }; }
|
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 { ChannelCustomize, DisplayTypeEnum, isLocalMock, isPC, ServiceProvider, WebAppUrlUtil } from "./deps";
|
20
|
+
|
21
|
+
// 缓存上次产品信息
|
22
|
+
var KEY_PREVIOUS_PRODUCT_INFO = 'antom_checkout_previous_ESP_ProductInfo';
|
23
|
+
export var EasySafePayProcessor = /*#__PURE__*/function () {
|
24
|
+
function EasySafePayProcessor() {
|
25
|
+
_classCallCheck(this, EasySafePayProcessor);
|
26
|
+
_defineProperty(this, "paymentContext", void 0);
|
27
|
+
_defineProperty(this, "initConfig", void 0);
|
28
|
+
_defineProperty(this, "logger", void 0);
|
29
|
+
_defineProperty(this, "instanceId", void 0);
|
30
|
+
_defineProperty(this, "hostSign", void 0);
|
31
|
+
// 是否允许submitPay提前调用,在ESP非首次的性能优化场景使用
|
32
|
+
_defineProperty(this, "allowSubmitPayCallAhead", void 0);
|
33
|
+
_defineProperty(this, "channelBehavior", void 0);
|
34
|
+
}
|
35
|
+
_createClass(EasySafePayProcessor, [{
|
36
|
+
key: "init",
|
37
|
+
value: function init(config, instanceId, sdkMetaData) {
|
38
|
+
this.initConfig = config;
|
39
|
+
this.instanceId = instanceId;
|
40
|
+
this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
|
41
|
+
this.preloadWebApp(config, this.instanceId, sdkMetaData);
|
42
|
+
}
|
43
|
+
}, {
|
44
|
+
key: "startBizFlow",
|
45
|
+
value: function () {
|
46
|
+
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentContext) {
|
47
|
+
var _paymentContext$payme2, _this$channelBehavior;
|
48
|
+
var _paymentContext$payme, productSceneVersion, paymentMethodCategoryType, autoDebitWithToken, requireFastSdk, authUrlInfo, isFirstTimeToPay, webAppUrl, resultPayload;
|
49
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
50
|
+
while (1) switch (_context.prev = _context.next) {
|
51
|
+
case 0:
|
52
|
+
// 放在最前面的逻辑
|
53
|
+
// 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
|
54
|
+
if (isPC()) {
|
55
|
+
// 非TOSS渠道,在PC场景需要改成1.0
|
56
|
+
if ('BANKTRANSFER_QUICKPAY' !== ((_paymentContext$payme = paymentContext.paymentSessionObj) === null || _paymentContext$payme === void 0 || (_paymentContext$payme = _paymentContext$payme.paymentMethodInfoView) === null || _paymentContext$payme === void 0 ? void 0 : _paymentContext$payme.paymentMethodType)) {
|
57
|
+
paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion = '1.0';
|
58
|
+
}
|
59
|
+
}
|
60
|
+
this.paymentContext = paymentContext;
|
61
|
+
this.hostSign = ((paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSession) || '').split('&&')[1] || '';
|
62
|
+
productSceneVersion = paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
63
|
+
paymentMethodCategoryType = paymentContext.paymentSessionObj.paymentSessionConfig.paymentMethodCategoryType;
|
64
|
+
autoDebitWithToken = paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
65
|
+
requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
|
66
|
+
authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
|
67
|
+
this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
|
68
|
+
// 首次支付
|
69
|
+
isFirstTimeToPay = !autoDebitWithToken; // 处理ESP1.0极速外跳支付场景
|
70
|
+
if (!(productSceneVersion === '1.0' && isFirstTimeToPay && requireFastSdk)) {
|
71
|
+
_context.next = 12;
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
|
75
|
+
case 12:
|
76
|
+
// 下面的场景是需要渲染UI的渠道, 打开WebUrl
|
77
|
+
webAppUrl = this.buildWebAppUrl();
|
78
|
+
resultPayload = {
|
79
|
+
url: webAppUrl,
|
80
|
+
allowClickPopupOutsideClose: (_this$channelBehavior = this.channelBehavior) === null || _this$channelBehavior === void 0 ? void 0 : _this$channelBehavior.allowClickOutsideClose
|
81
|
+
};
|
82
|
+
this.savePreviousProductInfo({
|
83
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
84
|
+
hostSign: this.hostSign,
|
85
|
+
productSceneVersion: productSceneVersion
|
86
|
+
});
|
87
|
+
// 返回结果之前,发送actionquery,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
|
88
|
+
this.sendRequestAndWaitWebLaunch();
|
89
|
+
// 返回结果,RENDER,让外层去处理iframe加载等逻辑
|
90
|
+
return _context.abrupt("return", {
|
91
|
+
behaviorType: 'RENDER',
|
92
|
+
payload: resultPayload
|
93
|
+
});
|
94
|
+
case 17:
|
95
|
+
case "end":
|
96
|
+
return _context.stop();
|
97
|
+
}
|
98
|
+
}, _callee, this);
|
99
|
+
}));
|
100
|
+
function startBizFlow(_x) {
|
101
|
+
return _startBizFlow.apply(this, arguments);
|
102
|
+
}
|
103
|
+
return startBizFlow;
|
104
|
+
}()
|
105
|
+
}, {
|
106
|
+
key: "preloadWebApp",
|
107
|
+
value: function preloadWebApp(config, instanceId, sdkMetaData) {
|
108
|
+
// trigger preload
|
109
|
+
var containerService = ServiceProvider.getInstance(this.instanceId).getService('Container');
|
110
|
+
var productScene = this.paymentContext.paymentSessionObj.paymentSessionConfig.productScene;
|
111
|
+
var paymentMethodCategoryType = this.paymentContext.paymentSessionObj.paymentSessionConfig.paymentMethodCategoryType;
|
112
|
+
var containerId = "ams-checkout-component-".concat(productScene, "_").concat(paymentMethodCategoryType);
|
113
|
+
var webAppUrl = this.buildWebAppPreloadUrl(config, instanceId, sdkMetaData);
|
114
|
+
containerService.preload(containerId, webAppUrl);
|
115
|
+
}
|
116
|
+
}, {
|
117
|
+
key: "buildWebAppPreloadUrl",
|
118
|
+
value: function buildWebAppPreloadUrl(initConfig, instanceId, sdkMetaData) {
|
119
|
+
var previousProductInfo = this.getPreviousProductInfo();
|
120
|
+
var paymentMethodCategoryType = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.paymentMethodCategoryType;
|
121
|
+
var productSceneVersion = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.productSceneVersion;
|
122
|
+
var hostSign = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.hostSign;
|
123
|
+
var webAppUrlInfo = WebAppUrlUtil.getWebAppUrl({
|
124
|
+
environment: initConfig.environment,
|
125
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
126
|
+
sdkMetaData: sdkMetaData,
|
127
|
+
productSceneVersion: productSceneVersion,
|
128
|
+
query: {
|
129
|
+
analyticsEnabled: initConfig.analytics.enabled,
|
130
|
+
displayType: DisplayTypeEnum.inline,
|
131
|
+
instanceId: instanceId,
|
132
|
+
isPreload: 'true',
|
133
|
+
locale: initConfig.locale,
|
134
|
+
hostSign: hostSign
|
135
|
+
}
|
136
|
+
});
|
137
|
+
var webAppUrl;
|
138
|
+
if (webAppUrlInfo.path.indexOf('?') !== -1) {
|
139
|
+
webAppUrl = "".concat(webAppUrlInfo.path, "&").concat(webAppUrlInfo.locationSearch);
|
140
|
+
} else {
|
141
|
+
webAppUrl = "".concat(webAppUrlInfo.path, "?").concat(webAppUrlInfo.locationSearch);
|
142
|
+
}
|
143
|
+
return webAppUrl;
|
144
|
+
}
|
145
|
+
}, {
|
146
|
+
key: "buildWebAppUrl",
|
147
|
+
value: function buildWebAppUrl() {
|
148
|
+
var _paymentContext$payme3, _paymentContext$payme4;
|
149
|
+
var paymentContext = this.paymentContext;
|
150
|
+
var paymentMethodCategoryType = (_paymentContext$payme3 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme3 === void 0 ? void 0 : _paymentContext$payme3.paymentMethodCategoryType;
|
151
|
+
var productSceneVersion = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productSceneVersion;
|
152
|
+
var hostSign = this.hostSign;
|
153
|
+
var webAppUrlInfo = WebAppUrlUtil.getWebAppUrl({
|
154
|
+
environment: this.initConfig.environment,
|
155
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
156
|
+
sdkMetaData: paymentContext.sdkMetaData,
|
157
|
+
productSceneVersion: productSceneVersion,
|
158
|
+
query: {
|
159
|
+
analyticsEnabled: this.initConfig.analytics.enabled,
|
160
|
+
displayType: DisplayTypeEnum.inline,
|
161
|
+
instanceId: this.instanceId,
|
162
|
+
isPreload: 'true',
|
163
|
+
locale: this.initConfig.locale,
|
164
|
+
hostSign: hostSign
|
165
|
+
}
|
166
|
+
});
|
167
|
+
var webAppUrl;
|
168
|
+
if (webAppUrlInfo.path.indexOf('?') !== -1) {
|
169
|
+
webAppUrl = "".concat(webAppUrlInfo.path, "&").concat(webAppUrlInfo.locationSearch);
|
170
|
+
} else {
|
171
|
+
webAppUrl = "".concat(webAppUrlInfo.path, "?").concat(webAppUrlInfo.locationSearch);
|
172
|
+
}
|
173
|
+
return webAppUrl;
|
174
|
+
}
|
175
|
+
}, {
|
176
|
+
key: "buildRedirectResult",
|
177
|
+
value: function buildRedirectResult(authUrlInfo) {
|
178
|
+
var data;
|
179
|
+
if (!(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.normalUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.schemeUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.applinkUrl) && authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.authUrl) {
|
180
|
+
data = {
|
181
|
+
url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
|
182
|
+
schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
|
183
|
+
applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl
|
184
|
+
};
|
185
|
+
} else {
|
186
|
+
data = {
|
187
|
+
url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.normalUrl,
|
188
|
+
schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.schemeUrl,
|
189
|
+
applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl
|
190
|
+
};
|
191
|
+
}
|
192
|
+
var result = {
|
193
|
+
behaviorType: 'REDIRECT',
|
194
|
+
payload: data
|
195
|
+
};
|
196
|
+
return result;
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* 等待Web应用启动,然后发送renderComponent事件
|
201
|
+
* start waiting web launch, then send renderComponent event
|
202
|
+
* */
|
203
|
+
}, {
|
204
|
+
key: "sendRequestAndWaitWebLaunch",
|
205
|
+
value: function sendRequestAndWaitWebLaunch() {
|
206
|
+
var _this = this;
|
207
|
+
var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
208
|
+
var requestPromise = Promise.all([this.processPaymentQuery(), this.processSubmitPay()]).then(function (_ref) {
|
209
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
210
|
+
queryRes = _ref2[0],
|
211
|
+
submitRes = _ref2[1];
|
212
|
+
return {
|
213
|
+
queryRes: queryRes,
|
214
|
+
submitRes: submitRes
|
215
|
+
};
|
216
|
+
});
|
217
|
+
var webLaunchPromose = new Promise(function (resolve) {
|
218
|
+
eventCenter.listen('onlaunch', function (res) {
|
219
|
+
resolve(res);
|
220
|
+
});
|
221
|
+
});
|
222
|
+
|
223
|
+
// 等请求和 Web启动都Ready之后,发送renderComponent
|
224
|
+
Promise.all([requestPromise, webLaunchPromose]).then(function (_ref3) {
|
225
|
+
var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
|
226
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
227
|
+
requestResult = _ref4[0],
|
228
|
+
launchRes = _ref4[1];
|
229
|
+
var logMetaData = _this.logger.getLogConfig().mdata;
|
230
|
+
eventCenter.dispatchToApp({
|
231
|
+
event: 'renderComponent',
|
232
|
+
data: {
|
233
|
+
queryResult: requestResult.queryRes,
|
234
|
+
submitResult: requestResult.submitRes,
|
235
|
+
sessionResult: (_this$paymentContext = _this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionObj,
|
236
|
+
paymentSessionData: (_this$paymentContext2 = _this.paymentContext) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSession,
|
237
|
+
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
238
|
+
renderDisplayType: _this.paymentContext.displayInfo.type,
|
239
|
+
appearance: (_this$paymentContext$ = _this.paymentContext.displayInfo) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.appearance,
|
240
|
+
notRedirectAfterComplete: ((_this$paymentContext$2 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.notRedirectAfterComplete) === true,
|
241
|
+
merchantAppointParam: (_this$paymentContext$3 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.merchantAppointParam,
|
242
|
+
allowSubmitPayCallAhead: _this.allowSubmitPayCallAhead,
|
243
|
+
envInfo: {
|
244
|
+
screenHeight: screen.height,
|
245
|
+
screenWidth: screen.width
|
246
|
+
},
|
247
|
+
logMetaData: _objectSpread(_objectSpread({
|
248
|
+
trackId: logMetaData.requestSeq,
|
249
|
+
platform: logMetaData.platform,
|
250
|
+
firstLogTime: logMetaData.firstLogTime
|
251
|
+
}, ((_this$paymentContext$4 = _this.paymentContext.paymentSessionObj) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.paymentSessionConfig) || {}), {}, {
|
252
|
+
renderDisplayType: logMetaData.renderDisplayType,
|
253
|
+
sdkVersion: logMetaData.sdkVersion,
|
254
|
+
merchantId: logMetaData.merchantId,
|
255
|
+
instanceId: logMetaData.instanceId,
|
256
|
+
paymentMethodType: logMetaData.paymentMethodType
|
257
|
+
})
|
258
|
+
}
|
259
|
+
});
|
260
|
+
});
|
261
|
+
}
|
262
|
+
}, {
|
263
|
+
key: "processPaymentQuery",
|
264
|
+
value: function () {
|
265
|
+
var _processPaymentQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
266
|
+
var _this$paymentContext3, _this$paymentContext4, _this$paymentContext5, _this$paymentContext6, _this$paymentContext7, _this$channelBehavior2;
|
267
|
+
var envInfo, requestData, extendInfo, actionData, enableEasypayApiOptimize, extendInfoData, productSceneVersion, requester, res;
|
268
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
269
|
+
while (1) switch (_context2.prev = _context2.next) {
|
270
|
+
case 0:
|
271
|
+
envInfo = {
|
272
|
+
locale: this.initConfig.locale
|
273
|
+
}; //
|
274
|
+
requestData = {
|
275
|
+
paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSession) || '',
|
276
|
+
paymentSessionConfig: (_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.paymentSessionObj) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionConfig,
|
277
|
+
notRedirectAfterComplete: ((_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.startBizFlowOptions.submitPayRequestExtra.notRedirectAfterComplete) === true
|
278
|
+
// merchantAppointParam: this._merchantAppointParam,
|
279
|
+
};
|
280
|
+
extendInfo = ((_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 || (_this$paymentContext6 = _this$paymentContext6.paymentSessionObj) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.extendInfo) || '';
|
281
|
+
actionData = (_this$paymentContext7 = this.paymentContext) === null || _this$paymentContext7 === void 0 || (_this$paymentContext7 = _this$paymentContext7.paymentSessionObj) === null || _this$paymentContext7 === void 0 ? void 0 : _this$paymentContext7.action;
|
282
|
+
enableEasypayApiOptimize = false;
|
283
|
+
try {
|
284
|
+
extendInfoData = JSON.parse(extendInfo);
|
285
|
+
enableEasypayApiOptimize = extendInfoData.enableEasypayApiOptimize || false;
|
286
|
+
} catch (error) {
|
287
|
+
console.log(error);
|
288
|
+
}
|
289
|
+
if (!isLocalMock()) {
|
290
|
+
_context2.next = 8;
|
291
|
+
break;
|
292
|
+
}
|
293
|
+
return _context2.abrupt("return", {
|
294
|
+
message: 'sdk no need to make query request',
|
295
|
+
success: true
|
296
|
+
});
|
297
|
+
case 8:
|
298
|
+
if (!((_this$channelBehavior2 = this.channelBehavior) !== null && _this$channelBehavior2 !== void 0 && _this$channelBehavior2.usePaymentSessionAsQueryResult)) {
|
299
|
+
_context2.next = 10;
|
300
|
+
break;
|
301
|
+
}
|
302
|
+
return _context2.abrupt("return", {
|
303
|
+
autoDebitWithToken: actionData === null || actionData === void 0 ? void 0 : actionData.autoDebitWithToken,
|
304
|
+
amountConfirmRequired: actionData === null || actionData === void 0 ? void 0 : actionData.amountConfirmRequired,
|
305
|
+
success: true
|
306
|
+
});
|
307
|
+
case 10:
|
308
|
+
if (!(actionData.skipSdkQuery && enableEasypayApiOptimize)) {
|
309
|
+
_context2.next = 12;
|
310
|
+
break;
|
311
|
+
}
|
312
|
+
return _context2.abrupt("return", {
|
313
|
+
message: 'sdk no need to make query request',
|
314
|
+
success: true
|
315
|
+
});
|
316
|
+
case 12:
|
317
|
+
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion; // ESP 2.0 无需Query
|
318
|
+
if (!(productSceneVersion === '2.0')) {
|
319
|
+
_context2.next = 15;
|
320
|
+
break;
|
321
|
+
}
|
322
|
+
return _context2.abrupt("return", {
|
323
|
+
message: 'sdk no need to make query request',
|
324
|
+
success: true
|
325
|
+
});
|
326
|
+
case 15:
|
327
|
+
_context2.next = 17;
|
328
|
+
return this.acquireApdidToken();
|
329
|
+
case 17:
|
330
|
+
envInfo.deviceId = _context2.sent;
|
331
|
+
// 打日志
|
332
|
+
this.logger.logInfo({
|
333
|
+
title: 'sdk_event_sdkQuery'
|
334
|
+
}, {
|
335
|
+
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
336
|
+
// TODO: 安全合规考虑
|
337
|
+
requestBody: requestData
|
338
|
+
});
|
339
|
+
|
340
|
+
// 真正发请求
|
341
|
+
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
342
|
+
_context2.prev = 20;
|
343
|
+
_context2.next = 23;
|
344
|
+
return requester.request(requestData, {
|
345
|
+
env: this.initConfig.environment,
|
346
|
+
envInfo: envInfo,
|
347
|
+
hostSign: this.hostSign,
|
348
|
+
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
349
|
+
});
|
350
|
+
case 23:
|
351
|
+
res = _context2.sent;
|
352
|
+
this.logger.logInfo({
|
353
|
+
title: 'sdk_event_sdkQueryEnd'
|
354
|
+
}, {
|
355
|
+
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
356
|
+
// TODO: 安全合规考虑
|
357
|
+
responseBody: res
|
358
|
+
});
|
359
|
+
_context2.next = 31;
|
360
|
+
break;
|
361
|
+
case 27:
|
362
|
+
_context2.prev = 27;
|
363
|
+
_context2.t0 = _context2["catch"](20);
|
364
|
+
this.logger.logError({
|
365
|
+
title: 'sdk_event_sdkQuery_failed'
|
366
|
+
}, {
|
367
|
+
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
368
|
+
errorReason: _context2.t0
|
369
|
+
});
|
370
|
+
throw _context2.t0;
|
371
|
+
case 31:
|
372
|
+
case "end":
|
373
|
+
return _context2.stop();
|
374
|
+
}
|
375
|
+
}, _callee2, this, [[20, 27]]);
|
376
|
+
}));
|
377
|
+
function processPaymentQuery() {
|
378
|
+
return _processPaymentQuery.apply(this, arguments);
|
379
|
+
}
|
380
|
+
return processPaymentQuery;
|
381
|
+
}()
|
382
|
+
}, {
|
383
|
+
key: "processSubmitPay",
|
384
|
+
value: function () {
|
385
|
+
var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
386
|
+
var _this$paymentContext8, _this$paymentContext9, _this$paymentContext11, _this$channelBehavior3, _this$channelBehavior4, _this$paymentContext$5;
|
387
|
+
var submitParams, shouldSkipSubmitPayInSDK, _this$paymentContext10, _ref5, _ref5$productSceneVer, productSceneVersion, _ref5$productScene, productScene, _ref6, _ref6$action, _ref6$action2, _ref6$action2$enableS, enableSignAgreement, _ref6$action2$autoDeb, autoDebitWithToken, extParams, requester, res;
|
388
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
389
|
+
while (1) switch (_context3.prev = _context3.next) {
|
390
|
+
case 0:
|
391
|
+
submitParams = {
|
392
|
+
paymentSessionData: ((_this$paymentContext8 = this.paymentContext) === null || _this$paymentContext8 === void 0 ? void 0 : _this$paymentContext8.paymentSession) || '',
|
393
|
+
paymentSessionConfig: (_this$paymentContext9 = this.paymentContext) === null || _this$paymentContext9 === void 0 || (_this$paymentContext9 = _this$paymentContext9.paymentSessionObj) === null || _this$paymentContext9 === void 0 ? void 0 : _this$paymentContext9.paymentSessionConfig
|
394
|
+
};
|
395
|
+
shouldSkipSubmitPayInSDK = false;
|
396
|
+
if (this.channelBehavior) {
|
397
|
+
// 新逻辑走 channelBehavior判断
|
398
|
+
shouldSkipSubmitPayInSDK = !this.channelBehavior.submitPayInSdk;
|
399
|
+
} else {
|
400
|
+
// TODO: 拉会找栎昂、甘颜一起对下
|
401
|
+
// 老逻辑,只要服务端标记不跳过sdkquery,就需要跳过submitpay
|
402
|
+
shouldSkipSubmitPayInSDK = !((_this$paymentContext10 = this.paymentContext) !== null && _this$paymentContext10 !== void 0 && (_this$paymentContext10 = _this$paymentContext10.paymentSessionObj) !== null && _this$paymentContext10 !== void 0 && (_this$paymentContext10 = _this$paymentContext10.action) !== null && _this$paymentContext10 !== void 0 && _this$paymentContext10.skipSdkQuery);
|
403
|
+
}
|
404
|
+
_ref5 = submitParams.paymentSessionConfig || {}, _ref5$productSceneVer = _ref5.productSceneVersion, productSceneVersion = _ref5$productSceneVer === void 0 ? '' : _ref5$productSceneVer, _ref5$productScene = _ref5.productScene, productScene = _ref5$productScene === void 0 ? '' : _ref5$productScene;
|
405
|
+
_ref6 = ((_this$paymentContext11 = this.paymentContext) === null || _this$paymentContext11 === void 0 ? void 0 : _this$paymentContext11.paymentSessionObj) || {}, _ref6$action = _ref6.action, _ref6$action2 = _ref6$action === void 0 ? {} : _ref6$action, _ref6$action2$enableS = _ref6$action2.enableSignAgreement, enableSignAgreement = _ref6$action2$enableS === void 0 ? false : _ref6$action2$enableS, _ref6$action2$autoDeb = _ref6$action2.autoDebitWithToken, autoDebitWithToken = _ref6$action2$autoDeb === void 0 ? false : _ref6$action2$autoDeb;
|
406
|
+
if (productSceneVersion === '2.0' && !autoDebitWithToken) {
|
407
|
+
///EasyPay 2.0 首次传signAgreement字段
|
408
|
+
submitParams['signAgreement'] = enableSignAgreement;
|
409
|
+
}
|
410
|
+
// 带上标记告知WebCheckOut SDK已发送submitpay请求
|
411
|
+
this.allowSubmitPayCallAhead = !shouldSkipSubmitPayInSDK;
|
412
|
+
if (!shouldSkipSubmitPayInSDK) {
|
413
|
+
_context3.next = 9;
|
414
|
+
break;
|
415
|
+
}
|
416
|
+
return _context3.abrupt("return", {
|
417
|
+
message: 'sdk no need to make submitPay request',
|
418
|
+
success: true
|
419
|
+
});
|
420
|
+
case 9:
|
421
|
+
// 下面真实发请求
|
422
|
+
this.logger.logInfo({
|
423
|
+
title: 'sdk_event_submitPay'
|
424
|
+
}, {
|
425
|
+
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
426
|
+
// TODO: 安全合规考虑
|
427
|
+
responseBody: submitParams
|
428
|
+
});
|
429
|
+
// 由渠道定制点来构建额外参数
|
430
|
+
extParams = ((_this$channelBehavior3 = this.channelBehavior) === null || _this$channelBehavior3 === void 0 || (_this$channelBehavior4 = _this$channelBehavior3.buildSubmitPayExtParams) === null || _this$channelBehavior4 === void 0 ? void 0 : _this$channelBehavior4.call(_this$channelBehavior3, {
|
431
|
+
instanceId: this.instanceId,
|
432
|
+
locale: this.initConfig.locale,
|
433
|
+
paymentMethodType: (_this$paymentContext$5 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$5 === void 0 || (_this$paymentContext$5 = _this$paymentContext$5.paymentMethodInfoView) === null || _this$paymentContext$5 === void 0 ? void 0 : _this$paymentContext$5.paymentMethodType,
|
434
|
+
paymentSessionData: this.paymentContext.paymentSession,
|
435
|
+
env: this.initConfig.environment,
|
436
|
+
sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
|
437
|
+
})) || {};
|
438
|
+
submitParams.extParams = extParams;
|
439
|
+
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
440
|
+
_context3.t0 = requester;
|
441
|
+
_context3.t1 = submitParams;
|
442
|
+
_context3.t2 = this.initConfig.environment;
|
443
|
+
_context3.next = 18;
|
444
|
+
return this.acquireApdidToken();
|
445
|
+
case 18:
|
446
|
+
_context3.t3 = _context3.sent;
|
447
|
+
_context3.t4 = {
|
448
|
+
deviceId: _context3.t3
|
449
|
+
};
|
450
|
+
_context3.t5 = this.hostSign;
|
451
|
+
_context3.t6 = {
|
452
|
+
env: _context3.t2,
|
453
|
+
timeout: 15000,
|
454
|
+
envInfo: _context3.t4,
|
455
|
+
hostSign: _context3.t5,
|
456
|
+
needEnvInfo: true,
|
457
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
458
|
+
};
|
459
|
+
_context3.next = 24;
|
460
|
+
return _context3.t0.request.call(_context3.t0, _context3.t1, _context3.t6);
|
461
|
+
case 24:
|
462
|
+
res = _context3.sent;
|
463
|
+
this.logger.logInfo({
|
464
|
+
title: 'sdk_event_submitPayEnd'
|
465
|
+
}, {
|
466
|
+
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
467
|
+
responseBody: res
|
468
|
+
});
|
469
|
+
return _context3.abrupt("return", res);
|
470
|
+
case 27:
|
471
|
+
case "end":
|
472
|
+
return _context3.stop();
|
473
|
+
}
|
474
|
+
}, _callee3, this);
|
475
|
+
}));
|
476
|
+
function processSubmitPay() {
|
477
|
+
return _processSubmitPay.apply(this, arguments);
|
478
|
+
}
|
479
|
+
return processSubmitPay;
|
480
|
+
}() // TOOD: 讨论下是否放到 requester里面
|
481
|
+
}, {
|
482
|
+
key: "acquireApdidToken",
|
483
|
+
value: function () {
|
484
|
+
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
485
|
+
var _this$paymentContext$6;
|
486
|
+
var securityService, productScene, deviceId;
|
487
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
488
|
+
while (1) switch (_context4.prev = _context4.next) {
|
489
|
+
case 0:
|
490
|
+
securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
491
|
+
productScene = (_this$paymentContext$6 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$6 === void 0 || (_this$paymentContext$6 = _this$paymentContext$6.paymentSessionConfig) === null || _this$paymentContext$6 === void 0 ? void 0 : _this$paymentContext$6.productScene;
|
492
|
+
deviceId = securityService.getDeviceId({
|
493
|
+
productScene: productScene
|
494
|
+
});
|
495
|
+
return _context4.abrupt("return", deviceId);
|
496
|
+
case 4:
|
497
|
+
case "end":
|
498
|
+
return _context4.stop();
|
499
|
+
}
|
500
|
+
}, _callee4, this);
|
501
|
+
}));
|
502
|
+
function acquireApdidToken() {
|
503
|
+
return _acquireApdidToken.apply(this, arguments);
|
504
|
+
}
|
505
|
+
return acquireApdidToken;
|
506
|
+
}()
|
507
|
+
}, {
|
508
|
+
key: "savePreviousProductInfo",
|
509
|
+
value: function savePreviousProductInfo(info) {
|
510
|
+
localStorage.setItem(KEY_PREVIOUS_PRODUCT_INFO, JSON.stringify({
|
511
|
+
productSceneVersion: info.productSceneVersion,
|
512
|
+
paymentMethodCategoryType: info.paymentMethodCategoryType,
|
513
|
+
hostSign: info.hostSign
|
514
|
+
}));
|
515
|
+
}
|
516
|
+
}, {
|
517
|
+
key: "getPreviousProductInfo",
|
518
|
+
value: function getPreviousProductInfo() {
|
519
|
+
var previousProductInfo = localStorage.getItem(KEY_PREVIOUS_PRODUCT_INFO);
|
520
|
+
if (previousProductInfo) {
|
521
|
+
try {
|
522
|
+
return JSON.parse(previousProductInfo);
|
523
|
+
} catch (error) {
|
524
|
+
console.log(error);
|
525
|
+
this.logger.logError({
|
526
|
+
title: 'performance_optimization_get_previousChannel_error'
|
527
|
+
}, {
|
528
|
+
error: error
|
529
|
+
});
|
530
|
+
}
|
531
|
+
}
|
532
|
+
return null;
|
533
|
+
}
|
534
|
+
}]);
|
535
|
+
return EasySafePayProcessor;
|
536
|
+
}();
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { DisplayInfo, SDKMetaData, Service } from '../../index';
|
2
|
+
import { IOptionsParams } from '../../../types';
|
3
|
+
export declare class ContainerService implements Service {
|
4
|
+
private instanceId;
|
5
|
+
private sdkMetaData;
|
6
|
+
private clearTimerIdMapping;
|
7
|
+
private popupManager;
|
8
|
+
private eventCenter;
|
9
|
+
private logService;
|
10
|
+
private displayInfo;
|
11
|
+
private webApp;
|
12
|
+
private customizedLoadingListener;
|
13
|
+
destroy(): void;
|
14
|
+
init(initOptions: IOptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
15
|
+
update(): void;
|
16
|
+
load(displayInfo: DisplayInfo, url: string, closeBtnFunc: () => void): HTMLDivElement;
|
17
|
+
cleanContainer(displayInfo: DisplayInfo): void;
|
18
|
+
preload(taskId: string, url: string): void;
|
19
|
+
clearPreloadContainer(taskId: string): void;
|
20
|
+
showLoading(container: HTMLDivElement, displayInfo: DisplayInfo): void;
|
21
|
+
dismissLoading(isKeepMockup?: boolean): void;
|
22
|
+
customizeLoading(listener: (event: 'SDK_START_OF_LOADING' | 'SDK_END_OF_LOADING') => void): void;
|
23
|
+
startHideAnim(): void;
|
24
|
+
private addCapabilityToEventCenter;
|
25
|
+
private addCapabilityToApiBusManager;
|
26
|
+
private handleSizeChanged;
|
27
|
+
private changeCloseBtnVisibility;
|
28
|
+
}
|