@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730441340-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +6 -7
- package/esm/constant/index.js +80 -11
- package/esm/{foundation/service/api-bus → core/bus}/ability/callback.d.ts +2 -2
- package/esm/{foundation/service/api-bus → core/bus}/ability/callback.js +1 -1
- package/esm/{foundation/service/api-bus → core/bus}/ability/security.d.ts +4 -6
- package/esm/{foundation/service/api-bus → core/bus}/ability/security.js +35 -92
- package/esm/{foundation/service/api-bus → core/bus}/ability/tracker.d.ts +4 -4
- package/esm/{foundation/service/api-bus → core/bus}/ability/tracker.js +3 -6
- package/esm/{foundation/service/api-bus/busManager.d.ts → core/bus/index.d.ts} +15 -17
- package/esm/{foundation/service/api-bus/busManager.js → core/bus/index.js} +35 -67
- package/esm/{foundation/service/api-bus → core/bus}/interface.d.ts +0 -12
- package/esm/{foundation/service/api-bus → core/bus}/interface.js +2 -16
- package/esm/core/component/address.d.ts +8 -0
- package/esm/{foundation/service/api-bus/ability/globalData.js → core/component/address.js} +58 -75
- package/esm/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/{foundation/service/container/popup.js → core/component/appPreloadProcessing.js} +83 -97
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +166 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +531 -0
- package/esm/core/drop-in/index.d.ts +22 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +89 -0
- package/esm/core/instance/index.js +499 -0
- package/esm/index.d.ts +28 -5
- package/esm/index.js +158 -29
- package/esm/plugin/applepay/component.d.ts +50 -0
- package/esm/plugin/applepay/component.js +339 -0
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/plugin/applepay/interface.d.ts +161 -0
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/plugin/applepay/service.d.ts +54 -0
- package/esm/plugin/applepay/service.js +289 -0
- package/esm/plugin/component/cashierApp.d.ts +34 -0
- package/esm/plugin/component/cashierApp.js +237 -0
- package/esm/{component → plugin/component}/channel.d.ts +4 -3
- package/esm/{component → plugin/component}/channel.js +37 -1
- package/esm/plugin/component/component.inline.style.d.ts +10 -0
- package/esm/{component → plugin/component}/component.inline.style.js +9 -11
- package/esm/{component → plugin/component}/component.popup.style.d.ts +6 -15
- package/esm/{component → plugin/component}/component.popup.style.js +18 -36
- package/esm/plugin/component/index.d.ts +126 -0
- package/esm/plugin/component/index.js +1839 -0
- package/esm/{component → plugin/component}/popupWindow.style.js +2 -2
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/drop-in/index.d.ts +71 -0
- package/esm/plugin/drop-in/index.js +324 -0
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +6 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +390 -0
- package/esm/plugin/type.d.ts +34 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/types/index.d.ts +55 -61
- package/esm/types/index.js +62 -63
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +2 -2
- package/esm/util/getBackScheme.js +2 -94
- package/esm/util/index.d.ts +11 -1
- package/esm/util/index.js +84 -3
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/{foundation/service/security → util}/security.d.ts +2 -2
- package/esm/{foundation/service/security → util}/security.js +3 -3
- package/esm/util/ua/index.d.ts +2 -0
- package/esm/util/ua/index.js +2 -0
- package/esm/util/ua/isAndroid.d.ts +4 -0
- package/esm/util/ua/isAndroid.js +7 -0
- package/esm/util/ua/isIOS.d.ts +4 -0
- package/esm/util/ua/isIOS.js +7 -0
- package/package.json +2 -2
- package/esm/component/component.inline.style.d.ts +0 -10
- package/esm/foundation/core/index.d.ts +0 -26
- package/esm/foundation/core/index.js +0 -364
- package/esm/foundation/index.d.ts +0 -74
- package/esm/foundation/index.js +0 -42
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +0 -18
- package/esm/foundation/product-processor/easysafepay/deps.js +0 -12
- package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -27
- package/esm/foundation/product-processor/easysafepay/index.js +0 -596
- package/esm/foundation/service/api-bus/ability/globalData.d.ts +0 -10
- package/esm/foundation/service/api-bus/ability/request.d.ts +0 -10
- package/esm/foundation/service/api-bus/ability/request.js +0 -151
- package/esm/foundation/service/api-bus/index.d.ts +0 -20
- package/esm/foundation/service/api-bus/index.js +0 -88
- package/esm/foundation/service/container/index.d.ts +0 -28
- package/esm/foundation/service/container/index.js +0 -256
- package/esm/foundation/service/container/popup.d.ts +0 -17
- package/esm/foundation/service/container/utils.d.ts +0 -7
- package/esm/foundation/service/container/utils.js +0 -48
- package/esm/foundation/service/event-center.d.ts +0 -74
- package/esm/foundation/service/event-center.js +0 -213
- package/esm/foundation/service/global-data/index.d.ts +0 -11
- package/esm/foundation/service/global-data/index.js +0 -68
- package/esm/foundation/service/index.d.ts +0 -19
- package/esm/foundation/service/index.js +0 -82
- package/esm/foundation/service/log/index.d.ts +0 -43
- package/esm/foundation/service/log/index.js +0 -235
- package/esm/foundation/service/log/types.d.ts +0 -32
- package/esm/foundation/service/requester/deps.d.ts +0 -17
- package/esm/foundation/service/requester/deps.js +0 -11
- package/esm/foundation/service/requester/requester.d.ts +0 -22
- package/esm/foundation/service/requester/requester.js +0 -214
- package/esm/foundation/service/security/index.d.ts +0 -28
- package/esm/foundation/service/security/index.js +0 -285
- package/esm/foundation/types/index.d.ts +0 -4
- package/esm/foundation/types/index.js +0 -4
- package/esm/foundation/utils/gray_scale_utils.d.ts +0 -7
- package/esm/foundation/utils/gray_scale_utils.js +0 -40
- package/esm/foundation/utils/payment_context_utils.d.ts +0 -13
- package/esm/foundation/utils/payment_context_utils.js +0 -57
- package/esm/foundation/utils/payment_product_utils.d.ts +0 -13
- package/esm/foundation/utils/payment_product_utils.js +0 -38
- package/esm/foundation/utils/redirect_utils.d.ts +0 -6
- package/esm/foundation/utils/redirect_utils.js +0 -115
- package/esm/foundation/utils/system_events.d.ts +0 -4
- package/esm/foundation/utils/system_events.js +0 -71
- package/esm/foundation/utils/web_app_url_utils.d.ts +0 -46
- package/esm/foundation/utils/web_app_url_utils.js +0 -112
- /package/esm/{component → plugin/component}/popupWindow.style.d.ts +0 -0
- /package/esm/{foundation/service/log/types.js → plugin/type.js} +0 -0
@@ -0,0 +1,289 @@
|
|
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 _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; }
|
3
|
+
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); } }
|
4
|
+
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); }); }; }
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6
|
+
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); } }
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
8
|
+
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; }
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
10
|
+
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); }
|
11
|
+
/**
|
12
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
13
|
+
*
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
15
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
16
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
17
|
+
*/
|
18
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
|
+
import { APPLE_PAY_VERSION, APPLE_PAY_RECURRING_VERSION } from "./interface";
|
20
|
+
import { eventCodeEnum } from "../../types";
|
21
|
+
import { ApplePayComponentEvent } from "./component";
|
22
|
+
var PaymentState = /*#__PURE__*/function (PaymentState) {
|
23
|
+
PaymentState[PaymentState["notStarted"] = 0] = "notStarted";
|
24
|
+
PaymentState[PaymentState["pending"] = 1] = "pending";
|
25
|
+
PaymentState[PaymentState["fail"] = 2] = "fail";
|
26
|
+
PaymentState[PaymentState["success"] = 3] = "success";
|
27
|
+
return PaymentState;
|
28
|
+
}(PaymentState || {});
|
29
|
+
/**
|
30
|
+
* Apple Pay Service
|
31
|
+
*/
|
32
|
+
var ApplePayService = /*#__PURE__*/function () {
|
33
|
+
function ApplePayService(logger) {
|
34
|
+
var _this = this;
|
35
|
+
_classCallCheck(this, ApplePayService);
|
36
|
+
_defineProperty(this, "merchantIdentifier", void 0);
|
37
|
+
_defineProperty(this, "merchantName", void 0);
|
38
|
+
_defineProperty(this, "session", void 0);
|
39
|
+
_defineProperty(this, "paymentState", void 0);
|
40
|
+
_defineProperty(this, "getMerchantSession", void 0);
|
41
|
+
_defineProperty(this, "completePaymentAuthorized", void 0);
|
42
|
+
_defineProperty(this, "completeApplePay", void 0);
|
43
|
+
_defineProperty(this, "logError", void 0);
|
44
|
+
_defineProperty(this, "isRecurring", false);
|
45
|
+
_defineProperty(this, "logger", void 0);
|
46
|
+
_defineProperty(this, "onvalidatemerchant", function (event) {
|
47
|
+
var success = false;
|
48
|
+
_this.getMerchantSession({
|
49
|
+
displayName: _this.merchantName,
|
50
|
+
merchantIdentifier: _this.merchantIdentifier,
|
51
|
+
validationUrl: event.validationURL
|
52
|
+
}).then(function (merchantSessionObjectString) {
|
53
|
+
console.log("onvalidatemerchant#merchantSessionObjectString", merchantSessionObjectString);
|
54
|
+
var merchantSessionObject = JSON.parse(merchantSessionObjectString);
|
55
|
+
_this.session.completeMerchantValidation(merchantSessionObject);
|
56
|
+
success = true;
|
57
|
+
}).catch(function (error) {
|
58
|
+
_this.logError(eventCodeEnum.SDK_PAYMENT_FAIL, 'MerchantValidationError', error);
|
59
|
+
_this.sessionAbort();
|
60
|
+
});
|
61
|
+
_this.logger.logInfo({
|
62
|
+
name: 'APPLE_PAY',
|
63
|
+
title: ApplePayComponentEvent.sdk_event_appleCreateComponent
|
64
|
+
}, {
|
65
|
+
biz: 'sdk',
|
66
|
+
type: 'funnel',
|
67
|
+
success: success,
|
68
|
+
recurring: _this.isRecurring
|
69
|
+
}).send();
|
70
|
+
});
|
71
|
+
_defineProperty(this, "onpaymentauthorized", function (event) {
|
72
|
+
var _event$payment;
|
73
|
+
var _window = window,
|
74
|
+
ApplePaySession = _window.ApplePaySession;
|
75
|
+
var success = false;
|
76
|
+
var exception = function exception(error) {
|
77
|
+
_this.session.completePayment(ApplePaySession.STATUS_FAILURE);
|
78
|
+
_this.logError(eventCodeEnum.SDK_PAYMENT_FAIL, 'PaymentAuthorizedError', error);
|
79
|
+
_this.sessionAbort();
|
80
|
+
};
|
81
|
+
if (event !== null && event !== void 0 && (_event$payment = event.payment) !== null && _event$payment !== void 0 && _event$payment.token) {
|
82
|
+
_this.paymentState = PaymentState.pending;
|
83
|
+
_this.completePaymentAuthorized({
|
84
|
+
paymentToken: JSON.stringify(event.payment.token)
|
85
|
+
}).then(function (data) {
|
86
|
+
_this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
|
87
|
+
_this.completeApplePay(data);
|
88
|
+
_this.paymentState = PaymentState.success;
|
89
|
+
success = true;
|
90
|
+
}).catch(function (error) {
|
91
|
+
exception(error);
|
92
|
+
_this.paymentState = PaymentState.fail;
|
93
|
+
});
|
94
|
+
} else {
|
95
|
+
exception();
|
96
|
+
}
|
97
|
+
_this.logger.logInfo({
|
98
|
+
name: 'APPLE_PAY',
|
99
|
+
title: ApplePayComponentEvent.sdk_event_appleSubmitToken
|
100
|
+
}, {
|
101
|
+
biz: 'sdk',
|
102
|
+
type: 'funnel',
|
103
|
+
success: success,
|
104
|
+
recurring: _this.isRecurring
|
105
|
+
}).send();
|
106
|
+
});
|
107
|
+
/**
|
108
|
+
* Start Pay
|
109
|
+
*/
|
110
|
+
_defineProperty(this, "startPay", function (param) {
|
111
|
+
var paymentSessionFactor = param.paymentSessionFactor;
|
112
|
+
var extendInfo = paymentSessionFactor.extendInfo,
|
113
|
+
merchantInfo = paymentSessionFactor.merchantInfo,
|
114
|
+
paymentAmount = paymentSessionFactor.paymentAmount,
|
115
|
+
order = paymentSessionFactor.order,
|
116
|
+
recurringInfo = paymentSessionFactor.recurringInfo;
|
117
|
+
_this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
|
118
|
+
var _window2 = window,
|
119
|
+
ApplePaySession = _window2.ApplePaySession;
|
120
|
+
_this.isRecurring = recurringInfo !== null;
|
121
|
+
_this.logger.logInfo({
|
122
|
+
name: 'APPLE_PAY',
|
123
|
+
title: ApplePayComponentEvent.sdk_event_appleCreateComponent
|
124
|
+
}, {
|
125
|
+
biz: 'sdk',
|
126
|
+
type: 'funnel',
|
127
|
+
success: ApplePaySession !== null,
|
128
|
+
recurring: _this.isRecurring
|
129
|
+
}).send();
|
130
|
+
if (!ApplePaySession) {
|
131
|
+
_this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "ApplePaySession is only support in Safari");
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
if (!(extendInfo !== null && extendInfo !== void 0 && extendInfo.merchantCapabilities) || !(extendInfo !== null && extendInfo !== void 0 && extendInfo.supportedNetworks) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.registeredCountry) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.currency) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.value) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.merchantName)) {
|
135
|
+
_this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "Abnormal params paymentSessionFactor");
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
if (recurringInfo) {
|
139
|
+
var _recurringInfo$interv;
|
140
|
+
if (!(order !== null && order !== void 0 && order.orderDescription) || !(recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.managementURL)) {
|
141
|
+
_this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "Abnormal params recurringInfo");
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
var lineItem = {
|
145
|
+
type: 'final',
|
146
|
+
label: recurringInfo.title,
|
147
|
+
amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value,
|
148
|
+
paymentTiming: "recurring",
|
149
|
+
recurringPaymentStartDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.startDate ? new Date(Number(recurringInfo.startDate) * 1000) : null,
|
150
|
+
recurringPaymentEndDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.endDate ? new Date(Number(recurringInfo.endDate) * 1000) : null,
|
151
|
+
recurringPaymentIntervalUnit: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.intervalUnit ? recurringInfo.intervalUnit : "month",
|
152
|
+
recurringPaymentIntervalCount: (_recurringInfo$interv = recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.intervalCount) !== null && _recurringInfo$interv !== void 0 ? _recurringInfo$interv : 1
|
153
|
+
};
|
154
|
+
var recurringRequest = {
|
155
|
+
// 不知道显示在哪里
|
156
|
+
paymentDescription: order === null || order === void 0 ? void 0 : order.orderDescription,
|
157
|
+
billingAgreement: recurringInfo.agreementDescription,
|
158
|
+
regularBilling: lineItem,
|
159
|
+
managementURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.managementURL,
|
160
|
+
tokenNotificationURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.tokenNotificationURL
|
161
|
+
};
|
162
|
+
var request = {
|
163
|
+
merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
|
164
|
+
supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
|
165
|
+
countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
|
166
|
+
currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
|
167
|
+
total: lineItem,
|
168
|
+
recurringPaymentRequest: recurringRequest,
|
169
|
+
lineItems: [lineItem]
|
170
|
+
};
|
171
|
+
_this.session = new ApplePaySession(APPLE_PAY_RECURRING_VERSION, request);
|
172
|
+
} else {
|
173
|
+
var _request = {
|
174
|
+
merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
|
175
|
+
supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
|
176
|
+
countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
|
177
|
+
currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
|
178
|
+
total: {
|
179
|
+
type: 'final',
|
180
|
+
label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
|
181
|
+
amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
|
182
|
+
}
|
183
|
+
};
|
184
|
+
_this.session = new ApplePaySession(APPLE_PAY_VERSION, _request);
|
185
|
+
}
|
186
|
+
// 核身前触发
|
187
|
+
_this.session.onvalidatemerchant = _this.onvalidatemerchant;
|
188
|
+
// 核身后触发
|
189
|
+
_this.session.onpaymentauthorized = _this.onpaymentauthorized;
|
190
|
+
_this.session.oncancel = function () {
|
191
|
+
if (_this.paymentState === PaymentState.pending) {
|
192
|
+
_this.logError(eventCodeEnum.SDK_PAYMENT_PROCESSING, 'Payment processing but user dismissed the sheet');
|
193
|
+
} else {
|
194
|
+
_this.logError(eventCodeEnum.SDK_PAYMENT_CANCEL, 'User dismissed the sheet');
|
195
|
+
}
|
196
|
+
_this.sessionAbort();
|
197
|
+
};
|
198
|
+
_this.session.begin();
|
199
|
+
_this.logger.logInfo({
|
200
|
+
name: 'APPLE_PAY',
|
201
|
+
title: ApplePayComponentEvent.sdk_event_appleShowPaymentSheet
|
202
|
+
}, {
|
203
|
+
biz: 'sdk',
|
204
|
+
type: 'funnel',
|
205
|
+
success: true,
|
206
|
+
recurring: recurringInfo !== null
|
207
|
+
}).send();
|
208
|
+
});
|
209
|
+
this.logger = logger;
|
210
|
+
}
|
211
|
+
|
212
|
+
/**
|
213
|
+
* set Apple Pay Params
|
214
|
+
* @param getMerchantSession
|
215
|
+
* @param completePaymentAuthorized
|
216
|
+
* @param completeApplePay
|
217
|
+
* @param logError
|
218
|
+
* @param applePayTrace
|
219
|
+
*/
|
220
|
+
_createClass(ApplePayService, [{
|
221
|
+
key: "setApplePayParams",
|
222
|
+
value: function setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError) {
|
223
|
+
this.getMerchantSession = getMerchantSession;
|
224
|
+
this.completePaymentAuthorized = completePaymentAuthorized;
|
225
|
+
this.completeApplePay = completeApplePay;
|
226
|
+
this.logError = logError;
|
227
|
+
this.paymentState = PaymentState.notStarted;
|
228
|
+
}
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Is Apple Pay Enabled
|
232
|
+
* @param subTypeEnum
|
233
|
+
* @returns
|
234
|
+
*/
|
235
|
+
}, {
|
236
|
+
key: "hasActiveCard",
|
237
|
+
value: (
|
238
|
+
/**
|
239
|
+
* has Active Card in Apple Pay
|
240
|
+
* @param merchantIdentifier
|
241
|
+
*/
|
242
|
+
function () {
|
243
|
+
var _hasActiveCard = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(merchantIdentifier) {
|
244
|
+
var _window3, ApplePaySession;
|
245
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
246
|
+
while (1) switch (_context.prev = _context.next) {
|
247
|
+
case 0:
|
248
|
+
_window3 = window, ApplePaySession = _window3.ApplePaySession;
|
249
|
+
if (!ApplePaySession) {
|
250
|
+
_context.next = 3;
|
251
|
+
break;
|
252
|
+
}
|
253
|
+
return _context.abrupt("return", ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier));
|
254
|
+
case 3:
|
255
|
+
return _context.abrupt("return", Promise.resolve(false));
|
256
|
+
case 4:
|
257
|
+
case "end":
|
258
|
+
return _context.stop();
|
259
|
+
}
|
260
|
+
}, _callee);
|
261
|
+
}));
|
262
|
+
function hasActiveCard(_x) {
|
263
|
+
return _hasActiveCard.apply(this, arguments);
|
264
|
+
}
|
265
|
+
return hasActiveCard;
|
266
|
+
}())
|
267
|
+
}, {
|
268
|
+
key: "sessionAbort",
|
269
|
+
value: function sessionAbort() {
|
270
|
+
if (this.session) {
|
271
|
+
try {
|
272
|
+
this.session.abort();
|
273
|
+
} catch (error) {
|
274
|
+
console.log("session.abort() error");
|
275
|
+
}
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}], [{
|
279
|
+
key: "canMakePayments",
|
280
|
+
value: function canMakePayments(subTypeEnum) {
|
281
|
+
if ('ApplePayRecurringPayment' === subTypeEnum) {
|
282
|
+
return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_RECURRING_VERSION) : false;
|
283
|
+
}
|
284
|
+
return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_VERSION) : false;
|
285
|
+
}
|
286
|
+
}]);
|
287
|
+
return ApplePayService;
|
288
|
+
}();
|
289
|
+
export default ApplePayService;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { componentSignEnum, Ianalytics, renderDisplayTypeEnum } from '../../types';
|
2
|
+
export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productScene: string, productSceneVersion: string, extendInfo: string, mid: string, sendLog?: boolean) => any;
|
3
|
+
export declare const getAppDomain: (domainParams: {
|
4
|
+
environment: string;
|
5
|
+
appVersion: string;
|
6
|
+
componentSign: componentSignEnum;
|
7
|
+
productScene: string;
|
8
|
+
productSceneVersion: string;
|
9
|
+
extendInfo: string;
|
10
|
+
mid: string;
|
11
|
+
}) => string;
|
12
|
+
export declare const getIframeUrl: (iframeParams: {
|
13
|
+
componentSign: componentSignEnum;
|
14
|
+
analytics?: Ianalytics;
|
15
|
+
productScene: string;
|
16
|
+
productSceneVersion: string;
|
17
|
+
environment: string;
|
18
|
+
appVersion: string;
|
19
|
+
extendInfo?: string;
|
20
|
+
locale?: string;
|
21
|
+
instanceId: string;
|
22
|
+
renderDisplayType: renderDisplayTypeEnum;
|
23
|
+
isPreload?: string;
|
24
|
+
hostSign?: string;
|
25
|
+
mid?: string;
|
26
|
+
}) => {
|
27
|
+
path: string;
|
28
|
+
locationSearch: string;
|
29
|
+
};
|
30
|
+
/**
|
31
|
+
* @description Create iframe
|
32
|
+
*/
|
33
|
+
export declare const createIframe: (mode: string, platform: 'mobile' | 'desktop') => HTMLIFrameElement;
|
34
|
+
export declare const createPreloadIframe: (channelType: any, version: any) => HTMLIFrameElement;
|
@@ -0,0 +1,237 @@
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
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 _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; }
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
10
|
+
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); }
|
11
|
+
/**
|
12
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
13
|
+
*
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
15
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
16
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
17
|
+
*/
|
18
|
+
import { elementAppMarmotMap, marmotMap, sdkVersion } from "../../config/index";
|
19
|
+
import { componentSignEnum, ComponentSignEnumV2 } from "../../types";
|
20
|
+
import { isDebugLog } from "../../util/debug";
|
21
|
+
import { queryParse, serialize } from "../../util/index";
|
22
|
+
import { Logger } from "../../util/logger";
|
23
|
+
import { getLastAppVersion, getMatchAppVersion, setLastAppVersion } from "../../util/upgrade";
|
24
|
+
var getAppVersion = function getAppVersion(_extendInfo, productScene, mid) {
|
25
|
+
var sendLog = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
26
|
+
try {
|
27
|
+
var appVersion = getMatchAppVersion(_extendInfo, {
|
28
|
+
sdkVersion: sdkVersion,
|
29
|
+
productScene: productScene,
|
30
|
+
mid: mid
|
31
|
+
});
|
32
|
+
if (sendLog) {
|
33
|
+
var _Logger$getInstance;
|
34
|
+
(_Logger$getInstance = Logger.getInstance()) === null || _Logger$getInstance === void 0 || _Logger$getInstance.logInfo({
|
35
|
+
title: 'sdk_event_appUpgradeInfo'
|
36
|
+
}, {
|
37
|
+
appUpgradeVersion: appVersion,
|
38
|
+
appUpgraded: appVersion ? true : false,
|
39
|
+
isPreload: _extendInfo ? false : true,
|
40
|
+
extendInfo: _extendInfo,
|
41
|
+
productScene: productScene,
|
42
|
+
mid: mid
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
// 没有匹配到版本,查询上次的加载版本
|
47
|
+
if (!appVersion) {
|
48
|
+
appVersion = getLastAppVersion(sdkVersion + productScene);
|
49
|
+
return appVersion;
|
50
|
+
}
|
51
|
+
// 不为空时代表是有sessionData,因此要保存当前版本
|
52
|
+
if (_extendInfo) {
|
53
|
+
setLastAppVersion(sdkVersion + productScene, appVersion);
|
54
|
+
}
|
55
|
+
return appVersion;
|
56
|
+
} catch (error) {
|
57
|
+
return '';
|
58
|
+
}
|
59
|
+
};
|
60
|
+
var getFinalProductSceneVersion = function getFinalProductSceneVersion(componentSign, productSceneVersion) {
|
61
|
+
var _signSupportMap;
|
62
|
+
var signSupportMap = (_signSupportMap = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_signSupportMap, componentSignEnum.NONE, ['']), componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), componentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), componentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), componentSignEnum.EASY_PAY_APM, ['2.0']), componentSignEnum.VAULTING_CARD, ['1.0']), componentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_defineProperty(_signSupportMap, componentSignEnum.ELEMENT_ADDRESS, ['1.0']), componentSignEnum.CHECKOUT_PAYMENT, ['1.0.0']));
|
63
|
+
var supportProductSceneVersion = signSupportMap[componentSign];
|
64
|
+
// 从左到右,从旧到新
|
65
|
+
var isSupport = supportProductSceneVersion.find(function (it) {
|
66
|
+
return it === productSceneVersion;
|
67
|
+
});
|
68
|
+
var finalProductSceneVersion = supportProductSceneVersion[supportProductSceneVersion.length - 1];
|
69
|
+
return isSupport ? productSceneVersion : finalProductSceneVersion;
|
70
|
+
};
|
71
|
+
export var getAppPath = function getAppPath() {
|
72
|
+
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
73
|
+
var appVersion = arguments.length > 1 ? arguments[1] : undefined;
|
74
|
+
var componentSign = arguments.length > 2 ? arguments[2] : undefined;
|
75
|
+
var productScene = arguments.length > 3 ? arguments[3] : undefined;
|
76
|
+
var productSceneVersion = arguments.length > 4 ? arguments[4] : undefined;
|
77
|
+
var extendInfo = arguments.length > 5 ? arguments[5] : undefined;
|
78
|
+
var mid = arguments.length > 6 ? arguments[6] : undefined;
|
79
|
+
var sendLog = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
80
|
+
var _ref = queryParse() || {},
|
81
|
+
urlTestHost = _ref.host;
|
82
|
+
var upgradeAppVersion = getAppVersion(extendInfo, productScene, mid, sendLog);
|
83
|
+
var finalAppVersion = upgradeAppVersion || appVersion;
|
84
|
+
// 当有升级版本时,更新到全局字段
|
85
|
+
if (upgradeAppVersion) {
|
86
|
+
var _Logger$getInstance2;
|
87
|
+
(_Logger$getInstance2 = Logger.getInstance()) === null || _Logger$getInstance2 === void 0 || _Logger$getInstance2.setMedta({
|
88
|
+
webAppVersion: finalAppVersion
|
89
|
+
});
|
90
|
+
}
|
91
|
+
if (isDebugLog()) {
|
92
|
+
console.log('appUpgrade#getAppPath#finalAppVersion', finalAppVersion);
|
93
|
+
console.log('appUpgrade#getAppPath#extendInfo', extendInfo, mid);
|
94
|
+
}
|
95
|
+
var finalProductSceneVersion = getFinalProductSceneVersion(componentSign, productSceneVersion);
|
96
|
+
// only for test while testurl?host=https://xxxxx.test.html
|
97
|
+
if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
|
98
|
+
return urlTestHost;
|
99
|
+
}
|
100
|
+
// 地址应用特殊处理
|
101
|
+
if (componentSign === componentSignEnum.ELEMENT_ADDRESS) {
|
102
|
+
return "".concat(elementAppMarmotMap[environment], "/element-address/").concat(finalAppVersion, "/pages/address/index.html");
|
103
|
+
}
|
104
|
+
// element应用特殊处理
|
105
|
+
if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign)) {
|
106
|
+
// element又分为express_checkout模式和普通模式, express_checkout 模式在扩展参数是返回expressCheckout=true
|
107
|
+
var isExpressCheckout = false;
|
108
|
+
try {
|
109
|
+
// expressCheckout可能出现string(false) JSON.parse再转一次
|
110
|
+
isExpressCheckout = JSON.parse(JSON.parse(extendInfo).expressCheckout);
|
111
|
+
} catch (error) {
|
112
|
+
// 遇到JSON解析错误,默认false
|
113
|
+
}
|
114
|
+
if (isExpressCheckout) {
|
115
|
+
// express_checkout模式走单独映射
|
116
|
+
return "".concat(elementAppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/express_checkout/index.html");
|
117
|
+
} else {
|
118
|
+
return "".concat(elementAppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/").concat(productScene.toLowerCase(), "/index.html");
|
119
|
+
}
|
120
|
+
}
|
121
|
+
return "".concat(marmotMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
122
|
+
};
|
123
|
+
export var getAppDomain = function getAppDomain(domainParams) {
|
124
|
+
var environment = domainParams.environment,
|
125
|
+
appVersion = domainParams.appVersion,
|
126
|
+
componentSign = domainParams.componentSign,
|
127
|
+
productScene = domainParams.productScene,
|
128
|
+
productSceneVersion = domainParams.productSceneVersion,
|
129
|
+
extendInfo = domainParams.extendInfo,
|
130
|
+
mid = domainParams.mid;
|
131
|
+
var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
|
132
|
+
var macth = reg.exec(getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo, mid));
|
133
|
+
return macth && macth[0] || '';
|
134
|
+
};
|
135
|
+
export var getIframeUrl = function getIframeUrl(iframeParams) {
|
136
|
+
var componentSign = iframeParams.componentSign,
|
137
|
+
_iframeParams$analyti = iframeParams.analytics,
|
138
|
+
analytics = _iframeParams$analyti === void 0 ? {
|
139
|
+
enabled: true
|
140
|
+
} : _iframeParams$analyti,
|
141
|
+
productScene = iframeParams.productScene,
|
142
|
+
productSceneVersion = iframeParams.productSceneVersion,
|
143
|
+
environment = iframeParams.environment,
|
144
|
+
appVersion = iframeParams.appVersion,
|
145
|
+
extendInfo = iframeParams.extendInfo,
|
146
|
+
locale = iframeParams.locale,
|
147
|
+
instanceId = iframeParams.instanceId,
|
148
|
+
renderDisplayType = iframeParams.renderDisplayType,
|
149
|
+
_iframeParams$isPrelo = iframeParams.isPreload,
|
150
|
+
isPreload = _iframeParams$isPrelo === void 0 ? '' : _iframeParams$isPrelo,
|
151
|
+
_iframeParams$hostSig = iframeParams.hostSign,
|
152
|
+
hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig,
|
153
|
+
_iframeParams$mid = iframeParams.mid,
|
154
|
+
mid = _iframeParams$mid === void 0 ? '' : _iframeParams$mid;
|
155
|
+
var path = getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo || '', mid, true);
|
156
|
+
var appMatched = getMatchAppVersion(extendInfo, {
|
157
|
+
sdkVersion: sdkVersion,
|
158
|
+
productScene: productScene,
|
159
|
+
mid: mid
|
160
|
+
}) ? 'true' : 'false';
|
161
|
+
var _queryParse = queryParse(),
|
162
|
+
_sandbox = _queryParse._sandbox,
|
163
|
+
_light_sandbox = _queryParse._light_sandbox,
|
164
|
+
_queryParse$requestHo = _queryParse.requestHost,
|
165
|
+
requestHost = _queryParse$requestHo === void 0 ? '' : _queryParse$requestHo,
|
166
|
+
_queryParse$groupId = _queryParse.groupId,
|
167
|
+
groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
|
168
|
+
LOCAL_MOCK = _queryParse.LOCAL_MOCK,
|
169
|
+
_displayType = _queryParse._displayType;
|
170
|
+
var urlParams = Object.assign({}, {
|
171
|
+
displayType: renderDisplayType,
|
172
|
+
locale: locale,
|
173
|
+
instanceId: instanceId,
|
174
|
+
appMatched: appMatched,
|
175
|
+
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
176
|
+
sdkVersion: sdkVersion,
|
177
|
+
refUrl: window.location.href,
|
178
|
+
_componentStartTime: "".concat(Date.now()),
|
179
|
+
isPreload: isPreload || '',
|
180
|
+
hostSign: hostSign || ''
|
181
|
+
});
|
182
|
+
if (LOCAL_MOCK) urlParams.LOCAL_MOCK = LOCAL_MOCK;
|
183
|
+
if (requestHost) urlParams.requestHost = requestHost;
|
184
|
+
if (groupId) urlParams.groupId = groupId;
|
185
|
+
if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
|
186
|
+
if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
|
187
|
+
if (_displayType) urlParams.displayType = _displayType;
|
188
|
+
var locationSearch = serialize(urlParams);
|
189
|
+
if (isDebugLog()) {
|
190
|
+
console.log('appUpgrade#getIframeUrl#appMatched', appMatched);
|
191
|
+
console.log('appUpgrade#getIframeUrl#url', path, locationSearch);
|
192
|
+
}
|
193
|
+
return {
|
194
|
+
path: path,
|
195
|
+
locationSearch: locationSearch
|
196
|
+
};
|
197
|
+
};
|
198
|
+
|
199
|
+
/**
|
200
|
+
* @description Create iframe
|
201
|
+
*/
|
202
|
+
export var createIframe = function createIframe(mode, platform) {
|
203
|
+
var getIframeId = function getIframeId() {
|
204
|
+
var IdMap = {
|
205
|
+
dropin: "ams-checkout-dropin-".concat(platform),
|
206
|
+
component: "ams-checkout-component-".concat(platform)
|
207
|
+
};
|
208
|
+
return IdMap[mode] || 'ams-checkout-component';
|
209
|
+
};
|
210
|
+
var iframe = document.createElement('iframe');
|
211
|
+
var iframeId = getIframeId();
|
212
|
+
var none = '0';
|
213
|
+
var width = '100%';
|
214
|
+
iframe.id = iframeId;
|
215
|
+
iframe.style.height = none;
|
216
|
+
iframe.style.width = width;
|
217
|
+
iframe.style.border = none;
|
218
|
+
iframe.style.opacity = none;
|
219
|
+
iframe.style.overflow = 'hidden';
|
220
|
+
// iframe设置支持第三方支付
|
221
|
+
iframe.allow = 'payment';
|
222
|
+
return iframe;
|
223
|
+
};
|
224
|
+
export var createPreloadIframe = function createPreloadIframe(channelType, version) {
|
225
|
+
var id = "ams-checkout-component-".concat(channelType, "-").concat(version);
|
226
|
+
var iframe = document.createElement('iframe');
|
227
|
+
var iframeId = id;
|
228
|
+
var none = '1px';
|
229
|
+
var width = '1px';
|
230
|
+
iframe.id = iframeId;
|
231
|
+
iframe.style.height = none;
|
232
|
+
iframe.style.width = width;
|
233
|
+
iframe.style.border = none;
|
234
|
+
iframe.style.opacity = '0';
|
235
|
+
iframe.style.overflow = 'hidden';
|
236
|
+
return iframe;
|
237
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { eventPayload, IpaymentSessionMetaData } from 'src/types';
|
2
|
+
type IChannelBehavior = {
|
3
3
|
usePaymentSessionAsQueryResult: boolean;
|
4
4
|
submitPayInSdk: boolean;
|
5
5
|
createIframeNode: boolean;
|
@@ -15,6 +15,7 @@ type GetDoubleFaParams = {
|
|
15
15
|
env: string;
|
16
16
|
sdkVersion: string;
|
17
17
|
};
|
18
|
-
export declare function getChannelBehavior(paymentSessionMetaData?:
|
18
|
+
export declare function getChannelBehavior(paymentSessionMetaData?: IpaymentSessionMetaData): IChannelBehavior | undefined;
|
19
19
|
export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
|
20
|
+
export declare const handleGooglePay: (data: eventPayload) => Promise<unknown>;
|
20
21
|
export {};
|
@@ -50,4 +50,40 @@ export function getDoubleFaUrl(params) {
|
|
50
50
|
};
|
51
51
|
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
52
52
|
return "".concat(doubleFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(paymentSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
53
|
-
}
|
53
|
+
}
|
54
|
+
export var handleGooglePay = function handleGooglePay(data) {
|
55
|
+
return new Promise(function (resolve, reject) {
|
56
|
+
var _data$context;
|
57
|
+
var _data$context$data$da = data === null || data === void 0 || (_data$context = data.context) === null || _data$context === void 0 || (_data$context = _data$context.data) === null || _data$context === void 0 || (_data$context = _data$context.data) === null || _data$context === void 0 || (_data$context = _data$context.paymentMethodDetail) === null || _data$context === void 0 ? void 0 : _data$context.googlePayProps,
|
58
|
+
_data$context$data$da2 = _data$context$data$da.environment,
|
59
|
+
environment = _data$context$data$da2 === void 0 ? 'TEST' : _data$context$data$da2,
|
60
|
+
_data$context$data$da3 = _data$context$data$da.paymentRequest,
|
61
|
+
paymentRequest = _data$context$data$da3 === void 0 ? {} : _data$context$data$da3;
|
62
|
+
var script = document.createElement('script');
|
63
|
+
script.src = 'https://pay.google.com/gp/p/js/pay.js';
|
64
|
+
script.async = true;
|
65
|
+
document.body.appendChild(script);
|
66
|
+
// 执行googlePay sdk
|
67
|
+
script.onload = function () {
|
68
|
+
var paymentsClient = new window.google.payments.api.PaymentsClient({
|
69
|
+
environment: environment,
|
70
|
+
// 按钮为付款时需要传递的参数
|
71
|
+
paymentDataCallbacks: {
|
72
|
+
onPaymentAuthorized: function onPaymentAuthorized(paymentData) {
|
73
|
+
return {
|
74
|
+
transactionState: 'SUCCESS'
|
75
|
+
};
|
76
|
+
}
|
77
|
+
}
|
78
|
+
});
|
79
|
+
// 获取到googlePay token后返回消息给app
|
80
|
+
paymentsClient.loadPaymentData(paymentRequest).then(function (paymentData) {
|
81
|
+
if (paymentData) {
|
82
|
+
resolve(paymentData);
|
83
|
+
}
|
84
|
+
}).catch(function (err) {
|
85
|
+
reject(err);
|
86
|
+
});
|
87
|
+
};
|
88
|
+
});
|
89
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { componentSignEnum, platformEnum } from '../../types';
|
2
|
+
interface Options {
|
3
|
+
componentSign?: componentSignEnum;
|
4
|
+
type: 'tabs' | 'Accordion';
|
5
|
+
isExpressCheckout?: boolean;
|
6
|
+
}
|
7
|
+
export declare const inlineComponentAddCss: () => void;
|
8
|
+
export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum, options: Options) => void;
|
9
|
+
export declare const createInlineBaseElement: (selector: string) => HTMLDivElement;
|
10
|
+
export {};
|