@alipay/ams-checkout 1.23.0 → 1.25.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/component/channel.d.ts +19 -0
- package/esm/component/channel.js +87 -0
- package/esm/component/component.inline.style.d.ts +10 -0
- package/esm/component/component.inline.style.js +121 -0
- package/esm/component/component.popup.style.d.ts +23 -0
- package/esm/component/component.popup.style.js +190 -0
- package/esm/component/popupWindow.style.d.ts +11 -0
- package/esm/component/popupWindow.style.js +121 -0
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +10 -10
- package/esm/constant/index.d.ts +9 -5
- package/esm/constant/index.js +12 -78
- 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 +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 +4 -4
- package/esm/core/component/index.js +14 -14
- package/esm/core/drop-in/index.js +2 -2
- package/esm/core/instance/index.js +9 -9
- package/esm/foundation/core/index.d.ts +26 -0
- package/esm/foundation/core/index.js +366 -0
- package/esm/foundation/index.d.ts +75 -0
- package/esm/foundation/index.js +42 -0
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +18 -0
- package/esm/foundation/product-processor/easysafepay/deps.js +12 -0
- package/esm/foundation/product-processor/easysafepay/index.d.ts +26 -0
- package/esm/foundation/product-processor/easysafepay/index.js +463 -0
- package/esm/foundation/service/api-bus/ability/callback.d.ts +9 -0
- package/esm/foundation/service/api-bus/ability/callback.js +55 -0
- package/esm/foundation/service/api-bus/ability/globalData.d.ts +10 -0
- package/esm/foundation/service/api-bus/ability/globalData.js +89 -0
- package/esm/foundation/service/api-bus/ability/request.d.ts +10 -0
- package/esm/foundation/service/api-bus/ability/request.js +151 -0
- package/esm/foundation/service/api-bus/ability/security.d.ts +12 -0
- package/esm/foundation/service/api-bus/ability/security.js +161 -0
- package/esm/foundation/service/api-bus/ability/tracker.d.ts +9 -0
- package/esm/foundation/service/api-bus/ability/tracker.js +80 -0
- package/esm/foundation/service/api-bus/busManager.d.ts +127 -0
- package/esm/foundation/service/api-bus/busManager.js +398 -0
- package/esm/foundation/service/api-bus/index.d.ts +20 -0
- package/esm/foundation/service/api-bus/index.js +88 -0
- package/esm/foundation/service/api-bus/interface.d.ts +48 -0
- package/esm/foundation/service/api-bus/interface.js +54 -0
- package/esm/foundation/service/container/index.d.ts +30 -0
- package/esm/foundation/service/container/index.js +298 -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-center.d.ts +76 -0
- package/esm/foundation/service/event-center.js +243 -0
- package/esm/foundation/service/global-data/index.d.ts +11 -0
- package/esm/foundation/service/global-data/index.js +68 -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 +214 -0
- package/esm/foundation/service/security/index.d.ts +28 -0
- package/esm/foundation/service/security/index.js +286 -0
- package/esm/foundation/service/security/security.d.ts +33 -0
- package/esm/foundation/service/security/security.js +182 -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/payment_product_utils.d.ts +13 -0
- package/esm/foundation/utils/payment_product_utils.js +38 -0
- package/esm/foundation/utils/redirect_utils.d.ts +11 -0
- package/esm/foundation/utils/redirect_utils.js +263 -0
- package/esm/foundation/utils/system_events.d.ts +4 -0
- package/esm/foundation/utils/system_events.js +66 -0
- package/esm/foundation/utils/web_app_url_utils.d.ts +46 -0
- package/esm/foundation/utils/web_app_url_utils.js +112 -0
- package/esm/index.d.ts +12 -6
- package/esm/index.js +75 -64
- 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 +15 -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 -8
- package/esm/plugin/component/component.popup.style.d.ts +6 -6
- package/esm/plugin/component/component.popup.style.js +6 -6
- package/esm/plugin/component/index.d.ts +8 -7
- package/esm/plugin/component/index.js +160 -103
- 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/type.d.ts +3 -3
- 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 +247 -39
- package/esm/types/index.js +109 -59
- package/esm/util/createIframeNode.d.ts +2 -2
- package/esm/util/createIframeNode.js +3 -3
- package/esm/util/getBackScheme.js +95 -3
- package/esm/util/security.d.ts +2 -2
- package/esm/util/security.js +2 -2
- package/package.json +2 -1
- package/esm/util/ua/index.d.ts +0 -2
- package/esm/util/ua/index.js +0 -2
- package/esm/util/ua/isAndroid.d.ts +0 -4
- package/esm/util/ua/isAndroid.js +0 -7
- package/esm/util/ua/isIOS.d.ts +0 -4
- package/esm/util/ua/isIOS.js +0 -7
@@ -0,0 +1,463 @@
|
|
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, getBackScheme, isPC, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
|
20
|
+
export var EasySafePayProcessor = /*#__PURE__*/function () {
|
21
|
+
function EasySafePayProcessor() {
|
22
|
+
_classCallCheck(this, EasySafePayProcessor);
|
23
|
+
_defineProperty(this, "paymentContext", void 0);
|
24
|
+
_defineProperty(this, "initConfig", void 0);
|
25
|
+
_defineProperty(this, "logger", void 0);
|
26
|
+
_defineProperty(this, "securityService", void 0);
|
27
|
+
_defineProperty(this, "instanceId", void 0);
|
28
|
+
// 服务端接口区域信息,请求时决定API域名
|
29
|
+
_defineProperty(this, "hostSign", void 0);
|
30
|
+
// 是否允许submitPay提前调用,在ESP非首次的性能优化场景使用
|
31
|
+
_defineProperty(this, "allowSubmitPayCallAhead", void 0);
|
32
|
+
_defineProperty(this, "channelBehavior", void 0);
|
33
|
+
_defineProperty(this, "SECURITY_SDK_INIT_TIMEOUT", 18000);
|
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.securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
42
|
+
this.preloadWebApp(config, this.instanceId, sdkMetaData);
|
43
|
+
}
|
44
|
+
}, {
|
45
|
+
key: "startBizFlow",
|
46
|
+
value: function () {
|
47
|
+
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentContext) {
|
48
|
+
var _paymentContext$payme2, _this$channelBehavior;
|
49
|
+
var _paymentContext$payme, productSceneVersion, paymentMethodCategoryType, autoDebitWithToken, requireFastSdk, authUrlInfo, isFirstTimeToPay, webAppUrl, resultPayload;
|
50
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
52
|
+
case 0:
|
53
|
+
// 放在最前面的逻辑
|
54
|
+
// 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
|
55
|
+
if (isPC()) {
|
56
|
+
// 非TOSS渠道,在PC场景需要改成1.0
|
57
|
+
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)) {
|
58
|
+
paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion = '1.0';
|
59
|
+
}
|
60
|
+
}
|
61
|
+
this.paymentContext = paymentContext;
|
62
|
+
this.hostSign = ((paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSession) || '').split('&&')[1] || '';
|
63
|
+
productSceneVersion = paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
64
|
+
paymentMethodCategoryType = paymentContext.paymentSessionObj.paymentSessionConfig.paymentMethodCategoryType;
|
65
|
+
autoDebitWithToken = paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
66
|
+
requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
|
67
|
+
authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
|
68
|
+
this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
|
69
|
+
// 首次支付
|
70
|
+
isFirstTimeToPay = !autoDebitWithToken; // 处理ESP1.0极速外跳支付场景
|
71
|
+
if (!(productSceneVersion === '1.0' && isFirstTimeToPay && requireFastSdk)) {
|
72
|
+
_context.next = 12;
|
73
|
+
break;
|
74
|
+
}
|
75
|
+
return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
|
76
|
+
case 12:
|
77
|
+
// 下面的场景是需要渲染UI的渠道, 打开WebUrl
|
78
|
+
webAppUrl = this.buildWebAppUrl(); // const webAppUrl = 'http://svc-9kvjxwjf68cptha8.cloudide.svc.et15-sqa.alipay.net:5173/src/component-app/index.html';
|
79
|
+
resultPayload = {
|
80
|
+
url: webAppUrl,
|
81
|
+
allowClickPopupOutsideClose: (_this$channelBehavior = this.channelBehavior) === null || _this$channelBehavior === void 0 ? void 0 : _this$channelBehavior.allowClickOutsideClose
|
82
|
+
};
|
83
|
+
ProductInfoCacheUtil.savePreviousProductInfo(ProductSceneEnum.EASY_PAY, {
|
84
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
85
|
+
hostSign: this.hostSign,
|
86
|
+
productSceneVersion: productSceneVersion
|
87
|
+
});
|
88
|
+
// 返回结果之前,发送 sessionData,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
|
89
|
+
this.sendRequestAndWaitWebLaunch();
|
90
|
+
// 返回结果,RENDER,让外层去处理iframe加载等逻辑
|
91
|
+
return _context.abrupt("return", {
|
92
|
+
behaviorType: 'RENDER',
|
93
|
+
payload: resultPayload
|
94
|
+
});
|
95
|
+
case 17:
|
96
|
+
case "end":
|
97
|
+
return _context.stop();
|
98
|
+
}
|
99
|
+
}, _callee, this);
|
100
|
+
}));
|
101
|
+
function startBizFlow(_x) {
|
102
|
+
return _startBizFlow.apply(this, arguments);
|
103
|
+
}
|
104
|
+
return startBizFlow;
|
105
|
+
}()
|
106
|
+
}, {
|
107
|
+
key: "preloadWebApp",
|
108
|
+
value: function preloadWebApp(config, instanceId, sdkMetaData) {
|
109
|
+
// trigger preload
|
110
|
+
var containerService = ServiceProvider.getInstance(this.instanceId).getService('Container');
|
111
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(config, instanceId, sdkMetaData),
|
112
|
+
taskId = _this$buildWebAppPrel.taskId,
|
113
|
+
webUrl = _this$buildWebAppPrel.webUrl;
|
114
|
+
containerService.preload(taskId, webUrl);
|
115
|
+
}
|
116
|
+
}, {
|
117
|
+
key: "buildWebAppPreloadUrl",
|
118
|
+
value: function buildWebAppPreloadUrl(initConfig, instanceId, sdkMetaData) {
|
119
|
+
var _this = this;
|
120
|
+
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(ProductSceneEnum.EASY_PAY, function (erorrMsg) {
|
121
|
+
if (erorrMsg) {
|
122
|
+
_this.logger.logError({
|
123
|
+
title: 'performance_optimization_get_previousChannel_error'
|
124
|
+
}, {
|
125
|
+
error: erorrMsg
|
126
|
+
});
|
127
|
+
}
|
128
|
+
});
|
129
|
+
var paymentMethodCategoryType = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.paymentMethodCategoryType;
|
130
|
+
var productSceneVersion = (previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.productSceneVersion) || '2.0';
|
131
|
+
var taskId = "ams-checkout-component-".concat(sdkMetaData.productScene, "_").concat(paymentMethodCategoryType);
|
132
|
+
var hostSign = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.hostSign;
|
133
|
+
var webUrl = WebAppUrlUtil.getWebAppUrl({
|
134
|
+
environment: initConfig.environment,
|
135
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
136
|
+
sdkMetaData: sdkMetaData,
|
137
|
+
isPreload: true,
|
138
|
+
productSceneVersion: productSceneVersion,
|
139
|
+
query: {
|
140
|
+
analyticsEnabled: initConfig.analytics.enabled,
|
141
|
+
displayType: DisplayTypeEnum.popup,
|
142
|
+
instanceId: instanceId,
|
143
|
+
locale: initConfig.locale,
|
144
|
+
hostSign: hostSign
|
145
|
+
}
|
146
|
+
});
|
147
|
+
return {
|
148
|
+
webUrl: webUrl,
|
149
|
+
taskId: taskId
|
150
|
+
};
|
151
|
+
}
|
152
|
+
}, {
|
153
|
+
key: "buildWebAppUrl",
|
154
|
+
value: function buildWebAppUrl() {
|
155
|
+
var _paymentContext$payme3, _paymentContext$payme4;
|
156
|
+
var paymentContext = this.paymentContext;
|
157
|
+
var paymentMethodCategoryType = (_paymentContext$payme3 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme3 === void 0 ? void 0 : _paymentContext$payme3.paymentMethodCategoryType;
|
158
|
+
var productSceneVersion = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productSceneVersion;
|
159
|
+
var hostSign = this.hostSign;
|
160
|
+
var webAppUrl = WebAppUrlUtil.getWebAppUrl({
|
161
|
+
environment: this.initConfig.environment,
|
162
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
163
|
+
sdkMetaData: paymentContext.sdkMetaData,
|
164
|
+
productSceneVersion: productSceneVersion,
|
165
|
+
isPreload: false,
|
166
|
+
query: {
|
167
|
+
analyticsEnabled: this.initConfig.analytics.enabled,
|
168
|
+
displayType: DisplayTypeEnum.popup,
|
169
|
+
instanceId: this.instanceId,
|
170
|
+
locale: this.initConfig.locale,
|
171
|
+
hostSign: hostSign
|
172
|
+
}
|
173
|
+
});
|
174
|
+
return webAppUrl;
|
175
|
+
}
|
176
|
+
}, {
|
177
|
+
key: "buildRedirectResult",
|
178
|
+
value: function buildRedirectResult(authUrlInfo) {
|
179
|
+
var data;
|
180
|
+
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) {
|
181
|
+
data = {
|
182
|
+
url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
|
183
|
+
schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
|
184
|
+
applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl
|
185
|
+
};
|
186
|
+
} else {
|
187
|
+
data = {
|
188
|
+
url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.normalUrl,
|
189
|
+
schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.schemeUrl,
|
190
|
+
applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl
|
191
|
+
};
|
192
|
+
}
|
193
|
+
var result = {
|
194
|
+
behaviorType: 'REDIRECT',
|
195
|
+
payload: data
|
196
|
+
};
|
197
|
+
return result;
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* 等待Web应用启动,然后发送renderComponent事件
|
202
|
+
* start waiting web launch, then send renderComponent event
|
203
|
+
* */
|
204
|
+
}, {
|
205
|
+
key: "sendRequestAndWaitWebLaunch",
|
206
|
+
value: function sendRequestAndWaitWebLaunch() {
|
207
|
+
var _this2 = this;
|
208
|
+
var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
209
|
+
var webLaunchPromise = new Promise(function (resolve) {
|
210
|
+
eventCenter.listen('onLaunch', function (res) {
|
211
|
+
resolve(res);
|
212
|
+
});
|
213
|
+
});
|
214
|
+
|
215
|
+
// 等请求和 Web启动都Ready之后,发送renderComponent
|
216
|
+
Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
|
217
|
+
var _this2$paymentContext, _this2$paymentContext2, _this2$paymentContext3, _this2$paymentContext4, _this2$paymentContext5, _this2$paymentContext6;
|
218
|
+
var _ref2 = _slicedToArray(_ref, 3),
|
219
|
+
_initSecurityRes = _ref2[0],
|
220
|
+
submitRes = _ref2[1],
|
221
|
+
_webLaunchRes = _ref2[2];
|
222
|
+
var logMetaData = _this2.logger.getLogConfig().mdata;
|
223
|
+
eventCenter.dispatchToApp({
|
224
|
+
event: 'renderComponent',
|
225
|
+
data: {
|
226
|
+
sessionResult: (_this2$paymentContext = _this2.paymentContext) === null || _this2$paymentContext === void 0 ? void 0 : _this2$paymentContext.paymentSessionObj,
|
227
|
+
submitResult: submitRes,
|
228
|
+
paymentSessionData: (_this2$paymentContext2 = _this2.paymentContext) === null || _this2$paymentContext2 === void 0 ? void 0 : _this2$paymentContext2.paymentSessionId,
|
229
|
+
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
230
|
+
renderDisplayType: _this2.paymentContext.displayInfo.type,
|
231
|
+
appearance: (_this2$paymentContext3 = _this2.paymentContext.displayInfo) === null || _this2$paymentContext3 === void 0 ? void 0 : _this2$paymentContext3.appearance,
|
232
|
+
notRedirectAfterComplete: ((_this2$paymentContext4 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext4 === void 0 ? void 0 : _this2$paymentContext4.notRedirectAfterComplete) === true,
|
233
|
+
isAppWebview: _this2.paymentContext.startBizFlowOptions.isAppWebview,
|
234
|
+
merchantAppointParam: (_this2$paymentContext5 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext5 === void 0 ? void 0 : _this2$paymentContext5.merchantAppointParam,
|
235
|
+
allowSubmitPayCallAhead: _this2.allowSubmitPayCallAhead,
|
236
|
+
envInfo: {
|
237
|
+
screenHeight: screen.height,
|
238
|
+
screenWidth: screen.width
|
239
|
+
},
|
240
|
+
logMetaData: _objectSpread(_objectSpread({
|
241
|
+
trackId: logMetaData.requestSeq,
|
242
|
+
platform: logMetaData.platform,
|
243
|
+
firstLogTime: logMetaData.firstLogTime
|
244
|
+
}, ((_this2$paymentContext6 = _this2.paymentContext.paymentSessionObj) === null || _this2$paymentContext6 === void 0 ? void 0 : _this2$paymentContext6.paymentSessionConfig) || {}), {}, {
|
245
|
+
renderDisplayType: logMetaData.renderDisplayType,
|
246
|
+
sdkVersion: logMetaData.sdkVersion,
|
247
|
+
merchantId: logMetaData.merchantId,
|
248
|
+
instanceId: logMetaData.instanceId,
|
249
|
+
paymentMethodType: logMetaData.paymentMethodType
|
250
|
+
})
|
251
|
+
}
|
252
|
+
});
|
253
|
+
});
|
254
|
+
}
|
255
|
+
}, {
|
256
|
+
key: "processSubmitPay",
|
257
|
+
value: function () {
|
258
|
+
var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
259
|
+
var _this$paymentContext, _this$paymentContext2, _this$paymentContext3, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$2;
|
260
|
+
var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, res;
|
261
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
262
|
+
while (1) switch (_context2.prev = _context2.next) {
|
263
|
+
case 0:
|
264
|
+
submitParams = {
|
265
|
+
paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionId) || '',
|
266
|
+
paymentSessionConfig: (_this$paymentContext2 = this.paymentContext) === null || _this$paymentContext2 === void 0 || (_this$paymentContext2 = _this$paymentContext2.paymentSessionObj) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionConfig
|
267
|
+
};
|
268
|
+
_ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
|
269
|
+
_ref4 = ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionObj) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$enableS = _ref4$action2.enableSignAgreement, enableSignAgreement = _ref4$action2$enableS === void 0 ? false : _ref4$action2$enableS, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
270
|
+
if (productSceneVersion === '2.0' && !autoDebitWithToken) {
|
271
|
+
///EasyPay 2.0 首次传signAgreement字段
|
272
|
+
submitParams['signAgreement'] = enableSignAgreement;
|
273
|
+
paymentMethodType = (_this$paymentContext$ = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$ === void 0 || (_this$paymentContext$ = _this$paymentContext$.paymentMethodInfoView) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.paymentMethodType;
|
274
|
+
isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
|
275
|
+
if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
|
276
|
+
backScheme = getBackScheme(undefined, this.logger);
|
277
|
+
if (backScheme && backScheme !== 'https') {
|
278
|
+
submitParams['h5FromApp'] = encodeURIComponent(backScheme);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
|
283
|
+
//console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
|
284
|
+
if (this.allowSubmitPayCallAhead) {
|
285
|
+
_context2.next = 7;
|
286
|
+
break;
|
287
|
+
}
|
288
|
+
return _context2.abrupt("return", {
|
289
|
+
message: 'sdk no need to make submitPay request',
|
290
|
+
success: true
|
291
|
+
});
|
292
|
+
case 7:
|
293
|
+
requestBizId = uuid(); // 下面真实发请求
|
294
|
+
this.logger.logInfo({
|
295
|
+
title: 'sdk_event_submitPay'
|
296
|
+
}, {
|
297
|
+
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
298
|
+
requestBizId: requestBizId
|
299
|
+
});
|
300
|
+
// 由渠道定制点来构建额外参数
|
301
|
+
extParams = ((_this$channelBehavior2 = this.channelBehavior) === null || _this$channelBehavior2 === void 0 || (_this$channelBehavior3 = _this$channelBehavior2.buildSubmitPayExtParams) === null || _this$channelBehavior3 === void 0 ? void 0 : _this$channelBehavior3.call(_this$channelBehavior2, {
|
302
|
+
instanceId: this.instanceId,
|
303
|
+
locale: this.initConfig.locale,
|
304
|
+
paymentMethodType: (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentMethodInfoView) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.paymentMethodType,
|
305
|
+
paymentSessionData: this.paymentContext.paymentSessionId,
|
306
|
+
env: this.initConfig.environment,
|
307
|
+
sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
|
308
|
+
})) || {};
|
309
|
+
extParams.complianceSDK = true;
|
310
|
+
submitParams.extParams = extParams;
|
311
|
+
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
312
|
+
_context2.prev = 13;
|
313
|
+
_context2.t0 = requester;
|
314
|
+
_context2.t1 = submitParams;
|
315
|
+
_context2.t2 = this.initConfig.environment;
|
316
|
+
_context2.next = 19;
|
317
|
+
return this.acquireApdidToken();
|
318
|
+
case 19:
|
319
|
+
_context2.t3 = _context2.sent;
|
320
|
+
_context2.t4 = {
|
321
|
+
deviceId: _context2.t3
|
322
|
+
};
|
323
|
+
_context2.t5 = this.hostSign;
|
324
|
+
_context2.t6 = {
|
325
|
+
env: _context2.t2,
|
326
|
+
timeout: 15000,
|
327
|
+
envInfo: _context2.t4,
|
328
|
+
hostSign: _context2.t5,
|
329
|
+
needEnvInfo: true,
|
330
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
331
|
+
};
|
332
|
+
_context2.next = 25;
|
333
|
+
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
|
334
|
+
case 25:
|
335
|
+
res = _context2.sent;
|
336
|
+
this.logger.logInfo({
|
337
|
+
title: 'sdk_event_submitPayEnd'
|
338
|
+
}, {
|
339
|
+
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
340
|
+
requestBizId: requestBizId,
|
341
|
+
traceId: res.traceId
|
342
|
+
});
|
343
|
+
return _context2.abrupt("return", res);
|
344
|
+
case 30:
|
345
|
+
_context2.prev = 30;
|
346
|
+
_context2.t7 = _context2["catch"](13);
|
347
|
+
this.logger.logError({
|
348
|
+
title: 'sdk_event_submitPay_failed'
|
349
|
+
}, {
|
350
|
+
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
351
|
+
errorReason: _context2.t7,
|
352
|
+
requestBizId: requestBizId,
|
353
|
+
traceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
|
354
|
+
});
|
355
|
+
throw _context2.t7;
|
356
|
+
case 34:
|
357
|
+
case "end":
|
358
|
+
return _context2.stop();
|
359
|
+
}
|
360
|
+
}, _callee2, this, [[13, 30]]);
|
361
|
+
}));
|
362
|
+
function processSubmitPay() {
|
363
|
+
return _processSubmitPay.apply(this, arguments);
|
364
|
+
}
|
365
|
+
return processSubmitPay;
|
366
|
+
}()
|
367
|
+
}, {
|
368
|
+
key: "acquireApdidToken",
|
369
|
+
value: function () {
|
370
|
+
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
371
|
+
var _this$paymentContext$3;
|
372
|
+
var securityService, productScene, deviceId;
|
373
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
374
|
+
while (1) switch (_context3.prev = _context3.next) {
|
375
|
+
case 0:
|
376
|
+
securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
377
|
+
productScene = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentSessionConfig) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.productScene;
|
378
|
+
deviceId = securityService.getDeviceId({
|
379
|
+
productScene: productScene
|
380
|
+
});
|
381
|
+
return _context3.abrupt("return", deviceId);
|
382
|
+
case 4:
|
383
|
+
case "end":
|
384
|
+
return _context3.stop();
|
385
|
+
}
|
386
|
+
}, _callee3, this);
|
387
|
+
}));
|
388
|
+
function acquireApdidToken() {
|
389
|
+
return _acquireApdidToken.apply(this, arguments);
|
390
|
+
}
|
391
|
+
return acquireApdidToken;
|
392
|
+
}()
|
393
|
+
}, {
|
394
|
+
key: "initSecuritySDK",
|
395
|
+
value: function () {
|
396
|
+
var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
397
|
+
var _this$paymentContext$4, _this$paymentContext$5, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay, shouldInitSecuritySDK;
|
398
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
399
|
+
while (1) switch (_context4.prev = _context4.next) {
|
400
|
+
case 0:
|
401
|
+
_context4.prev = 0;
|
402
|
+
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
403
|
+
nonCompliant = (_this$paymentContext$4 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.nonCompliant;
|
404
|
+
nonInitSecuritySDK = (_this$paymentContext$5 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$5 === void 0 ? void 0 : _this$paymentContext$5.nonInitSecuritySDK;
|
405
|
+
isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
406
|
+
shouldInitSecuritySDK = false;
|
407
|
+
if (nonInitSecuritySDK) {
|
408
|
+
// 钱包不依赖风控
|
409
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk when nonInitSecuritySDK is true');
|
410
|
+
shouldInitSecuritySDK = false;
|
411
|
+
} else {
|
412
|
+
if (productSceneVersion === '1.0') {
|
413
|
+
// 1.0 不初始化 SecuritySDK
|
414
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 1.0');
|
415
|
+
shouldInitSecuritySDK = false;
|
416
|
+
} else if (productSceneVersion === '2.0') {
|
417
|
+
if (nonCompliant === true) {
|
418
|
+
// 未切流「隐私合规」
|
419
|
+
// console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and nonCompliant is true');
|
420
|
+
shouldInitSecuritySDK = true;
|
421
|
+
} else {
|
422
|
+
if (isFirstTimeToPay) {
|
423
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 2.0 and when first time to pay');
|
424
|
+
shouldInitSecuritySDK = false;
|
425
|
+
} else {
|
426
|
+
// 切流「隐私合规」且非首次支付
|
427
|
+
// console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and when not first time to pay');
|
428
|
+
shouldInitSecuritySDK = true;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
}
|
433
|
+
if (!shouldInitSecuritySDK) {
|
434
|
+
_context4.next = 10;
|
435
|
+
break;
|
436
|
+
}
|
437
|
+
_context4.next = 10;
|
438
|
+
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
439
|
+
case 10:
|
440
|
+
this.logger.logInfo({
|
441
|
+
title: 'a3753.b101271.c388193.d514078'
|
442
|
+
}, {
|
443
|
+
riskSdkInfo: shouldInitSecuritySDK ? RiskSdkInfoEnum.NEED : RiskSdkInfoEnum.NO_NEED
|
444
|
+
});
|
445
|
+
_context4.next = 15;
|
446
|
+
break;
|
447
|
+
case 13:
|
448
|
+
_context4.prev = 13;
|
449
|
+
_context4.t0 = _context4["catch"](0);
|
450
|
+
case 15:
|
451
|
+
case "end":
|
452
|
+
return _context4.stop();
|
453
|
+
}
|
454
|
+
}, _callee4, this, [[0, 13]]);
|
455
|
+
}));
|
456
|
+
function initSecuritySDK() {
|
457
|
+
return _initSecuritySDK.apply(this, arguments);
|
458
|
+
}
|
459
|
+
return initSecuritySDK;
|
460
|
+
}()
|
461
|
+
}]);
|
462
|
+
return EasySafePayProcessor;
|
463
|
+
}();
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { BusContext, BusMessage, BusSubscriber } from "../busManager";
|
2
|
+
import { callOnEventCallback } from "../../../../types";
|
3
|
+
export declare class SDKCallbackBusSubscriber extends BusSubscriber {
|
4
|
+
private _onEventCallback?;
|
5
|
+
constructor(onEventCallback?: callOnEventCallback);
|
6
|
+
actionNames(): string[];
|
7
|
+
protected onEventCallback(message: BusMessage): void;
|
8
|
+
onMessage(context: BusContext, message: BusMessage): void;
|
9
|
+
}
|
@@ -0,0 +1,55 @@
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
5
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
6
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
14
|
+
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); }
|
15
|
+
import { SDKCallbackActionEnum } from "../interface";
|
16
|
+
import { BusSubscriber } from "../busManager";
|
17
|
+
export var SDKCallbackBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
18
|
+
_inherits(SDKCallbackBusSubscriber, _BusSubscriber);
|
19
|
+
var _super = _createSuper(SDKCallbackBusSubscriber);
|
20
|
+
function SDKCallbackBusSubscriber(onEventCallback) {
|
21
|
+
var _this;
|
22
|
+
_classCallCheck(this, SDKCallbackBusSubscriber);
|
23
|
+
_this = _super.call(this);
|
24
|
+
_defineProperty(_assertThisInitialized(_this), "_onEventCallback", void 0);
|
25
|
+
_this._onEventCallback = onEventCallback;
|
26
|
+
return _this;
|
27
|
+
}
|
28
|
+
_createClass(SDKCallbackBusSubscriber, [{
|
29
|
+
key: "actionNames",
|
30
|
+
value: function actionNames() {
|
31
|
+
return Object.values(SDKCallbackActionEnum);
|
32
|
+
}
|
33
|
+
}, {
|
34
|
+
key: "onEventCallback",
|
35
|
+
value: function onEventCallback(message) {
|
36
|
+
var data = message.getJSONObject();
|
37
|
+
console.log("onEventCallback", message);
|
38
|
+
if (this._onEventCallback && data) {
|
39
|
+
this._onEventCallback(data);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}, {
|
43
|
+
key: "onMessage",
|
44
|
+
value: function onMessage(context, message) {
|
45
|
+
switch (message.getAction()) {
|
46
|
+
case SDKCallbackActionEnum.onEventCallback:
|
47
|
+
this.onEventCallback(message);
|
48
|
+
break;
|
49
|
+
default:
|
50
|
+
console.log("Unknown action: " + message.getAction());
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}]);
|
54
|
+
return SDKCallbackBusSubscriber;
|
55
|
+
}(BusSubscriber);
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { BusContext, BusMessage, BusSubscriber } from '../../../../foundation/service/api-bus/busManager';
|
2
|
+
export declare class DataBusSubscriber extends BusSubscriber {
|
3
|
+
private instanceId;
|
4
|
+
constructor(instanceId: string);
|
5
|
+
actionNames(): string[];
|
6
|
+
protected getGlobalData(context: BusContext, message: BusMessage): void;
|
7
|
+
protected setGlobalData(context: BusContext, message: BusMessage): void;
|
8
|
+
protected clearGlobalData(context: BusContext, message: BusMessage): void;
|
9
|
+
onMessage(context: BusContext, message: BusMessage): void;
|
10
|
+
}
|