@alipay/ams-checkout 0.0.1745390310-dev.0 → 0.0.1745390310-dev.2
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.
@@ -1,6 +1,4 @@
|
|
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
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; }
|
5
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); } }
|
6
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); }); }; }
|
@@ -23,9 +21,9 @@ import { getApplePayPaymentSession } from "../../../service";
|
|
23
21
|
import { EnvironmentEnum } from "../../../types";
|
24
22
|
import { queryParse } from "../../../util";
|
25
23
|
import { LogConfig, Logger } from "../../../util/logger";
|
26
|
-
import { BusManager, BusMessage } from "../../bus";
|
27
24
|
import CoreInstance from "../../instance/index";
|
28
25
|
var CKP_PAYMENT_PAGE_HOST = {
|
26
|
+
LOCAL: 'http://localhost:5174',
|
29
27
|
DEV: 'https://dev.page.alipay.net',
|
30
28
|
TEST: 'https://test.page.alipay.net',
|
31
29
|
PRE: 'https://pre.ac.alipay.com',
|
@@ -35,9 +33,12 @@ var CKP_PAYMENT_PAGE_HOST = {
|
|
35
33
|
// for local development
|
36
34
|
|
37
35
|
var CKP_PAGE_ADDRESS = '/page/antom-web-checkout-v2/checkout-page/pages/payment/index.html';
|
36
|
+
var CKP_PAGE_LOCAL = '/checkout-page/src/pages/payment/index.html';
|
38
37
|
var CKP_PAGE_NEW_ADDRESS = '/checkout-page/pages/payment/index.html';
|
39
38
|
export var getCKPPageAddress = function getCKPPageAddress(env) {
|
40
39
|
switch (env) {
|
40
|
+
case 'local':
|
41
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.LOCAL).concat(CKP_PAGE_LOCAL);
|
41
42
|
case 'dev':
|
42
43
|
return "".concat(CKP_PAYMENT_PAGE_HOST.DEV).concat(CKP_PAGE_ADDRESS);
|
43
44
|
case 'sit':
|
@@ -62,14 +63,15 @@ export var AMSCheckoutPage = /*#__PURE__*/function (_CoreInstance) {
|
|
62
63
|
_this = _super.call(this, options);
|
63
64
|
// logger: Logger;
|
64
65
|
// private _instanceId: string;
|
65
|
-
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "app", void 0);
|
66
67
|
_defineProperty(_assertThisInitialized(_this), "APP_IFRAME_ID", 'antom-checkout-page-sub-page-iframe');
|
67
68
|
_defineProperty(_assertThisInitialized(_this), "eventListener", void 0);
|
68
69
|
_defineProperty(_assertThisInitialized(_this), "generateIframeSrc", function (sessionData) {
|
69
70
|
var env = _this.originOptions.environment || 'prod';
|
70
71
|
var session = sessionData || '';
|
71
72
|
var lang = _this.originOptions.locale || 'en_US';
|
72
|
-
|
73
|
+
console.log(env, '---env------');
|
74
|
+
var ckpPageAddress = getCKPPageAddress('local');
|
73
75
|
console.log('[antom-web-sdk] <antom-checkout-page> generateIframeSrc', _this.originOptions, env, session, lang, ckpPageAddress);
|
74
76
|
|
75
77
|
// 先获取去除的 query 参数的 url
|
@@ -87,7 +89,7 @@ export var AMSCheckoutPage = /*#__PURE__*/function (_CoreInstance) {
|
|
87
89
|
return url;
|
88
90
|
});
|
89
91
|
_defineProperty(_assertThisInitialized(_this), "eventListenerWrapper", function (event) {
|
90
|
-
var _ref = JSON.parse(event.data) || {},
|
92
|
+
var _ref = JSON.parse((event === null || event === void 0 ? void 0 : event.data) || '') || {},
|
91
93
|
code = _ref.code,
|
92
94
|
message = _ref.message,
|
93
95
|
result = _ref.result;
|
@@ -111,8 +113,7 @@ export var AMSCheckoutPage = /*#__PURE__*/function (_CoreInstance) {
|
|
111
113
|
_this._instanceId = uuid();
|
112
114
|
_this.originOptions = options;
|
113
115
|
_this.eventListener = options.onEventCallback;
|
114
|
-
|
115
|
-
|
116
|
+
_this.app = null;
|
116
117
|
_this.logger = new Logger(LogConfig, ![EnvironmentEnum.prod, EnvironmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
|
117
118
|
Logger.setInstance(_this.logger);
|
118
119
|
_this.logger.setMedta({
|
@@ -125,110 +126,25 @@ export var AMSCheckoutPage = /*#__PURE__*/function (_CoreInstance) {
|
|
125
126
|
title: 'NEW_AMSSDK_BY_MECHANT',
|
126
127
|
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
|
127
128
|
}).send();
|
129
|
+
|
130
|
+
// 监听ckp applePay提交支付动作
|
131
|
+
var onListenSubmitAction = function onListenSubmitAction(e) {
|
132
|
+
if (typeof (e === null || e === void 0 ? void 0 : e.data) !== 'string') {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
var submitData = JSON.parse((e === null || e === void 0 ? void 0 : e.data) || '{}');
|
136
|
+
var _ref2 = (submitData === null || submitData === void 0 ? void 0 : submitData.context) || {},
|
137
|
+
event = _ref2.event,
|
138
|
+
data = _ref2.data;
|
139
|
+
if (event === 'onApplePaySubmit') {
|
140
|
+
console.log(data, 'onApplePaySubmit--------');
|
141
|
+
_this.applePaySubmit(data);
|
142
|
+
}
|
143
|
+
};
|
144
|
+
window.addEventListener('message', onListenSubmitAction);
|
128
145
|
return _this;
|
129
146
|
}
|
130
|
-
/**
|
131
|
-
* 初始化 Bus总线的能力
|
132
|
-
*/
|
133
|
-
// private registerBusAbility() {
|
134
|
-
// BusManager.debugTrace(this.originOptions?.environment !== EnvironmentEnum.prod, this.logger);
|
135
|
-
// BusManager.clear();
|
136
|
-
// BusManager.addInterceptor({
|
137
|
-
// onPublishException: (message: BusMessage, e) => {
|
138
|
-
// this.logger.logError(
|
139
|
-
// { title: 'onBusPublishException' },
|
140
|
-
// {
|
141
|
-
// ...message,
|
142
|
-
// errorMessage: JSON.stringify(e),
|
143
|
-
// },
|
144
|
-
// );
|
145
|
-
// },
|
146
|
-
// });
|
147
|
-
// // subscribe basic ablility
|
148
|
-
// // BusManager.subscribe(
|
149
|
-
// // new SDKCallbackBusSubscriber((state: { code: string; message?: string; result?: EventCallbackResult }) => {
|
150
|
-
// this._componentApp?.AMSSDK?._eventCenter.emit(EVENT.eventCallback.name, state);
|
151
|
-
// // }),
|
152
|
-
// // );
|
153
|
-
// // BusManager.subscribe(
|
154
|
-
// // new SecurityBusSubscriber((deviceIdParameter: DeviceIdParameter, isPolling: boolean) => {
|
155
|
-
// // return this._componentApp?.getDeviceIdAndLog(deviceIdParameter, isPolling);
|
156
|
-
// // }),
|
157
|
-
// // );
|
158
|
-
|
159
|
-
// // BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
160
|
-
// // subscribe plugin
|
161
|
-
// BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
|
162
|
-
|
163
|
-
// // register bus plugin
|
164
|
-
// ExtendPlugin.forEach((item) => {
|
165
|
-
// if (item?.busSubscriber) {
|
166
|
-
// BusManager.subscribe(item?.busSubscriber);
|
167
|
-
// }
|
168
|
-
|
169
|
-
// const paymentChannelMatcher = item.paymentChannelMatcher;
|
170
|
-
// if (paymentChannelMatcher) {
|
171
|
-
// this._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
|
172
|
-
// }
|
173
|
-
// const sessionMatcher = item.sessionMatcher;
|
174
|
-
// if (sessionMatcher) {
|
175
|
-
// const pluginKey =
|
176
|
-
// sessionMatcher.productScene + sessionMatcher.productSceneVersion + sessionMatcher.paymentMethodCategoryType;
|
177
|
-
// if (sessionMatcher.paymentMethodTypes) {
|
178
|
-
// sessionMatcher.paymentMethodTypes.forEach((paymentMethodType) => {
|
179
|
-
// const subPluginKey = pluginKey + paymentMethodType;
|
180
|
-
// this._registerPlugin(subPluginKey, item.busActionNames);
|
181
|
-
// });
|
182
|
-
// } else {
|
183
|
-
// this._registerPlugin(pluginKey, item.busActionNames);
|
184
|
-
// }
|
185
|
-
// }
|
186
|
-
// const optInit = item?.busActionNames?.optional_init;
|
187
|
-
// if (optInit) {
|
188
|
-
// BusManager.publish(new BusMessage(optInit, JSON.stringify(this.originOptions)));
|
189
|
-
// }
|
190
|
-
// });
|
191
|
-
// }
|
192
|
-
/**
|
193
|
-
* To determine whether the corresponding payment method is available,
|
194
|
-
* only the channel described in the document will be called, and it will be returned as available by default
|
195
|
-
* @param paymentMethod - described in the document
|
196
|
-
* @param subPaymentMethod - described in the document
|
197
|
-
* @returns
|
198
|
-
*/
|
199
147
|
_createClass(AMSCheckoutPage, [{
|
200
|
-
key: "canMakePayments",
|
201
|
-
value: function canMakePayments(paymentMethod, subPaymentMethod) {
|
202
|
-
var _this3 = this;
|
203
|
-
// 判断支付方式是否可用
|
204
|
-
return new Promise(function (resolve) {
|
205
|
-
var _this3$_getPlugin;
|
206
|
-
if (!paymentMethod) {
|
207
|
-
return resolve(true);
|
208
|
-
}
|
209
|
-
var actionName = (_this3$_getPlugin = _this3._getPlugin(paymentMethod)) === null || _this3$_getPlugin === void 0 ? void 0 : _this3$_getPlugin.canMakePayments;
|
210
|
-
if (actionName && BusManager.isSubscribed(actionName)) {
|
211
|
-
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
212
|
-
paymentMethod: paymentMethod,
|
213
|
-
subPaymentMethod: subPaymentMethod
|
214
|
-
})), {
|
215
|
-
fallback: false
|
216
|
-
}).then(function (message) {
|
217
|
-
resolve(message.getJSONObject());
|
218
|
-
}).catch(function (e) {
|
219
|
-
_this3.logger.logInfo({
|
220
|
-
title: 'canMakePayments_error'
|
221
|
-
}, {
|
222
|
-
errorMessage: JSON.stringify(e)
|
223
|
-
});
|
224
|
-
resolve(false);
|
225
|
-
});
|
226
|
-
} else {
|
227
|
-
resolve(true);
|
228
|
-
}
|
229
|
-
});
|
230
|
-
}
|
231
|
-
}, {
|
232
148
|
key: "mountComponent",
|
233
149
|
value:
|
234
150
|
/**
|
@@ -254,6 +170,7 @@ export var AMSCheckoutPage = /*#__PURE__*/function (_CoreInstance) {
|
|
254
170
|
this.addListener();
|
255
171
|
var ckpPageAddress = this.generateIframeSrc(params.sessionData);
|
256
172
|
var iframe = document.createElement('iframe');
|
173
|
+
this.app = iframe;
|
257
174
|
iframe.id = this.APP_IFRAME_ID;
|
258
175
|
iframe.src = ckpPageAddress;
|
259
176
|
// iframe设置支持第三方支付
|
@@ -297,208 +214,221 @@ export var AMSCheckoutPage = /*#__PURE__*/function (_CoreInstance) {
|
|
297
214
|
*/
|
298
215
|
}, {
|
299
216
|
key: "applePaySubmit",
|
300
|
-
value: function
|
301
|
-
var
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
error: {
|
319
|
-
errorCode: 'APPLE_PAY_NOT_SUPPORTED'
|
320
|
-
}
|
321
|
-
});
|
322
|
-
return;
|
323
|
-
}
|
324
|
-
var getMerchantSession = /*#__PURE__*/function () {
|
325
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
|
326
|
-
var validationUrl, requestParams;
|
327
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
328
|
-
while (1) switch (_context.prev = _context.next) {
|
329
|
-
case 0:
|
330
|
-
validationUrl = _ref3.validationUrl;
|
331
|
-
// get validateUrl
|
332
|
-
requestParams = {
|
333
|
-
validateUrl: validationUrl,
|
334
|
-
paymentSessionData: paymentSessionData
|
335
|
-
};
|
336
|
-
return _context.abrupt("return", getApplePayPaymentSession(paymentSessionData, requestParams, {
|
337
|
-
env: 'prod',
|
338
|
-
envInfo: {
|
339
|
-
deviceId: ''
|
217
|
+
value: (function () {
|
218
|
+
var _applePaySubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
|
219
|
+
var _this3 = this,
|
220
|
+
_request$total,
|
221
|
+
_request$total2;
|
222
|
+
var paymentRequest, paymentSessionData, paymentMethod, version, request, appleService, onPostEndMessage, getMerchantSession, completePaymentAuthorized, completeApplePay, param, status;
|
223
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
224
|
+
while (1) switch (_context3.prev = _context3.next) {
|
225
|
+
case 0:
|
226
|
+
paymentRequest = _ref3.paymentRequest, paymentSessionData = _ref3.paymentSessionData, paymentMethod = _ref3.paymentMethod, version = _ref3.version, request = _ref3.request;
|
227
|
+
appleService = new ApplePayService(this.logger);
|
228
|
+
onPostEndMessage = function onPostEndMessage(data) {
|
229
|
+
console.log('enter--onPostEndMessage---', data, _this3.app);
|
230
|
+
_this3.app.contentWindow.postMessage(JSON.stringify({
|
231
|
+
name: 'SDK_TO_APP',
|
232
|
+
context: {
|
233
|
+
event: 'paymentEnd',
|
234
|
+
data: JSON.stringify(data)
|
340
235
|
}
|
341
|
-
},
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
236
|
+
}), '*');
|
237
|
+
};
|
238
|
+
if (ApplePayService.canMakePayments(version)) {
|
239
|
+
_context3.next = 7;
|
240
|
+
break;
|
241
|
+
}
|
242
|
+
this.logger.logError({
|
243
|
+
code: 'a3753.b103030.c386485.d507471'
|
244
|
+
}, {
|
245
|
+
paymentRequest: paymentRequest
|
246
|
+
});
|
247
|
+
onPostEndMessage === null || onPostEndMessage === void 0 || onPostEndMessage({
|
248
|
+
status: false,
|
249
|
+
error: {
|
250
|
+
errorCode: 'APPLE_PAY_NOT_SUPPORTED'
|
251
|
+
}
|
252
|
+
});
|
253
|
+
return _context3.abrupt("return");
|
254
|
+
case 7:
|
255
|
+
getMerchantSession = /*#__PURE__*/function () {
|
256
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
|
257
|
+
var validationUrl, requestParams;
|
258
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
259
|
+
while (1) switch (_context.prev = _context.next) {
|
260
|
+
case 0:
|
261
|
+
validationUrl = _ref4.validationUrl;
|
262
|
+
// get validateUrl
|
263
|
+
requestParams = {
|
264
|
+
validateUrl: validationUrl,
|
265
|
+
paymentSessionData: paymentSessionData
|
266
|
+
};
|
267
|
+
return _context.abrupt("return", getApplePayPaymentSession(paymentSessionData, requestParams, {
|
268
|
+
env: 'prod',
|
269
|
+
envInfo: {
|
270
|
+
deviceId: ''
|
271
|
+
}
|
272
|
+
}, _this3.logger).then(function (res) {
|
273
|
+
if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
|
274
|
+
return Promise.resolve(res.merchantSessionObject);
|
275
|
+
}
|
276
|
+
onPostEndMessage === null || onPostEndMessage === void 0 || onPostEndMessage({
|
277
|
+
status: false,
|
278
|
+
error: {
|
279
|
+
errorCode: res === null || res === void 0 ? void 0 : res.errorCode,
|
280
|
+
errorMessage: res === null || res === void 0 ? void 0 : res.errorMessage
|
281
|
+
}
|
282
|
+
});
|
283
|
+
return Promise.reject({
|
284
|
+
errorCode: res.errorCode,
|
285
|
+
errorMessage: res.errorMessage
|
286
|
+
});
|
287
|
+
}).catch(function (error) {
|
288
|
+
_this3.logger.logError({
|
289
|
+
code: 'a3753.b103030.c386485.d507483'
|
290
|
+
}, error);
|
291
|
+
onPostEndMessage === null || onPostEndMessage === void 0 || onPostEndMessage({
|
292
|
+
status: false,
|
293
|
+
error: {
|
294
|
+
errorCode: 'APPLE_PAY_PAYMENT_SESSION_REQUEST_FAILED'
|
295
|
+
}
|
296
|
+
});
|
297
|
+
return Promise.reject(error);
|
298
|
+
}));
|
299
|
+
case 3:
|
300
|
+
case "end":
|
301
|
+
return _context.stop();
|
350
302
|
}
|
351
|
-
});
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
303
|
+
}, _callee);
|
304
|
+
}));
|
305
|
+
return function getMerchantSession(_x2) {
|
306
|
+
return _ref5.apply(this, arguments);
|
307
|
+
};
|
308
|
+
}();
|
309
|
+
completePaymentAuthorized = /*#__PURE__*/function () {
|
310
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
311
|
+
var _ref7,
|
312
|
+
paymentToken,
|
313
|
+
billingContact,
|
314
|
+
shippingContact,
|
315
|
+
paramsPaymentFactors,
|
316
|
+
submitResult,
|
317
|
+
_args2 = arguments;
|
318
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
319
|
+
while (1) switch (_context2.prev = _context2.next) {
|
320
|
+
case 0:
|
321
|
+
_ref7 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, paymentToken = _ref7.paymentToken, billingContact = _ref7.billingContact, shippingContact = _ref7.shippingContact;
|
322
|
+
_context2.prev = 1;
|
323
|
+
paramsPaymentFactors = {
|
324
|
+
instPaymentToken: paymentToken,
|
325
|
+
applePayBillingContact: billingContact,
|
326
|
+
applePayShippingContact: shippingContact
|
327
|
+
};
|
328
|
+
_context2.next = 5;
|
329
|
+
return new Promise(function (resolve, reject) {
|
330
|
+
if (!_this3.app) {
|
331
|
+
reject('');
|
332
|
+
}
|
333
|
+
_this3.app.contentWindow.postMessage(JSON.stringify({
|
334
|
+
name: 'SDK_TO_APP',
|
335
|
+
context: {
|
336
|
+
event: 'doSubmit',
|
337
|
+
data: JSON.stringify(paramsPaymentFactors)
|
338
|
+
}
|
339
|
+
}), '*');
|
340
|
+
window.addEventListener('message', function (e) {
|
341
|
+
var messageData = JSON.parse(e === null || e === void 0 ? void 0 : e.data) || {};
|
342
|
+
var _messageData$context = messageData === null || messageData === void 0 ? void 0 : messageData.context,
|
343
|
+
event = _messageData$context.event,
|
344
|
+
data = _messageData$context.data;
|
345
|
+
if (event === 'onApplePaySubmitResult') {
|
346
|
+
resolve(data || {});
|
347
|
+
}
|
348
|
+
});
|
349
|
+
setTimeout(resolve, 20000);
|
350
|
+
});
|
351
|
+
case 5:
|
352
|
+
submitResult = _context2.sent;
|
353
|
+
if (!(submitResult !== null && submitResult !== void 0 && submitResult.success || (submitResult === null || submitResult === void 0 ? void 0 : submitResult.errorStatus) === 'U')) {
|
354
|
+
_context2.next = 8;
|
355
|
+
break;
|
356
|
+
}
|
357
|
+
return _context2.abrupt("return", Promise.resolve(submitResult));
|
358
|
+
case 8:
|
359
|
+
return _context2.abrupt("return", Promise.reject({
|
360
|
+
errorCode: submitResult.errorCode,
|
361
|
+
errorMessage: submitResult.errorMessage
|
362
|
+
}));
|
363
|
+
case 11:
|
364
|
+
_context2.prev = 11;
|
365
|
+
_context2.t0 = _context2["catch"](1);
|
366
|
+
onPostEndMessage === null || onPostEndMessage === void 0 || onPostEndMessage({
|
367
|
+
status: false,
|
368
|
+
error: _context2.t0
|
369
|
+
});
|
370
|
+
return _context2.abrupt("return", Promise.reject(_context2.t0));
|
371
|
+
case 15:
|
372
|
+
case "end":
|
373
|
+
return _context2.stop();
|
364
374
|
}
|
365
|
-
});
|
366
|
-
return Promise.reject(error);
|
375
|
+
}, _callee2, null, [[1, 11]]);
|
367
376
|
}));
|
368
|
-
|
369
|
-
|
370
|
-
return _context.stop();
|
371
|
-
}
|
372
|
-
}, _callee);
|
373
|
-
}));
|
374
|
-
return function getMerchantSession(_x) {
|
375
|
-
return _ref4.apply(this, arguments);
|
376
|
-
};
|
377
|
-
}();
|
378
|
-
var completePaymentAuthorized = /*#__PURE__*/function () {
|
379
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
380
|
-
var _ref6,
|
381
|
-
paymentToken,
|
382
|
-
billingContact,
|
383
|
-
shippingContact,
|
384
|
-
paramsPaymentFactors,
|
385
|
-
params,
|
386
|
-
submitResult,
|
387
|
-
_args2 = arguments;
|
388
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
389
|
-
while (1) switch (_context2.prev = _context2.next) {
|
390
|
-
case 0:
|
391
|
-
_ref6 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, paymentToken = _ref6.paymentToken, billingContact = _ref6.billingContact, shippingContact = _ref6.shippingContact;
|
392
|
-
// 外网沙箱环境
|
393
|
-
paramsPaymentFactors = {
|
394
|
-
instPaymentToken: paymentToken,
|
395
|
-
applePayBillingContact: billingContact,
|
396
|
-
applePayShippingContact: shippingContact
|
377
|
+
return function completePaymentAuthorized() {
|
378
|
+
return _ref6.apply(this, arguments);
|
397
379
|
};
|
398
|
-
|
399
|
-
|
400
|
-
|
380
|
+
}();
|
381
|
+
completeApplePay = function completeApplePay(data) {
|
382
|
+
onPostEndMessage === null || onPostEndMessage === void 0 || onPostEndMessage({
|
383
|
+
status: true,
|
384
|
+
result: data
|
401
385
|
});
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
386
|
+
};
|
387
|
+
appleService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, onPostEndMessage);
|
388
|
+
param = {
|
389
|
+
paymentSessionFactor: {
|
390
|
+
extendInfo: {
|
391
|
+
merchantCapabilities: request === null || request === void 0 ? void 0 : request.merchantCapabilities,
|
392
|
+
supportedNetworks: request === null || request === void 0 ? void 0 : request.supportedNetworks,
|
393
|
+
requiredBillingContactFields: null,
|
394
|
+
requiredShippingContactFields: null
|
395
|
+
},
|
396
|
+
merchantInfo: {
|
397
|
+
partnerId: '1',
|
398
|
+
registeredCountry: request === null || request === void 0 ? void 0 : request.countryCode,
|
399
|
+
merchantName: request === null || request === void 0 || (_request$total = request.total) === null || _request$total === void 0 ? void 0 : _request$total.label
|
400
|
+
},
|
401
|
+
paymentAmount: {
|
402
|
+
currency: request === null || request === void 0 ? void 0 : request.currencyCode,
|
403
|
+
value: request === null || request === void 0 || (_request$total2 = request.total) === null || _request$total2 === void 0 ? void 0 : _request$total2.amount
|
404
|
+
}
|
406
405
|
}
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
_context2.next = 12;
|
415
|
-
break;
|
406
|
+
};
|
407
|
+
try {
|
408
|
+
status = appleService.startPay(param);
|
409
|
+
if (!status) {
|
410
|
+
onPostEndMessage === null || onPostEndMessage === void 0 || onPostEndMessage({
|
411
|
+
status: false
|
412
|
+
});
|
416
413
|
}
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
errorCode: submitResult.errorCode,
|
421
|
-
errorMessage: submitResult.errorMessage
|
422
|
-
}));
|
423
|
-
case 15:
|
424
|
-
_context2.prev = 15;
|
425
|
-
_context2.t1 = _context2["catch"](2);
|
426
|
-
paymentEndFn === null || paymentEndFn === void 0 || paymentEndFn({
|
414
|
+
} catch (error) {
|
415
|
+
console.log(error, '----error-----');
|
416
|
+
onPostEndMessage === null || onPostEndMessage === void 0 || onPostEndMessage({
|
427
417
|
status: false,
|
428
|
-
error:
|
418
|
+
error: error
|
429
419
|
});
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
}
|
435
|
-
}, _callee2, null, [[2, 15]]);
|
436
|
-
}));
|
437
|
-
return function completePaymentAuthorized() {
|
438
|
-
return _ref5.apply(this, arguments);
|
439
|
-
};
|
440
|
-
}();
|
441
|
-
var completeApplePay = function completeApplePay(data) {
|
442
|
-
paymentEndFn === null || paymentEndFn === void 0 || paymentEndFn({
|
443
|
-
status: true,
|
444
|
-
result: data
|
445
|
-
});
|
446
|
-
};
|
447
|
-
appleService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, paymentEndFn);
|
448
|
-
var param = {
|
449
|
-
paymentSessionFactor: {
|
450
|
-
extendInfo: {
|
451
|
-
merchantCapabilities: request === null || request === void 0 ? void 0 : request.merchantCapabilities,
|
452
|
-
supportedNetworks: request === null || request === void 0 ? void 0 : request.supportedNetworks,
|
453
|
-
requiredBillingContactFields: null,
|
454
|
-
requiredShippingContactFields: null
|
455
|
-
},
|
456
|
-
merchantInfo: {
|
457
|
-
partnerId: '1',
|
458
|
-
registeredCountry: request === null || request === void 0 ? void 0 : request.countryCode,
|
459
|
-
merchantName: request === null || request === void 0 || (_request$total = request.total) === null || _request$total === void 0 ? void 0 : _request$total.label
|
460
|
-
},
|
461
|
-
paymentAmount: {
|
462
|
-
currency: request === null || request === void 0 ? void 0 : request.currencyCode,
|
463
|
-
value: request === null || request === void 0 || (_request$total2 = request.total) === null || _request$total2 === void 0 ? void 0 : _request$total2.amount
|
420
|
+
}
|
421
|
+
case 13:
|
422
|
+
case "end":
|
423
|
+
return _context3.stop();
|
464
424
|
}
|
465
|
-
}
|
466
|
-
};
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
// this.logger.logInfo({
|
473
|
-
// title: 'sdk_event_apiSubmit',
|
474
|
-
// });
|
475
|
-
// const actionName = this.getBusActionNames()?.submit;
|
476
|
-
// if (actionName && BusManager.isSubscribed(actionName)) {
|
477
|
-
// // 执行出错了,在通用拦截器返回
|
478
|
-
// BusManager.publishForResult(
|
479
|
-
// new BusMessage(
|
480
|
-
// actionName,
|
481
|
-
// JSON.stringify({
|
482
|
-
// appendParams: this._appendParams,
|
483
|
-
// options: this.originOptions,
|
484
|
-
// data: data,
|
485
|
-
// }),
|
486
|
-
// ),
|
487
|
-
// ).then((busMessage) => {
|
488
|
-
// resolve(busMessage?.getJSONObject());
|
489
|
-
// });
|
490
|
-
// } else {
|
491
|
-
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
492
|
-
// // this._eventCenter.once(eventCallbackId, (_data: any) => {
|
493
|
-
// // resolve(_data);
|
494
|
-
// // });
|
495
|
-
// // this._componentApp.dispatchToApp({ context: { event: 'submitPay', eventCallbackId, data } });
|
496
|
-
// }
|
497
|
-
// } catch (error) {
|
498
|
-
// reject(error);
|
499
|
-
// }
|
500
|
-
// });
|
501
|
-
}
|
425
|
+
}, _callee3, this);
|
426
|
+
}));
|
427
|
+
function applePaySubmit(_x) {
|
428
|
+
return _applePaySubmit.apply(this, arguments);
|
429
|
+
}
|
430
|
+
return applePaySubmit;
|
431
|
+
}())
|
502
432
|
}]);
|
503
433
|
return AMSCheckoutPage;
|
504
434
|
}(CoreInstance);
|