@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730107332-dev.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.d.ts +2 -3
- package/esm/component/channel.js +55 -29
- package/esm/component/component.inline.style.js +1 -1
- package/esm/component/component.popup.style.d.ts +1 -3
- package/esm/component/component.popup.style.js +1 -3
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +10 -10
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/core/bus/ability/callback.js +55 -0
- package/esm/core/bus/ability/security.d.ts +10 -0
- package/esm/core/bus/ability/security.js +104 -0
- package/esm/core/bus/ability/tracker.d.ts +9 -0
- package/esm/core/bus/ability/tracker.js +77 -0
- package/esm/core/bus/index.d.ts +125 -0
- package/esm/core/bus/index.js +366 -0
- package/esm/core/bus/interface.d.ts +36 -0
- package/esm/core/bus/interface.js +40 -0
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/core/component/appPreloadProcessing.js +89 -0
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +167 -0
- package/esm/core/component/element/components/address.d.ts +19 -0
- package/esm/core/component/element/components/address.js +68 -0
- package/esm/core/component/element/components/auth.d.ts +17 -0
- package/esm/core/component/element/components/auth.js +60 -0
- package/esm/core/component/element/components/payment.d.ts +19 -0
- package/esm/core/component/element/components/payment.js +74 -0
- package/esm/core/component/element/index.d.ts +47 -0
- package/esm/core/component/element/index.js +816 -0
- package/esm/core/component/element/mock.d.ts +4 -0
- package/esm/core/component/element/mock.js +491 -0
- package/esm/core/component/element/type.d.ts +190 -0
- package/esm/core/component/element/type.js +35 -0
- package/esm/core/component/element/utils.d.ts +13 -0
- package/esm/core/component/element/utils.js +6 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +531 -0
- package/esm/core/drop-in/index.d.ts +22 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +89 -0
- package/esm/core/instance/index.js +499 -0
- package/esm/foundation/core/index.d.ts +3 -3
- package/esm/foundation/core/index.js +10 -8
- package/esm/foundation/index.d.ts +6 -5
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +6 -6
- package/esm/foundation/product-processor/easysafepay/deps.js +4 -4
- package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -3
- package/esm/foundation/product-processor/easysafepay/index.js +110 -243
- package/esm/foundation/service/api-bus/index.d.ts +2 -2
- package/esm/foundation/service/container/index.d.ts +4 -2
- package/esm/foundation/service/container/index.js +43 -1
- package/esm/foundation/service/event-center.d.ts +6 -4
- package/esm/foundation/service/event-center.js +47 -17
- package/esm/foundation/service/global-data/index.d.ts +2 -2
- package/esm/foundation/service/index.d.ts +2 -2
- package/esm/foundation/service/log/index.d.ts +2 -2
- package/esm/foundation/service/log/index.js +1 -1
- package/esm/foundation/service/requester/deps.d.ts +1 -1
- package/esm/foundation/service/requester/requester.d.ts +2 -2
- package/esm/foundation/service/security/index.d.ts +2 -2
- package/esm/foundation/service/security/index.js +5 -20
- package/esm/foundation/utils/redirect_utils.d.ts +5 -0
- package/esm/foundation/utils/redirect_utils.js +205 -58
- package/esm/foundation/utils/system_events.js +0 -5
- package/esm/foundation/utils/web_app_url_utils.js +1 -1
- package/esm/index.d.ts +31 -2
- package/esm/index.js +146 -6
- package/esm/plugin/applepay/component.d.ts +50 -0
- package/esm/plugin/applepay/component.js +339 -0
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/plugin/applepay/interface.d.ts +161 -0
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/plugin/applepay/service.d.ts +54 -0
- package/esm/plugin/applepay/service.js +289 -0
- package/esm/plugin/component/cashierApp.d.ts +36 -0
- package/esm/plugin/component/cashierApp.js +244 -0
- package/esm/plugin/component/channel.d.ts +21 -0
- package/esm/plugin/component/channel.js +89 -0
- package/esm/plugin/component/component.inline.style.d.ts +10 -0
- package/esm/plugin/component/component.inline.style.js +121 -0
- package/esm/plugin/component/component.popup.style.d.ts +16 -0
- package/esm/plugin/component/component.popup.style.js +174 -0
- package/esm/plugin/component/index.d.ts +127 -0
- package/esm/plugin/component/index.js +1896 -0
- package/esm/plugin/component/popupWindow.style.d.ts +11 -0
- package/esm/plugin/component/popupWindow.style.js +121 -0
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/drop-in/index.d.ts +71 -0
- package/esm/plugin/drop-in/index.js +324 -0
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +6 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +390 -0
- package/esm/plugin/type.d.ts +34 -0
- package/esm/plugin/type.js +1 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/service/element.d.ts +4 -0
- package/esm/service/element.js +51 -0
- package/esm/service/index.d.ts +1 -0
- package/esm/service/index.js +2 -0
- package/esm/types/index.d.ts +228 -26
- package/esm/types/index.js +54 -5
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +2 -2
- package/esm/util/getBackScheme.js +2 -2
- package/esm/util/index.d.ts +11 -1
- package/esm/util/index.js +84 -3
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/util/security.d.ts +33 -0
- package/esm/util/security.js +182 -0
- package/package.json +2 -1
- package/esm/foundation/types/index.d.ts +0 -4
- package/esm/foundation/types/index.js +0 -4
@@ -0,0 +1,89 @@
|
|
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
|
+
import { loadSDKScript } from "../../util";
|
6
|
+
export function loadChannelPneumaticControl(_x, _x2) {
|
7
|
+
return _loadChannelPneumaticControl.apply(this, arguments);
|
8
|
+
}
|
9
|
+
function _loadChannelPneumaticControl() {
|
10
|
+
_loadChannelPneumaticControl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(paymentSessionFactor, logger) {
|
11
|
+
var _ref, _ref$frontModulesToBe, frontModulesToBeLoaded, paymentRequestId;
|
12
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
13
|
+
while (1) switch (_context2.prev = _context2.next) {
|
14
|
+
case 0:
|
15
|
+
_ref = paymentSessionFactor || {}, _ref$frontModulesToBe = _ref.frontModulesToBeLoaded, frontModulesToBeLoaded = _ref$frontModulesToBe === void 0 ? [] : _ref$frontModulesToBe, paymentRequestId = _ref.paymentRequestId;
|
16
|
+
if (Array.isArray(frontModulesToBeLoaded)) {
|
17
|
+
_context2.next = 3;
|
18
|
+
break;
|
19
|
+
}
|
20
|
+
return _context2.abrupt("return");
|
21
|
+
case 3:
|
22
|
+
if (!(frontModulesToBeLoaded.length === 0)) {
|
23
|
+
_context2.next = 5;
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
return _context2.abrupt("return");
|
27
|
+
case 5:
|
28
|
+
return _context2.abrupt("return", new Promise( /*#__PURE__*/function () {
|
29
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
|
30
|
+
var NONE_LOAD_SDK_CHANNEL_LIST, promiseList;
|
31
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
32
|
+
while (1) switch (_context.prev = _context.next) {
|
33
|
+
case 0:
|
34
|
+
NONE_LOAD_SDK_CHANNEL_LIST = /*#__PURE__*/function (NONE_LOAD_SDK_CHANNEL_LIST) {
|
35
|
+
NONE_LOAD_SDK_CHANNEL_LIST["AIRWALLEX"] = "AIRWALLEX";
|
36
|
+
return NONE_LOAD_SDK_CHANNEL_LIST;
|
37
|
+
}({});
|
38
|
+
promiseList = [];
|
39
|
+
logger.logInfo({
|
40
|
+
title: 'load_channel_sdk_start'
|
41
|
+
}, {
|
42
|
+
frontModulesToBeLoaded: JSON.stringify(frontModulesToBeLoaded),
|
43
|
+
paymentRequestId: paymentRequestId
|
44
|
+
});
|
45
|
+
frontModulesToBeLoaded.forEach(function (loadItem) {
|
46
|
+
var acquirerName = loadItem.acquirerName,
|
47
|
+
scriptUrl = loadItem.scriptUrl;
|
48
|
+
var promiseItem = null;
|
49
|
+
if (acquirerName === NONE_LOAD_SDK_CHANNEL_LIST.AIRWALLEX) {
|
50
|
+
var attrOptions = {
|
51
|
+
defer: true,
|
52
|
+
id: 'airwallex-fraud-api',
|
53
|
+
'data-order-session-id': paymentRequestId
|
54
|
+
};
|
55
|
+
promiseItem = loadSDKScript({
|
56
|
+
src: scriptUrl,
|
57
|
+
attrOptions: attrOptions,
|
58
|
+
timeOut: 3
|
59
|
+
}, logger);
|
60
|
+
} else {
|
61
|
+
promiseItem = loadSDKScript({
|
62
|
+
src: scriptUrl,
|
63
|
+
timeOut: 3
|
64
|
+
}, logger);
|
65
|
+
}
|
66
|
+
promiseList.push(promiseItem);
|
67
|
+
});
|
68
|
+
_context.next = 6;
|
69
|
+
return Promise.all(promiseList);
|
70
|
+
case 6:
|
71
|
+
resolve(true);
|
72
|
+
case 7:
|
73
|
+
case "end":
|
74
|
+
return _context.stop();
|
75
|
+
}
|
76
|
+
}, _callee);
|
77
|
+
}));
|
78
|
+
return function (_x3) {
|
79
|
+
return _ref2.apply(this, arguments);
|
80
|
+
};
|
81
|
+
}()));
|
82
|
+
case 6:
|
83
|
+
case "end":
|
84
|
+
return _context2.stop();
|
85
|
+
}
|
86
|
+
}, _callee2);
|
87
|
+
}));
|
88
|
+
return _loadChannelPneumaticControl.apply(this, arguments);
|
89
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { IcreateComponent, IoptionsParams } from '../../../types';
|
2
|
+
import { Logger } from '../../../util/logger';
|
3
|
+
type LOCAL_URL = string;
|
4
|
+
export type CKPEmbeddedAppEnv = 'dev' | 'sit' | 'pre' | 'prod';
|
5
|
+
export type CKPEmbeddedEventType = 'SDK_PAYMENT_SUCCESSFUL' | 'SDK_PAYMENT_FAIL' | 'SDK_PAYMENT_CANCEL' | 'SDK_PAYMENT_CLICK_BACK_TO_MERCHANT';
|
6
|
+
export declare const getCKPPageAddress: (env: IoptionsParams['environment'] | LOCAL_URL) => string;
|
7
|
+
export declare class AMSCheckoutPage {
|
8
|
+
logger: Logger;
|
9
|
+
private _instanceId;
|
10
|
+
private originOptions;
|
11
|
+
private readonly APP_IFRAME_ID;
|
12
|
+
private eventListener?;
|
13
|
+
constructor(options: Pick<IoptionsParams, 'environment' | 'locale' | 'onEventCallback'>);
|
14
|
+
private generateIframeSrc;
|
15
|
+
private eventListenerWrapper;
|
16
|
+
private addListener;
|
17
|
+
private removeListener;
|
18
|
+
/**
|
19
|
+
* 挂载组件
|
20
|
+
*/
|
21
|
+
mountComponent(params: Pick<IcreateComponent, 'sessionData'>, selector: string): Promise<void>;
|
22
|
+
/**
|
23
|
+
* 卸载组件
|
24
|
+
*/
|
25
|
+
unmount(): void;
|
26
|
+
}
|
27
|
+
export {};
|
@@ -0,0 +1,167 @@
|
|
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 _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; }
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
|
+
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); }
|
8
|
+
import { v4 as uuid } from 'uuid';
|
9
|
+
import { EnvironmentEnum } from "../../../types";
|
10
|
+
import { queryParse } from "../../../util";
|
11
|
+
import { LogConfig, Logger } from "../../../util/logger";
|
12
|
+
var CKP_PAYMENT_PAGE_HOST = {
|
13
|
+
DEV: 'https://dev.page.alipay.net',
|
14
|
+
TEST: 'https://test.page.alipay.net',
|
15
|
+
PRE: 'https://pre.ac.alipay.com',
|
16
|
+
PROD: 'https://checkout.antom.com'
|
17
|
+
};
|
18
|
+
|
19
|
+
// for local development
|
20
|
+
|
21
|
+
var CKP_PAGE_ADDRESS = '/page/antom-web-checkout-v2/checkout-page/pages/payment/index.html';
|
22
|
+
var CKP_PAGE_NEW_ADDRESS = '/checkout-page/pages/payment/index.html';
|
23
|
+
export var getCKPPageAddress = function getCKPPageAddress(env) {
|
24
|
+
switch (env) {
|
25
|
+
case 'dev':
|
26
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.DEV).concat(CKP_PAGE_ADDRESS);
|
27
|
+
case 'sit':
|
28
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.TEST).concat(CKP_PAGE_ADDRESS);
|
29
|
+
case 'pre':
|
30
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.PRE).concat(CKP_PAGE_ADDRESS);
|
31
|
+
case 'prod':
|
32
|
+
case 'sandbox':
|
33
|
+
case 'light_sandbox':
|
34
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.PROD).concat(CKP_PAGE_NEW_ADDRESS);
|
35
|
+
default:
|
36
|
+
// for local development, e.g. http://localhost:5173/checkout-page/src/pages/payment/index.html
|
37
|
+
return env;
|
38
|
+
}
|
39
|
+
};
|
40
|
+
export var AMSCheckoutPage = /*#__PURE__*/function () {
|
41
|
+
function AMSCheckoutPage(options) {
|
42
|
+
var _this = this;
|
43
|
+
_classCallCheck(this, AMSCheckoutPage);
|
44
|
+
_defineProperty(this, "logger", void 0);
|
45
|
+
_defineProperty(this, "_instanceId", void 0);
|
46
|
+
_defineProperty(this, "originOptions", void 0);
|
47
|
+
_defineProperty(this, "APP_IFRAME_ID", 'antom-checkout-page-sub-page-iframe');
|
48
|
+
_defineProperty(this, "eventListener", void 0);
|
49
|
+
_defineProperty(this, "generateIframeSrc", function (sessionData) {
|
50
|
+
var env = _this.originOptions.environment || 'prod';
|
51
|
+
var session = sessionData || '';
|
52
|
+
var lang = _this.originOptions.locale || 'en_US';
|
53
|
+
var ckpPageAddress = getCKPPageAddress(env);
|
54
|
+
console.log('[antom-web-sdk] <antom-checkout-page> generateIframeSrc', _this.originOptions, env, session, lang, ckpPageAddress);
|
55
|
+
|
56
|
+
// 先获取去除的 query 参数的 url
|
57
|
+
var url = ckpPageAddress.split('?')[0];
|
58
|
+
var queryObj = queryParse(ckpPageAddress);
|
59
|
+
queryObj.sessionData = session;
|
60
|
+
queryObj.lang = lang;
|
61
|
+
queryObj.mode = 'embed';
|
62
|
+
if (env === 'sandbox') {
|
63
|
+
queryObj.shadow = 'true';
|
64
|
+
}
|
65
|
+
Object.keys(queryObj).forEach(function (key) {
|
66
|
+
url += "".concat(url.includes('?') ? '&' : '?').concat(key, "=").concat(encodeURIComponent(queryObj[key]));
|
67
|
+
});
|
68
|
+
return url;
|
69
|
+
});
|
70
|
+
_defineProperty(this, "eventListenerWrapper", function (event) {
|
71
|
+
var _ref = JSON.parse(event.data) || {},
|
72
|
+
code = _ref.code,
|
73
|
+
message = _ref.message,
|
74
|
+
result = _ref.result;
|
75
|
+
if (code && code.startsWith('SDK_PAYMENT')) {
|
76
|
+
var _this$eventListener;
|
77
|
+
console.log('[antom-web-sdk] <antom-checkout-page> eventListenerWrapper', event, message, result);
|
78
|
+
(_this$eventListener = _this.eventListener) === null || _this$eventListener === void 0 || _this$eventListener.call(_this, {
|
79
|
+
code: code,
|
80
|
+
message: message,
|
81
|
+
result: result
|
82
|
+
});
|
83
|
+
}
|
84
|
+
});
|
85
|
+
_defineProperty(this, "addListener", function () {
|
86
|
+
window.addEventListener('message', _this.eventListenerWrapper);
|
87
|
+
});
|
88
|
+
_defineProperty(this, "removeListener", function () {
|
89
|
+
window.removeEventListener('message', _this.eventListenerWrapper);
|
90
|
+
});
|
91
|
+
options.environment = options.environment || EnvironmentEnum.prod;
|
92
|
+
this._instanceId = uuid();
|
93
|
+
this.originOptions = options;
|
94
|
+
this.eventListener = options.onEventCallback;
|
95
|
+
this.logger = new Logger(LogConfig, ![EnvironmentEnum.prod, EnvironmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
|
96
|
+
Logger.setInstance(this.logger);
|
97
|
+
this.logger.setMedta({
|
98
|
+
instanceId: this._instanceId
|
99
|
+
});
|
100
|
+
this.logger.initTracker();
|
101
|
+
this.logger.setComponentStartTime(Date.now());
|
102
|
+
this.logger.setTrackId(this._instanceId);
|
103
|
+
this.logger.logInfo({
|
104
|
+
title: 'NEW_AMSSDK_BY_MECHANT',
|
105
|
+
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
|
106
|
+
}).send();
|
107
|
+
}
|
108
|
+
_createClass(AMSCheckoutPage, [{
|
109
|
+
key: "mountComponent",
|
110
|
+
value:
|
111
|
+
/**
|
112
|
+
* 挂载组件
|
113
|
+
*/
|
114
|
+
function mountComponent(params, selector) {
|
115
|
+
if (params.sessionData === undefined || params.sessionData === '' || typeof params.sessionData !== 'string') {
|
116
|
+
this.logger.logError({
|
117
|
+
title: 'PARAMS_ERROR_INVALID_SESSION_DATA'
|
118
|
+
});
|
119
|
+
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: sessionData is required and must be a string');
|
120
|
+
throw new Error('PARAMS_ERROR_INVALID_SESSION_DATA');
|
121
|
+
}
|
122
|
+
if (document.querySelector(this.APP_IFRAME_ID)) {
|
123
|
+
this.logger.logError({
|
124
|
+
title: 'PARAMS_ERROR_ALREADY_MOUNTED'
|
125
|
+
});
|
126
|
+
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: already mounted, please unmount first');
|
127
|
+
throw new Error('PARAMS_ERROR_ALREADY_MOUNTED');
|
128
|
+
}
|
129
|
+
this.addListener();
|
130
|
+
var ckpPageAddress = this.generateIframeSrc(params.sessionData);
|
131
|
+
var iframe = document.createElement('iframe');
|
132
|
+
iframe.id = this.APP_IFRAME_ID;
|
133
|
+
iframe.src = ckpPageAddress;
|
134
|
+
iframe.width = '100%';
|
135
|
+
iframe.height = '100%';
|
136
|
+
iframe.style.border = 'none';
|
137
|
+
var wrapper = document.querySelector(selector);
|
138
|
+
if (wrapper) {
|
139
|
+
wrapper.innerHTML = '';
|
140
|
+
wrapper.appendChild(iframe);
|
141
|
+
} else {
|
142
|
+
this.logger.logError({
|
143
|
+
title: 'PARAMS_ERROR_INVALID_SELECTOR'
|
144
|
+
});
|
145
|
+
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: invalid selector');
|
146
|
+
this.removeListener();
|
147
|
+
throw new Error('PARAMS_ERROR_INVALID_SELECTOR');
|
148
|
+
}
|
149
|
+
return Promise.resolve();
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* 卸载组件
|
154
|
+
*/
|
155
|
+
}, {
|
156
|
+
key: "unmount",
|
157
|
+
value: function unmount() {
|
158
|
+
this.removeListener();
|
159
|
+
var iframe = document.getElementById(this.APP_IFRAME_ID);
|
160
|
+
if (iframe) {
|
161
|
+
iframe.remove();
|
162
|
+
}
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
}]);
|
166
|
+
return AMSCheckoutPage;
|
167
|
+
}();
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { AddressMountComponentsParams } from '../type';
|
2
|
+
interface ElementAddressMountOptions extends Omit<AddressMountComponentsParams, 'type'> {
|
3
|
+
selector: string;
|
4
|
+
}
|
5
|
+
export declare class ElementAddressComponent {
|
6
|
+
private sdk;
|
7
|
+
private elementContainer;
|
8
|
+
private isConnect;
|
9
|
+
constructor();
|
10
|
+
create(options: {
|
11
|
+
environment: string;
|
12
|
+
locale: string;
|
13
|
+
appVersion: string;
|
14
|
+
}, isConnect: boolean): void;
|
15
|
+
mount(sessionData: string, options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
|
16
|
+
update(): void;
|
17
|
+
unmount(): void;
|
18
|
+
}
|
19
|
+
export {};
|
@@ -0,0 +1,68 @@
|
|
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 _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; }
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
|
+
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); }
|
8
|
+
import { AddressComponent } from "../../address";
|
9
|
+
export var ElementAddressComponent = /*#__PURE__*/function () {
|
10
|
+
function ElementAddressComponent() {
|
11
|
+
_classCallCheck(this, ElementAddressComponent);
|
12
|
+
_defineProperty(this, "sdk", void 0);
|
13
|
+
_defineProperty(this, "elementContainer", void 0);
|
14
|
+
_defineProperty(this, "isConnect", void 0);
|
15
|
+
}
|
16
|
+
_createClass(ElementAddressComponent, [{
|
17
|
+
key: "create",
|
18
|
+
value: function create(options, isConnect) {
|
19
|
+
this.isConnect = isConnect;
|
20
|
+
this.sdk = new AddressComponent(options);
|
21
|
+
}
|
22
|
+
}, {
|
23
|
+
key: "mount",
|
24
|
+
value: function mount(sessionData, options) {
|
25
|
+
var _this = this;
|
26
|
+
var elementContainer = document.querySelector(options.selector);
|
27
|
+
if (this.isConnect) {
|
28
|
+
elementContainer.style.display = 'none';
|
29
|
+
}
|
30
|
+
return new Promise(function (resolve) {
|
31
|
+
_this.sdk.mountComponent({
|
32
|
+
sessionData: sessionData,
|
33
|
+
elementProps: options.elementProps,
|
34
|
+
configParams: options.configParams,
|
35
|
+
appearance: options.appearance,
|
36
|
+
prefillValue: options.prefillValue,
|
37
|
+
appendAliasContainerId: true
|
38
|
+
}, options.selector).then(function () {
|
39
|
+
var _elementContainer$get;
|
40
|
+
_this.elementContainer = elementContainer;
|
41
|
+
var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
|
42
|
+
resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
|
43
|
+
}, function () {
|
44
|
+
resolve(undefined);
|
45
|
+
});
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}, {
|
49
|
+
key: "update",
|
50
|
+
value: function update() {
|
51
|
+
if (this.elementContainer && this.isConnect) {
|
52
|
+
this.elementContainer.style.display = '';
|
53
|
+
}
|
54
|
+
// 下发数据
|
55
|
+
}
|
56
|
+
}, {
|
57
|
+
key: "unmount",
|
58
|
+
value: function unmount() {
|
59
|
+
var _this$elementContaine, _this$elementContaine2;
|
60
|
+
var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
|
61
|
+
if (containers !== null && containers !== void 0 && containers[0]) {
|
62
|
+
var _containers$, _containers$$remove;
|
63
|
+
(_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}]);
|
67
|
+
return ElementAddressComponent;
|
68
|
+
}();
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { LinkAuthMountOptions } from '../type';
|
2
|
+
interface ElementAuthMountOptions extends Omit<LinkAuthMountOptions, 'type' | 'elementProps'> {
|
3
|
+
selector: string;
|
4
|
+
url: string;
|
5
|
+
}
|
6
|
+
export declare class ElementAuthComponent {
|
7
|
+
private elementContainer;
|
8
|
+
constructor();
|
9
|
+
create(options: {
|
10
|
+
environment: string;
|
11
|
+
locale: string;
|
12
|
+
}): void;
|
13
|
+
mount(options: ElementAuthMountOptions): Promise<HTMLIFrameElement | undefined>;
|
14
|
+
update(height?: number): void;
|
15
|
+
unmount(): void;
|
16
|
+
}
|
17
|
+
export {};
|
@@ -0,0 +1,60 @@
|
|
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 _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; }
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
|
+
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); }
|
8
|
+
import { createIframe } from "../../../../foundation/service/container/utils";
|
9
|
+
import { createInlineBaseElement } from "../../../../plugin/component/component.inline.style";
|
10
|
+
export var ElementAuthComponent = /*#__PURE__*/function () {
|
11
|
+
function ElementAuthComponent() {
|
12
|
+
_classCallCheck(this, ElementAuthComponent);
|
13
|
+
_defineProperty(this, "elementContainer", void 0);
|
14
|
+
}
|
15
|
+
_createClass(ElementAuthComponent, [{
|
16
|
+
key: "create",
|
17
|
+
value: function create(options) {}
|
18
|
+
}, {
|
19
|
+
key: "mount",
|
20
|
+
value: function mount(options) {
|
21
|
+
var _this = this;
|
22
|
+
return new Promise(function (resolve) {
|
23
|
+
try {
|
24
|
+
var selector = options.selector,
|
25
|
+
url = options.url;
|
26
|
+
var containerId = (selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1);
|
27
|
+
var containerSelector = "antom-sdk-web-app-".concat(containerId);
|
28
|
+
var container = createInlineBaseElement(selector);
|
29
|
+
var webApp = createIframe(containerSelector);
|
30
|
+
webApp.src = url;
|
31
|
+
container.appendChild(webApp);
|
32
|
+
_this.elementContainer = container;
|
33
|
+
resolve(webApp);
|
34
|
+
} catch (error) {
|
35
|
+
resolve(undefined);
|
36
|
+
}
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}, {
|
40
|
+
key: "update",
|
41
|
+
value: function update() {
|
42
|
+
var _this$elementContaine, _this$elementContaine2;
|
43
|
+
var height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
44
|
+
var iframes = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'iframe');
|
45
|
+
if (iframes !== null && iframes !== void 0 && iframes[0]) {
|
46
|
+
var iframe = iframes[0];
|
47
|
+
iframe.style.opacity = '1';
|
48
|
+
iframe.style.overflow = 'visible';
|
49
|
+
iframe.style.height = "".concat(height, "px");
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}, {
|
53
|
+
key: "unmount",
|
54
|
+
value: function unmount() {
|
55
|
+
var _this$elementContaine3, _this$elementContaine4;
|
56
|
+
(_this$elementContaine3 = this.elementContainer) === null || _this$elementContaine3 === void 0 || (_this$elementContaine4 = _this$elementContaine3.remove) === null || _this$elementContaine4 === void 0 || _this$elementContaine4.call(_this$elementContaine3);
|
57
|
+
}
|
58
|
+
}]);
|
59
|
+
return ElementAuthComponent;
|
60
|
+
}();
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { PaymentMountOptions } from '../type';
|
2
|
+
interface ElementPaymentMountOptions extends Omit<PaymentMountOptions, 'type'> {
|
3
|
+
selector: string;
|
4
|
+
}
|
5
|
+
export declare class ElementPaymentComponent {
|
6
|
+
private sdk;
|
7
|
+
private elementContainer;
|
8
|
+
private isConnect;
|
9
|
+
constructor();
|
10
|
+
create(options: {
|
11
|
+
environment: string;
|
12
|
+
locale: string;
|
13
|
+
appVersion: string;
|
14
|
+
}, isConnect: boolean): void;
|
15
|
+
mount(sessionData: string, options: ElementPaymentMountOptions): Promise<HTMLIFrameElement | undefined>;
|
16
|
+
update(): void;
|
17
|
+
unmount(): void;
|
18
|
+
}
|
19
|
+
export {};
|
@@ -0,0 +1,74 @@
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5
|
+
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); } }
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
7
|
+
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; }
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
9
|
+
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); }
|
10
|
+
import AMSPaymentElement from "../../../../index";
|
11
|
+
export var ElementPaymentComponent = /*#__PURE__*/function () {
|
12
|
+
function ElementPaymentComponent() {
|
13
|
+
_classCallCheck(this, ElementPaymentComponent);
|
14
|
+
_defineProperty(this, "sdk", void 0);
|
15
|
+
_defineProperty(this, "elementContainer", void 0);
|
16
|
+
_defineProperty(this, "isConnect", void 0);
|
17
|
+
}
|
18
|
+
_createClass(ElementPaymentComponent, [{
|
19
|
+
key: "create",
|
20
|
+
value: function create(options, isConnect) {
|
21
|
+
this.isConnect = isConnect;
|
22
|
+
this.sdk = new AMSPaymentElement(_objectSpread(_objectSpread({}, options), {}, {
|
23
|
+
analytics: {
|
24
|
+
enabled: true
|
25
|
+
},
|
26
|
+
onEventCallback: function onEventCallback(state) {}
|
27
|
+
}));
|
28
|
+
}
|
29
|
+
}, {
|
30
|
+
key: "mount",
|
31
|
+
value: function mount(sessionData, options) {
|
32
|
+
var _this = this;
|
33
|
+
var elementContainer = document.querySelector(options.selector);
|
34
|
+
if (this.isConnect) {
|
35
|
+
elementContainer.style.display = 'none';
|
36
|
+
}
|
37
|
+
return new Promise(function (resolve) {
|
38
|
+
_this.sdk.mountComponent({
|
39
|
+
sessionData: sessionData,
|
40
|
+
appearance: options.appearance,
|
41
|
+
elementProps: options.elementProps,
|
42
|
+
notRedirectAfterComplete: true,
|
43
|
+
appendAliasContainerId: true
|
44
|
+
}, options.selector).then(function () {
|
45
|
+
var _elementContainer$get;
|
46
|
+
_this.elementContainer = elementContainer;
|
47
|
+
var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
|
48
|
+
resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
|
49
|
+
}, function () {
|
50
|
+
resolve(undefined);
|
51
|
+
});
|
52
|
+
});
|
53
|
+
}
|
54
|
+
}, {
|
55
|
+
key: "update",
|
56
|
+
value: function update() {
|
57
|
+
if (this.elementContainer && this.isConnect) {
|
58
|
+
this.elementContainer.style.display = 'initial';
|
59
|
+
}
|
60
|
+
// 下发数据
|
61
|
+
}
|
62
|
+
}, {
|
63
|
+
key: "unmount",
|
64
|
+
value: function unmount() {
|
65
|
+
var _this$elementContaine, _this$elementContaine2;
|
66
|
+
var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
|
67
|
+
if (containers !== null && containers !== void 0 && containers[0]) {
|
68
|
+
var _containers$, _containers$$remove;
|
69
|
+
(_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}]);
|
73
|
+
return ElementPaymentComponent;
|
74
|
+
}();
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { IElementOptions } from '../../../types';
|
2
|
+
import type { AddressMountOptions, AddressMountResult, LinkAuthMountOptions, LinkAuthMountResult, PaymentMountOptions, PaymentMountResult } from './type';
|
3
|
+
export declare class ElementComponent {
|
4
|
+
private parseData;
|
5
|
+
private loading;
|
6
|
+
private sessionData;
|
7
|
+
private elementContainer;
|
8
|
+
private authBase;
|
9
|
+
private addressBase;
|
10
|
+
private paymentBase;
|
11
|
+
private _options;
|
12
|
+
private eventService;
|
13
|
+
private requestService;
|
14
|
+
private sdkActionRes;
|
15
|
+
private oneAccountRes;
|
16
|
+
private launchSource;
|
17
|
+
private isConnect;
|
18
|
+
private iframeSrc;
|
19
|
+
private mountOptions;
|
20
|
+
private iframes;
|
21
|
+
private componentsCount;
|
22
|
+
private eventCallback;
|
23
|
+
constructor(options: IElementOptions);
|
24
|
+
private createElement;
|
25
|
+
private createIframeSrc;
|
26
|
+
private addListener;
|
27
|
+
private launchFunc;
|
28
|
+
private showIframe;
|
29
|
+
private afterInit;
|
30
|
+
private sendRenderData;
|
31
|
+
private removeListener;
|
32
|
+
private registerEventListener;
|
33
|
+
private mountAuth;
|
34
|
+
private mountAddress;
|
35
|
+
private mountPayment;
|
36
|
+
mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
37
|
+
mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
|
38
|
+
mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
39
|
+
private removeIframe;
|
40
|
+
unmount(): void;
|
41
|
+
private onAfterSubmitFunc;
|
42
|
+
private onSubmitRiskFunc;
|
43
|
+
private onSubmit;
|
44
|
+
private onValidateFunc;
|
45
|
+
private validatePromiseFuncs;
|
46
|
+
submitPayment(): Promise<void>;
|
47
|
+
}
|