@alipay/ams-checkout 0.0.1744698677-dev.0 → 0.0.1745390310-dev.1
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/component.inline.style.js +1 -1
- package/esm/component/popupWindow.style.js +1 -4
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +0 -9
- package/esm/constant/index.js +0 -9
- package/esm/core/component/ckp/index.d.ts +26 -6
- package/esm/core/component/ckp/index.js +361 -25
- package/esm/core/component/ckp/interface.d.ts +540 -0
- package/esm/core/component/ckp/interface.js +233 -0
- package/esm/core/component/element/index.d.ts +46 -8
- package/esm/core/component/element/index.js +922 -28
- package/esm/core/component/element/mock.d.ts +0 -4
- package/esm/core/component/element/mock.js +1 -365
- package/esm/core/component/element/type.d.ts +1 -42
- package/esm/core/component/index.d.ts +1 -5
- package/esm/core/component/index.js +2 -1
- package/esm/foundation/core/index.d.ts +1 -6
- package/esm/foundation/core/index.js +35 -70
- package/esm/foundation/index.d.ts +0 -14
- package/esm/foundation/index.js +2 -13
- package/esm/foundation/service/container/index.d.ts +3 -6
- package/esm/foundation/service/container/index.js +16 -43
- package/esm/foundation/service/container/popup.d.ts +1 -1
- package/esm/foundation/service/event-center.js +0 -1
- package/esm/foundation/service/log/keys.js +1 -3
- package/esm/index.js +0 -1
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/index.js +1 -1
- package/esm/types/index.d.ts +1 -1
- package/esm/types/index.js +1 -1
- package/package.json +1 -1
- package/esm/core/component/element/elementContainerService/containerService.d.ts +0 -33
- package/esm/core/component/element/elementContainerService/containerService.js +0 -123
- package/esm/core/component/element/elementContainerService/index.d.ts +0 -20
- package/esm/core/component/element/elementContainerService/index.js +0 -63
- package/esm/core/component/element/elementController/index.d.ts +0 -27
- package/esm/core/component/element/elementController/index.js +0 -476
- package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +0 -20
- package/esm/core/component/element/elementProcessor/addressProcessor.js +0 -160
- package/esm/core/component/element/elementProcessor/authProcessor.d.ts +0 -20
- package/esm/core/component/element/elementProcessor/authProcessor.js +0 -125
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +0 -38
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +0 -85
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +0 -20
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +0 -373
- package/esm/core/component/element/util.d.ts +0 -60
- package/esm/core/component/element/util.js +0 -451
- package/esm/core/component/oldElement/index.d.ts +0 -59
- package/esm/core/component/oldElement/index.js +0 -956
- package/esm/core/component/oldElement/mock.d.ts +0 -6
- package/esm/core/component/oldElement/mock.js +0 -567
- package/esm/core/component/oldElement/type.d.ts +0 -351
- package/esm/core/component/oldElement/type.js +0 -81
- package/esm/foundation/product-processor/element/index.d.ts +0 -7
- package/esm/foundation/product-processor/element/index.js +0 -24
- /package/esm/core/component/{oldElement → element}/components/address.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/address.js +0 -0
- /package/esm/core/component/{oldElement → element}/components/auth.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/auth.js +0 -0
- /package/esm/core/component/{oldElement → element}/components/payment.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/payment.js +0 -0
- /package/esm/core/component/{oldElement → element}/utils.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/utils.js +0 -0
@@ -1,15 +1,32 @@
|
|
1
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 _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; }
|
5
|
+
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); } }
|
6
|
+
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); }); }; }
|
2
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
8
|
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
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
10
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
12
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
13
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
15
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
5
17
|
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
18
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
19
|
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
20
|
import { v4 as uuid } from 'uuid';
|
21
|
+
import ApplePayService from "../../../plugin/applepay/service";
|
22
|
+
import { getApplePayPaymentSession } from "../../../service";
|
9
23
|
import { EnvironmentEnum } from "../../../types";
|
10
24
|
import { queryParse } from "../../../util";
|
11
25
|
import { LogConfig, Logger } from "../../../util/logger";
|
26
|
+
import { BusManager, BusMessage } from "../../bus";
|
27
|
+
import CoreInstance from "../../instance/index";
|
12
28
|
var CKP_PAYMENT_PAGE_HOST = {
|
29
|
+
LOCAL: 'http://localhost:5173',
|
13
30
|
DEV: 'https://dev.page.alipay.net',
|
14
31
|
TEST: 'https://test.page.alipay.net',
|
15
32
|
PRE: 'https://pre.ac.alipay.com',
|
@@ -19,9 +36,12 @@ var CKP_PAYMENT_PAGE_HOST = {
|
|
19
36
|
// for local development
|
20
37
|
|
21
38
|
var CKP_PAGE_ADDRESS = '/page/antom-web-checkout-v2/checkout-page/pages/payment/index.html';
|
39
|
+
var CKP_PAGE_LOCAL = '/checkout-page/src/pages/payment/index.html';
|
22
40
|
var CKP_PAGE_NEW_ADDRESS = '/checkout-page/pages/payment/index.html';
|
23
41
|
export var getCKPPageAddress = function getCKPPageAddress(env) {
|
24
42
|
switch (env) {
|
43
|
+
case 'local':
|
44
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.LOCAL).concat(CKP_PAGE_LOCAL);
|
25
45
|
case 'dev':
|
26
46
|
return "".concat(CKP_PAYMENT_PAGE_HOST.DEV).concat(CKP_PAGE_ADDRESS);
|
27
47
|
case 'sit':
|
@@ -37,16 +57,19 @@ export var getCKPPageAddress = function getCKPPageAddress(env) {
|
|
37
57
|
return env;
|
38
58
|
}
|
39
59
|
};
|
40
|
-
export var AMSCheckoutPage = /*#__PURE__*/function () {
|
60
|
+
export var AMSCheckoutPage = /*#__PURE__*/function (_CoreInstance) {
|
61
|
+
_inherits(AMSCheckoutPage, _CoreInstance);
|
62
|
+
var _super = _createSuper(AMSCheckoutPage);
|
41
63
|
function AMSCheckoutPage(options) {
|
42
|
-
var _this
|
64
|
+
var _this;
|
43
65
|
_classCallCheck(this, AMSCheckoutPage);
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
_defineProperty(
|
49
|
-
_defineProperty(
|
66
|
+
_this = _super.call(this, options);
|
67
|
+
// logger: Logger;
|
68
|
+
// private _instanceId: string;
|
69
|
+
// private originOptions: IoptionsParams;
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "APP_IFRAME_ID", 'antom-checkout-page-sub-page-iframe');
|
71
|
+
_defineProperty(_assertThisInitialized(_this), "eventListener", void 0);
|
72
|
+
_defineProperty(_assertThisInitialized(_this), "generateIframeSrc", function (sessionData) {
|
50
73
|
var env = _this.originOptions.environment || 'prod';
|
51
74
|
var session = sessionData || '';
|
52
75
|
var lang = _this.originOptions.locale || 'en_US';
|
@@ -67,45 +90,149 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
|
|
67
90
|
});
|
68
91
|
return url;
|
69
92
|
});
|
70
|
-
_defineProperty(
|
93
|
+
_defineProperty(_assertThisInitialized(_this), "eventListenerWrapper", function (event) {
|
71
94
|
var _ref = JSON.parse(event.data) || {},
|
72
95
|
code = _ref.code,
|
73
96
|
message = _ref.message,
|
74
97
|
result = _ref.result;
|
75
98
|
if (code && code.startsWith('SDK_PAYMENT')) {
|
76
|
-
var _this$eventListener;
|
99
|
+
var _this$eventListener, _this2;
|
77
100
|
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(
|
101
|
+
(_this$eventListener = (_this2 = _this).eventListener) === null || _this$eventListener === void 0 || _this$eventListener.call(_this2, {
|
79
102
|
code: code,
|
80
103
|
message: message,
|
81
104
|
result: result
|
82
105
|
});
|
83
106
|
}
|
84
107
|
});
|
85
|
-
_defineProperty(
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "addListener", function () {
|
86
109
|
window.addEventListener('message', _this.eventListenerWrapper);
|
87
110
|
});
|
88
|
-
_defineProperty(
|
111
|
+
_defineProperty(_assertThisInitialized(_this), "removeListener", function () {
|
89
112
|
window.removeEventListener('message', _this.eventListenerWrapper);
|
90
113
|
});
|
91
114
|
options.environment = options.environment || EnvironmentEnum.prod;
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
this.
|
96
|
-
|
97
|
-
|
98
|
-
|
115
|
+
_this._instanceId = uuid();
|
116
|
+
_this.originOptions = options;
|
117
|
+
_this.eventListener = options.onEventCallback;
|
118
|
+
// this.registerBusAbility();
|
119
|
+
|
120
|
+
_this.logger = new Logger(LogConfig, ![EnvironmentEnum.prod, EnvironmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
|
121
|
+
Logger.setInstance(_this.logger);
|
122
|
+
_this.logger.setMedta({
|
123
|
+
instanceId: _this._instanceId
|
99
124
|
});
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
125
|
+
_this.logger.initTracker();
|
126
|
+
_this.logger.setComponentStartTime(Date.now());
|
127
|
+
_this.logger.setTrackId(_this._instanceId);
|
128
|
+
_this.logger.logInfo({
|
104
129
|
title: 'NEW_AMSSDK_BY_MECHANT',
|
105
130
|
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
|
106
131
|
}).send();
|
132
|
+
return _this;
|
107
133
|
}
|
134
|
+
/**
|
135
|
+
* 初始化 Bus总线的能力
|
136
|
+
*/
|
137
|
+
// private registerBusAbility() {
|
138
|
+
// BusManager.debugTrace(this.originOptions?.environment !== EnvironmentEnum.prod, this.logger);
|
139
|
+
// BusManager.clear();
|
140
|
+
// BusManager.addInterceptor({
|
141
|
+
// onPublishException: (message: BusMessage, e) => {
|
142
|
+
// this.logger.logError(
|
143
|
+
// { title: 'onBusPublishException' },
|
144
|
+
// {
|
145
|
+
// ...message,
|
146
|
+
// errorMessage: JSON.stringify(e),
|
147
|
+
// },
|
148
|
+
// );
|
149
|
+
// },
|
150
|
+
// });
|
151
|
+
// // subscribe basic ablility
|
152
|
+
// // BusManager.subscribe(
|
153
|
+
// // new SDKCallbackBusSubscriber((state: { code: string; message?: string; result?: EventCallbackResult }) => {
|
154
|
+
// this._componentApp?.AMSSDK?._eventCenter.emit(EVENT.eventCallback.name, state);
|
155
|
+
// // }),
|
156
|
+
// // );
|
157
|
+
// // BusManager.subscribe(
|
158
|
+
// // new SecurityBusSubscriber((deviceIdParameter: DeviceIdParameter, isPolling: boolean) => {
|
159
|
+
// // return this._componentApp?.getDeviceIdAndLog(deviceIdParameter, isPolling);
|
160
|
+
// // }),
|
161
|
+
// // );
|
162
|
+
|
163
|
+
// // BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
164
|
+
// // subscribe plugin
|
165
|
+
// BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
|
166
|
+
|
167
|
+
// // register bus plugin
|
168
|
+
// ExtendPlugin.forEach((item) => {
|
169
|
+
// if (item?.busSubscriber) {
|
170
|
+
// BusManager.subscribe(item?.busSubscriber);
|
171
|
+
// }
|
172
|
+
|
173
|
+
// const paymentChannelMatcher = item.paymentChannelMatcher;
|
174
|
+
// if (paymentChannelMatcher) {
|
175
|
+
// this._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
|
176
|
+
// }
|
177
|
+
// const sessionMatcher = item.sessionMatcher;
|
178
|
+
// if (sessionMatcher) {
|
179
|
+
// const pluginKey =
|
180
|
+
// sessionMatcher.productScene + sessionMatcher.productSceneVersion + sessionMatcher.paymentMethodCategoryType;
|
181
|
+
// if (sessionMatcher.paymentMethodTypes) {
|
182
|
+
// sessionMatcher.paymentMethodTypes.forEach((paymentMethodType) => {
|
183
|
+
// const subPluginKey = pluginKey + paymentMethodType;
|
184
|
+
// this._registerPlugin(subPluginKey, item.busActionNames);
|
185
|
+
// });
|
186
|
+
// } else {
|
187
|
+
// this._registerPlugin(pluginKey, item.busActionNames);
|
188
|
+
// }
|
189
|
+
// }
|
190
|
+
// const optInit = item?.busActionNames?.optional_init;
|
191
|
+
// if (optInit) {
|
192
|
+
// BusManager.publish(new BusMessage(optInit, JSON.stringify(this.originOptions)));
|
193
|
+
// }
|
194
|
+
// });
|
195
|
+
// }
|
196
|
+
/**
|
197
|
+
* To determine whether the corresponding payment method is available,
|
198
|
+
* only the channel described in the document will be called, and it will be returned as available by default
|
199
|
+
* @param paymentMethod - described in the document
|
200
|
+
* @param subPaymentMethod - described in the document
|
201
|
+
* @returns
|
202
|
+
*/
|
108
203
|
_createClass(AMSCheckoutPage, [{
|
204
|
+
key: "canMakePayments",
|
205
|
+
value: function canMakePayments(paymentMethod, subPaymentMethod) {
|
206
|
+
var _this3 = this;
|
207
|
+
// 判断支付方式是否可用
|
208
|
+
return new Promise(function (resolve) {
|
209
|
+
var _this3$_getPlugin;
|
210
|
+
if (!paymentMethod) {
|
211
|
+
return resolve(true);
|
212
|
+
}
|
213
|
+
var actionName = (_this3$_getPlugin = _this3._getPlugin(paymentMethod)) === null || _this3$_getPlugin === void 0 ? void 0 : _this3$_getPlugin.canMakePayments;
|
214
|
+
if (actionName && BusManager.isSubscribed(actionName)) {
|
215
|
+
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
216
|
+
paymentMethod: paymentMethod,
|
217
|
+
subPaymentMethod: subPaymentMethod
|
218
|
+
})), {
|
219
|
+
fallback: false
|
220
|
+
}).then(function (message) {
|
221
|
+
resolve(message.getJSONObject());
|
222
|
+
}).catch(function (e) {
|
223
|
+
_this3.logger.logInfo({
|
224
|
+
title: 'canMakePayments_error'
|
225
|
+
}, {
|
226
|
+
errorMessage: JSON.stringify(e)
|
227
|
+
});
|
228
|
+
resolve(false);
|
229
|
+
});
|
230
|
+
} else {
|
231
|
+
resolve(true);
|
232
|
+
}
|
233
|
+
});
|
234
|
+
}
|
235
|
+
}, {
|
109
236
|
key: "mountComponent",
|
110
237
|
value:
|
111
238
|
/**
|
@@ -167,6 +294,215 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
|
|
167
294
|
}
|
168
295
|
return;
|
169
296
|
}
|
297
|
+
/**
|
298
|
+
* @description Execute payment submission process
|
299
|
+
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
300
|
+
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
301
|
+
*/
|
302
|
+
}, {
|
303
|
+
key: "applePaySubmit",
|
304
|
+
value: function applePaySubmit(_ref2, paymentEndFn, doSubmit) {
|
305
|
+
var _this4 = this,
|
306
|
+
_request$total,
|
307
|
+
_request$total2;
|
308
|
+
var paymentRequest = _ref2.paymentRequest,
|
309
|
+
paymentSessionData = _ref2.paymentSessionData,
|
310
|
+
paymentMethod = _ref2.paymentMethod,
|
311
|
+
version = _ref2.version,
|
312
|
+
request = _ref2.request;
|
313
|
+
var appleService = new ApplePayService(this.logger);
|
314
|
+
if (!ApplePayService.canMakePayments(version)) {
|
315
|
+
this.logger.logError({
|
316
|
+
code: 'a3753.b103030.c386485.d507471'
|
317
|
+
}, {
|
318
|
+
paymentRequest: paymentRequest
|
319
|
+
});
|
320
|
+
paymentEndFn === null || paymentEndFn === void 0 || paymentEndFn({
|
321
|
+
status: false,
|
322
|
+
error: {
|
323
|
+
errorCode: 'APPLE_PAY_NOT_SUPPORTED'
|
324
|
+
}
|
325
|
+
});
|
326
|
+
return;
|
327
|
+
}
|
328
|
+
var getMerchantSession = /*#__PURE__*/function () {
|
329
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
|
330
|
+
var validationUrl, requestParams;
|
331
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
332
|
+
while (1) switch (_context.prev = _context.next) {
|
333
|
+
case 0:
|
334
|
+
validationUrl = _ref3.validationUrl;
|
335
|
+
// get validateUrl
|
336
|
+
requestParams = {
|
337
|
+
validateUrl: validationUrl,
|
338
|
+
paymentSessionData: paymentSessionData
|
339
|
+
};
|
340
|
+
return _context.abrupt("return", getApplePayPaymentSession(paymentSessionData, requestParams, {
|
341
|
+
env: 'prod',
|
342
|
+
envInfo: {
|
343
|
+
deviceId: ''
|
344
|
+
}
|
345
|
+
}, _this4.logger).then(function (res) {
|
346
|
+
if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
|
347
|
+
return Promise.resolve(res.merchantSessionObject);
|
348
|
+
}
|
349
|
+
paymentEndFn === null || paymentEndFn === void 0 || paymentEndFn({
|
350
|
+
status: false,
|
351
|
+
error: {
|
352
|
+
errorCode: res === null || res === void 0 ? void 0 : res.errorCode,
|
353
|
+
errorMessage: res === null || res === void 0 ? void 0 : res.errorMessage
|
354
|
+
}
|
355
|
+
});
|
356
|
+
return Promise.reject({
|
357
|
+
errorCode: res.errorCode,
|
358
|
+
errorMessage: res.errorMessage
|
359
|
+
});
|
360
|
+
}).catch(function (error) {
|
361
|
+
_this4.logger.logError({
|
362
|
+
code: 'a3753.b103030.c386485.d507483'
|
363
|
+
}, error);
|
364
|
+
paymentEndFn === null || paymentEndFn === void 0 || paymentEndFn({
|
365
|
+
status: false,
|
366
|
+
error: {
|
367
|
+
errorCode: 'APPLE_PAY_PAYMENT_SESSION_REQUEST_FAILED'
|
368
|
+
}
|
369
|
+
});
|
370
|
+
return Promise.reject(error);
|
371
|
+
}));
|
372
|
+
case 3:
|
373
|
+
case "end":
|
374
|
+
return _context.stop();
|
375
|
+
}
|
376
|
+
}, _callee);
|
377
|
+
}));
|
378
|
+
return function getMerchantSession(_x) {
|
379
|
+
return _ref4.apply(this, arguments);
|
380
|
+
};
|
381
|
+
}();
|
382
|
+
var completePaymentAuthorized = /*#__PURE__*/function () {
|
383
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
384
|
+
var _ref6,
|
385
|
+
paymentToken,
|
386
|
+
billingContact,
|
387
|
+
shippingContact,
|
388
|
+
paramsPaymentFactors,
|
389
|
+
params,
|
390
|
+
submitResult,
|
391
|
+
_args2 = arguments;
|
392
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
393
|
+
while (1) switch (_context2.prev = _context2.next) {
|
394
|
+
case 0:
|
395
|
+
_ref6 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, paymentToken = _ref6.paymentToken, billingContact = _ref6.billingContact, shippingContact = _ref6.shippingContact;
|
396
|
+
// 外网沙箱环境
|
397
|
+
paramsPaymentFactors = {
|
398
|
+
instPaymentToken: paymentToken,
|
399
|
+
applePayBillingContact: billingContact,
|
400
|
+
applePayShippingContact: shippingContact
|
401
|
+
};
|
402
|
+
_context2.prev = 2;
|
403
|
+
params = _objectSpread(_objectSpread({}, paymentMethod), {}, {
|
404
|
+
paymentFactors: paramsPaymentFactors
|
405
|
+
});
|
406
|
+
_context2.t0 = doSubmit;
|
407
|
+
if (!_context2.t0) {
|
408
|
+
_context2.next = 9;
|
409
|
+
break;
|
410
|
+
}
|
411
|
+
_context2.next = 8;
|
412
|
+
return doSubmit(params);
|
413
|
+
case 8:
|
414
|
+
_context2.t0 = _context2.sent;
|
415
|
+
case 9:
|
416
|
+
submitResult = _context2.t0;
|
417
|
+
if (!(submitResult !== null && submitResult !== void 0 && submitResult.success || (submitResult === null || submitResult === void 0 ? void 0 : submitResult.errorStatus) === 'U')) {
|
418
|
+
_context2.next = 12;
|
419
|
+
break;
|
420
|
+
}
|
421
|
+
return _context2.abrupt("return", Promise.resolve(submitResult));
|
422
|
+
case 12:
|
423
|
+
return _context2.abrupt("return", Promise.reject({
|
424
|
+
errorCode: submitResult.errorCode,
|
425
|
+
errorMessage: submitResult.errorMessage
|
426
|
+
}));
|
427
|
+
case 15:
|
428
|
+
_context2.prev = 15;
|
429
|
+
_context2.t1 = _context2["catch"](2);
|
430
|
+
paymentEndFn === null || paymentEndFn === void 0 || paymentEndFn({
|
431
|
+
status: false,
|
432
|
+
error: _context2.t1
|
433
|
+
});
|
434
|
+
return _context2.abrupt("return", Promise.reject(_context2.t1));
|
435
|
+
case 19:
|
436
|
+
case "end":
|
437
|
+
return _context2.stop();
|
438
|
+
}
|
439
|
+
}, _callee2, null, [[2, 15]]);
|
440
|
+
}));
|
441
|
+
return function completePaymentAuthorized() {
|
442
|
+
return _ref5.apply(this, arguments);
|
443
|
+
};
|
444
|
+
}();
|
445
|
+
var completeApplePay = function completeApplePay(data) {
|
446
|
+
paymentEndFn === null || paymentEndFn === void 0 || paymentEndFn({
|
447
|
+
status: true,
|
448
|
+
result: data
|
449
|
+
});
|
450
|
+
};
|
451
|
+
appleService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, paymentEndFn);
|
452
|
+
var param = {
|
453
|
+
paymentSessionFactor: {
|
454
|
+
extendInfo: {
|
455
|
+
merchantCapabilities: request === null || request === void 0 ? void 0 : request.merchantCapabilities,
|
456
|
+
supportedNetworks: request === null || request === void 0 ? void 0 : request.supportedNetworks,
|
457
|
+
requiredBillingContactFields: null,
|
458
|
+
requiredShippingContactFields: null
|
459
|
+
},
|
460
|
+
merchantInfo: {
|
461
|
+
partnerId: '1',
|
462
|
+
registeredCountry: request === null || request === void 0 ? void 0 : request.countryCode,
|
463
|
+
merchantName: request === null || request === void 0 || (_request$total = request.total) === null || _request$total === void 0 ? void 0 : _request$total.label
|
464
|
+
},
|
465
|
+
paymentAmount: {
|
466
|
+
currency: request === null || request === void 0 ? void 0 : request.currencyCode,
|
467
|
+
value: request === null || request === void 0 || (_request$total2 = request.total) === null || _request$total2 === void 0 ? void 0 : _request$total2.amount
|
468
|
+
}
|
469
|
+
}
|
470
|
+
};
|
471
|
+
appleService.startPay(param);
|
472
|
+
// return new Promise((resolve, reject) => {
|
473
|
+
// try {
|
474
|
+
// const eventCallbackId = uuid();
|
475
|
+
|
476
|
+
// this.logger.logInfo({
|
477
|
+
// title: 'sdk_event_apiSubmit',
|
478
|
+
// });
|
479
|
+
// const actionName = this.getBusActionNames()?.submit;
|
480
|
+
// if (actionName && BusManager.isSubscribed(actionName)) {
|
481
|
+
// // 执行出错了,在通用拦截器返回
|
482
|
+
// BusManager.publishForResult(
|
483
|
+
// new BusMessage(
|
484
|
+
// actionName,
|
485
|
+
// JSON.stringify({
|
486
|
+
// appendParams: this._appendParams,
|
487
|
+
// options: this.originOptions,
|
488
|
+
// data: data,
|
489
|
+
// }),
|
490
|
+
// ),
|
491
|
+
// ).then((busMessage) => {
|
492
|
+
// resolve(busMessage?.getJSONObject());
|
493
|
+
// });
|
494
|
+
// } else {
|
495
|
+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
496
|
+
// // this._eventCenter.once(eventCallbackId, (_data: any) => {
|
497
|
+
// // resolve(_data);
|
498
|
+
// // });
|
499
|
+
// // this._componentApp.dispatchToApp({ context: { event: 'submitPay', eventCallbackId, data } });
|
500
|
+
// }
|
501
|
+
// } catch (error) {
|
502
|
+
// reject(error);
|
503
|
+
// }
|
504
|
+
// });
|
505
|
+
}
|
170
506
|
}]);
|
171
507
|
return AMSCheckoutPage;
|
172
|
-
}();
|
508
|
+
}(CoreInstance);
|