@alipay/ams-checkout 0.0.1737621505-dev.2 → 0.0.1738831627-dev.4
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/core/component/element/index.d.ts +4 -5
- package/esm/core/component/element/index.js +103 -166
- package/esm/core/component/element/type.d.ts +164 -7
- package/esm/core/component/element/type.js +45 -1
- package/esm/plugin/component/channel.d.ts +26 -20
- package/esm/plugin/component/channel.js +427 -390
- package/esm/plugin/component/index.d.ts +1 -0
- package/esm/plugin/component/index.js +33 -38
- package/esm/service/index.d.ts +0 -1
- package/esm/service/index.js +0 -2
- package/esm/types/index.d.ts +2 -120
- package/esm/types/index.js +0 -35
- package/esm/util/index.d.ts +1 -2
- package/esm/util/index.js +1 -16
- package/esm/util/spm-map.d.ts +3 -0
- package/esm/util/spm-map.js +3 -0
- package/esm/util/versionCompare.d.ts +1 -1
- package/package.json +1 -1
- package/esm/service/element.d.ts +0 -4
- package/esm/service/element.js +0 -51
@@ -1,4 +1,6 @@
|
|
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; }
|
2
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; }
|
3
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); } }
|
4
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); }); }; }
|
@@ -12,8 +14,7 @@ import { BusManager, BusMessage } from "../../core/bus";
|
|
12
14
|
import { SecuritySDKActionEnum } from "../../core/bus/interface";
|
13
15
|
import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
14
16
|
import { EnvironmentEnum } from "../../types";
|
15
|
-
import { device
|
16
|
-
import { APPLE_PAY_RECURRING_VERSION, APPLE_PAY_VERSION } from "../applepay/interface";
|
17
|
+
import { device } from "../../util";
|
17
18
|
var APPLEPAYERRORENUM = /*#__PURE__*/function (APPLEPAYERRORENUM) {
|
18
19
|
APPLEPAYERRORENUM["APPLE_PAY_MISSING_DATA"] = "APPLE_PAY_MISSING_DATA";
|
19
20
|
APPLEPAYERRORENUM["APPLE_PAY_NOT_SUPPORTED"] = "APPLE_PAY_NOT_SUPPORTED";
|
@@ -116,331 +117,418 @@ export var handleGooglePay = function handleGooglePay(data) {
|
|
116
117
|
};
|
117
118
|
});
|
118
119
|
};
|
119
|
-
export var
|
120
|
-
function
|
121
|
-
var
|
122
|
-
|
123
|
-
|
124
|
-
|
120
|
+
export var ApplePayService = /*#__PURE__*/function () {
|
121
|
+
function ApplePayService(_ref) {
|
122
|
+
var _paymentMethod$paymen;
|
123
|
+
var sessionData = _ref.sessionData,
|
124
|
+
paymentSessionMetaData = _ref.paymentSessionMetaData,
|
125
|
+
paymentMethod = _ref.paymentMethod,
|
126
|
+
logger = _ref.logger,
|
127
|
+
dispatchToApp = _ref.dispatchToApp;
|
128
|
+
_classCallCheck(this, ApplePayService);
|
125
129
|
_defineProperty(this, "APPLESDKURL", 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js');
|
126
|
-
_defineProperty(this, "
|
130
|
+
_defineProperty(this, "applePaySession", void 0);
|
127
131
|
_defineProperty(this, "paymentSessionData", void 0);
|
128
|
-
_defineProperty(this, "
|
132
|
+
_defineProperty(this, "sessionResult", void 0);
|
129
133
|
/**
|
130
134
|
* @description 支付状态,pending:支付中,normal:正常
|
131
135
|
*/
|
132
136
|
_defineProperty(this, "paymentStatus", void 0);
|
137
|
+
/**
|
138
|
+
* @description paymentRequest
|
139
|
+
*/
|
140
|
+
_defineProperty(this, "paymentRequest", void 0);
|
133
141
|
_defineProperty(this, "logger", void 0);
|
134
|
-
this
|
135
|
-
this
|
142
|
+
_defineProperty(this, "dispatchToApp", void 0);
|
143
|
+
_defineProperty(this, "paymentMethod", void 0);
|
144
|
+
this.paymentMethod = paymentMethod;
|
145
|
+
this.dispatchToApp = dispatchToApp;
|
136
146
|
this.logger = logger;
|
147
|
+
this.paymentSessionData = sessionData;
|
148
|
+
this.sessionResult = paymentSessionMetaData;
|
149
|
+
this.paymentRequest = paymentMethod === null || paymentMethod === void 0 || (_paymentMethod$paymen = paymentMethod.paymentMethodDetail) === null || _paymentMethod$paymen === void 0 || (_paymentMethod$paymen = _paymentMethod$paymen.applePayProps) === null || _paymentMethod$paymen === void 0 ? void 0 : _paymentMethod$paymen.paymentRequest;
|
137
150
|
}
|
138
|
-
_createClass(
|
151
|
+
_createClass(ApplePayService, [{
|
139
152
|
key: "startPay",
|
140
153
|
value: function () {
|
141
|
-
var _startPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
142
|
-
|
143
|
-
|
154
|
+
var _startPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
155
|
+
var _this = this;
|
156
|
+
var _this$logger2, _this$logger;
|
157
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
158
|
+
while (1) switch (_context2.prev = _context2.next) {
|
144
159
|
case 0:
|
145
|
-
|
146
|
-
|
147
|
-
|
160
|
+
_context2.prev = 0;
|
161
|
+
if (!(this.paymentStatus === PAYMENT_STATUS.PENDING)) {
|
162
|
+
_context2.next = 3;
|
163
|
+
break;
|
164
|
+
}
|
165
|
+
return _context2.abrupt("return");
|
148
166
|
case 3:
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
167
|
+
if (this.isRequiredParameters) {
|
168
|
+
_context2.next = 7;
|
169
|
+
break;
|
170
|
+
}
|
171
|
+
(_this$logger = this.logger) === null || _this$logger === void 0 || _this$logger.logError({
|
172
|
+
code: 'a3753.b103030.c386485.d507448'
|
173
|
+
}, {
|
174
|
+
paymentRequest: JSON.stringify(this.paymentRequest)
|
175
|
+
});
|
176
|
+
this.paymentStatus = PAYMENT_STATUS.NORMAL;
|
177
|
+
return _context2.abrupt("return", Promise.reject({
|
178
|
+
errorCode: APPLEPAYERRORENUM.APPLE_PAY_MISSING_DATA
|
179
|
+
}));
|
180
|
+
case 7:
|
181
|
+
(_this$logger2 = this.logger) === null || _this$logger2 === void 0 || _this$logger2.logInfo({
|
182
|
+
code: 'a3753.b103030.c386485.d507459'
|
183
|
+
}, {
|
184
|
+
paymentRequest: JSON.stringify(this.paymentRequest)
|
185
|
+
});
|
186
|
+
_context2.next = 10;
|
187
|
+
return this.initApplePaySession();
|
188
|
+
case 10:
|
189
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
190
|
+
_this.applePaySession.onvalidatemerchant = /*#__PURE__*/function () {
|
191
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
192
|
+
var requestParams, res, merchantSession, _this$logger3, _this$logger4;
|
193
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
194
|
+
while (1) switch (_context.prev = _context.next) {
|
195
|
+
case 0:
|
196
|
+
_context.prev = 0;
|
197
|
+
requestParams = {
|
198
|
+
validateUrl: event === null || event === void 0 ? void 0 : event.validationURL,
|
199
|
+
paymentSessionData: _this.paymentSessionData
|
200
|
+
};
|
201
|
+
_context.t0 = getApplePayPaymentSession;
|
202
|
+
_context.t1 = _this.paymentSessionData;
|
203
|
+
_context.t2 = requestParams;
|
204
|
+
_context.t3 = EnvironmentEnum.prod;
|
205
|
+
_context.next = 8;
|
206
|
+
return _this.getDeviceId();
|
207
|
+
case 8:
|
208
|
+
_context.t4 = _context.sent;
|
209
|
+
_context.t5 = {
|
210
|
+
deviceId: _context.t4
|
211
|
+
};
|
212
|
+
_context.t6 = {
|
213
|
+
env: _context.t3,
|
214
|
+
envInfo: _context.t5
|
215
|
+
};
|
216
|
+
_context.t7 = _this.logger;
|
217
|
+
_context.next = 14;
|
218
|
+
return (0, _context.t0)(_context.t1, _context.t2, _context.t6, _context.t7);
|
219
|
+
case 14:
|
220
|
+
res = _context.sent;
|
221
|
+
if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
|
222
|
+
merchantSession = JSON.parse(res.merchantSessionObject);
|
223
|
+
_this.applePaySession.completeMerchantValidation(merchantSession);
|
224
|
+
} else {
|
225
|
+
(_this$logger3 = _this.logger) === null || _this$logger3 === void 0 || _this$logger3.logError({
|
226
|
+
code: 'a3753.b103030.c386485.d507483'
|
227
|
+
});
|
228
|
+
_this.abortPaySession();
|
229
|
+
reject({
|
230
|
+
errorCode: APPLEPAYERRORENUM.APPLE_PAY_PAYMENT_SESSION_REQUEST_FAILED
|
231
|
+
});
|
232
|
+
}
|
233
|
+
_context.next = 23;
|
234
|
+
break;
|
235
|
+
case 18:
|
236
|
+
_context.prev = 18;
|
237
|
+
_context.t8 = _context["catch"](0);
|
238
|
+
(_this$logger4 = _this.logger) === null || _this$logger4 === void 0 || _this$logger4.logError({
|
239
|
+
code: 'a3753.b103030.c386485.d507483'
|
240
|
+
});
|
241
|
+
_this.abortPaySession();
|
242
|
+
reject({
|
243
|
+
errorCode: APPLEPAYERRORENUM.APPLE_PAY_PAYMENT_SESSION_REQUEST_FAILED
|
244
|
+
});
|
245
|
+
case 23:
|
246
|
+
case "end":
|
247
|
+
return _context.stop();
|
248
|
+
}
|
249
|
+
}, _callee, null, [[0, 18]]);
|
250
|
+
}));
|
251
|
+
return function (_x) {
|
252
|
+
return _ref2.apply(this, arguments);
|
253
|
+
};
|
254
|
+
}();
|
255
|
+
_this.applePaySession.onpaymentauthorized = function (event) {
|
256
|
+
var exception = function exception() {
|
257
|
+
var _this$applePaySession, _this$applePaySession2;
|
258
|
+
(_this$applePaySession = _this.applePaySession) === null || _this$applePaySession === void 0 || (_this$applePaySession2 = _this$applePaySession.completePayment) === null || _this$applePaySession2 === void 0 || _this$applePaySession2.call(_this$applePaySession, window.ApplePaySession.STATUS_FAILURE);
|
259
|
+
_this.abortPaySession();
|
225
260
|
reject({
|
226
|
-
errorCode: APPLEPAYERRORENUM.
|
261
|
+
errorCode: APPLEPAYERRORENUM.APPLE_PAY_TOKEN_ERROR
|
227
262
|
});
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
};
|
237
|
-
}();
|
238
|
-
_this.session.onpaymentauthorized = /*#__PURE__*/function () {
|
239
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(event) {
|
240
|
-
var exception, _event$payment, token, billingContact, shippingContact, _this$parseData, obj, _this$parseData$payme, requiredBillingContactFields, requiredShippingContactFields, res, _this$logger3;
|
241
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
242
|
-
while (1) switch (_context3.prev = _context3.next) {
|
243
|
-
case 0:
|
244
|
-
exception = function exception() {
|
245
|
-
var _this$session, _this$session$complet;
|
246
|
-
(_this$session = _this.session) === null || _this$session === void 0 || (_this$session$complet = _this$session.completePayment) === null || _this$session$complet === void 0 || _this$session$complet.call(_this$session, window.ApplePaySession.STATUS_FAILURE);
|
247
|
-
_this.abortSession();
|
248
|
-
return Promise.reject({
|
249
|
-
errorCode: APPLEPAYERRORENUM.APPLE_PAY_TOKEN_ERROR
|
250
|
-
});
|
251
|
-
};
|
252
|
-
_event$payment = event === null || event === void 0 ? void 0 : event.payment, token = _event$payment.token, billingContact = _event$payment.billingContact, shippingContact = _event$payment.shippingContact;
|
253
|
-
if (!token) {
|
254
|
-
_context3.next = 14;
|
255
|
-
break;
|
256
|
-
}
|
257
|
-
obj = {
|
263
|
+
};
|
264
|
+
var _event$payment = event === null || event === void 0 ? void 0 : event.payment,
|
265
|
+
token = _event$payment.token,
|
266
|
+
billingContact = _event$payment.billingContact,
|
267
|
+
shippingContact = _event$payment.shippingContact;
|
268
|
+
if (token) {
|
269
|
+
var _this$paymentRequest, _this$paymentRequest2;
|
270
|
+
var obj = {
|
258
271
|
instPaymentToken: JSON.stringify(token)
|
259
272
|
};
|
260
|
-
|
261
|
-
if (!isEmpty(requiredBillingContactFields) && billingContact) {
|
273
|
+
if ((_this$paymentRequest = _this.paymentRequest) !== null && _this$paymentRequest !== void 0 && _this$paymentRequest.requiredBillingContactFields && billingContact) {
|
262
274
|
obj['applePayBillingContact'] = JSON.stringify(billingContact);
|
263
275
|
}
|
264
|
-
if (
|
276
|
+
if ((_this$paymentRequest2 = _this.paymentRequest) !== null && _this$paymentRequest2 !== void 0 && _this$paymentRequest2.requiredShippingContactFields && shippingContact) {
|
265
277
|
obj['applePayShippingContact'] = JSON.stringify(shippingContact);
|
266
278
|
}
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
case 14:
|
276
|
-
(_this$logger3 = _this.logger) === null || _this$logger3 === void 0 || _this$logger3.logError({
|
277
|
-
title: 'a3753.b103030.c386485.d507486'
|
279
|
+
_this.submitPay(obj).then(function (res) {
|
280
|
+
_this.setApplePayStatus(res);
|
281
|
+
resolve(res);
|
282
|
+
});
|
283
|
+
} else {
|
284
|
+
var _this$logger5;
|
285
|
+
(_this$logger5 = _this.logger) === null || _this$logger5 === void 0 || _this$logger5.logError({
|
286
|
+
code: 'a3753.b103030.c386485.d507486'
|
278
287
|
});
|
279
288
|
exception();
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
289
|
+
}
|
290
|
+
};
|
291
|
+
_this.applePaySession.oncancel = function () {
|
292
|
+
if (_this.paymentStatus === PAYMENT_STATUS.PENDING) {
|
293
|
+
var _this$logger6;
|
294
|
+
(_this$logger6 = _this.logger) === null || _this$logger6 === void 0 || _this$logger6.logError({
|
295
|
+
code: 'a3753.b103030.c386485.d507497'
|
296
|
+
});
|
297
|
+
} else {
|
298
|
+
var _this$logger7;
|
299
|
+
(_this$logger7 = _this.logger) === null || _this$logger7 === void 0 || _this$logger7.logInfo({
|
300
|
+
code: 'a3753.b103030.c386485.d507498'
|
301
|
+
});
|
302
|
+
}
|
303
|
+
_this.abortPaySession();
|
304
|
+
reject({
|
305
|
+
errorCode: APPLEPAYERRORENUM.APPLE_PAY_CANCEL
|
306
|
+
});
|
307
|
+
};
|
308
|
+
_this.applePaySession.begin();
|
309
|
+
_this.addEventListener(reject);
|
310
|
+
}));
|
311
|
+
case 13:
|
312
|
+
_context2.prev = 13;
|
313
|
+
_context2.t0 = _context2["catch"](0);
|
314
|
+
return _context2.abrupt("return", Promise.reject(_context2.t0));
|
315
|
+
case 16:
|
316
|
+
case "end":
|
317
|
+
return _context2.stop();
|
318
|
+
}
|
319
|
+
}, _callee2, this, [[0, 13]]);
|
320
|
+
}));
|
321
|
+
function startPay() {
|
322
|
+
return _startPay.apply(this, arguments);
|
323
|
+
}
|
324
|
+
return startPay;
|
325
|
+
}()
|
326
|
+
}, {
|
327
|
+
key: "setApplePayStatus",
|
328
|
+
value: function setApplePayStatus(result) {
|
329
|
+
var _this$applePaySession3, _this$applePaySession4;
|
330
|
+
var payStatus = {
|
331
|
+
success: window.ApplePaySession.STATUS_SUCCESS,
|
332
|
+
fail: window.ApplePaySession.STATUS_FAILURE
|
333
|
+
};
|
334
|
+
var status;
|
335
|
+
if (result !== null && result !== void 0 && result.success || (result === null || result === void 0 ? void 0 : result.errorStatus) === 'U') {
|
336
|
+
status = 'success';
|
337
|
+
} else {
|
338
|
+
status = 'fail';
|
339
|
+
}
|
340
|
+
this.paymentStatus = PAYMENT_STATUS.NORMAL;
|
341
|
+
(_this$applePaySession3 = this.applePaySession) === null || _this$applePaySession3 === void 0 || (_this$applePaySession4 = _this$applePaySession3.completePayment) === null || _this$applePaySession4 === void 0 || _this$applePaySession4.call(_this$applePaySession3, payStatus[status]);
|
313
342
|
}
|
314
343
|
}, {
|
315
344
|
key: "submitPay",
|
316
345
|
value: function () {
|
317
|
-
var _submitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
318
|
-
var _this$
|
319
|
-
return _regeneratorRuntime().wrap(function
|
320
|
-
while (1) switch (
|
346
|
+
var _submitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
347
|
+
var _this$sessionResult, _this$paymentMethod, _this$paymentMethod2, _this$paymentMethod3;
|
348
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
349
|
+
while (1) switch (_context3.prev = _context3.next) {
|
321
350
|
case 0:
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
paymentSessionConfig: (_this$
|
351
|
+
_context3.prev = 0;
|
352
|
+
_context3.t0 = submitPayInfo;
|
353
|
+
_context3.t1 = {
|
354
|
+
paymentSessionConfig: (_this$sessionResult = this.sessionResult) === null || _this$sessionResult === void 0 ? void 0 : _this$sessionResult.paymentSessionConfig,
|
326
355
|
paymentSessionData: this.paymentSessionData,
|
327
356
|
paymentFactors: params,
|
328
357
|
paymentMethod: {
|
329
|
-
paymentMethodType:
|
358
|
+
paymentMethodType: (_this$paymentMethod = this.paymentMethod) === null || _this$paymentMethod === void 0 ? void 0 : _this$paymentMethod.paymentMethodType,
|
359
|
+
category: (_this$paymentMethod2 = this.paymentMethod) === null || _this$paymentMethod2 === void 0 ? void 0 : _this$paymentMethod2.category,
|
360
|
+
paymentMethodDetail: (_this$paymentMethod3 = this.paymentMethod) === null || _this$paymentMethod3 === void 0 ? void 0 : _this$paymentMethod3.paymentMethodDetail
|
330
361
|
}
|
331
362
|
};
|
332
|
-
|
333
|
-
|
363
|
+
_context3.t2 = EnvironmentEnum.prod;
|
364
|
+
_context3.next = 6;
|
334
365
|
return this.getDeviceId();
|
335
366
|
case 6:
|
336
|
-
|
337
|
-
|
338
|
-
deviceId:
|
367
|
+
_context3.t3 = _context3.sent;
|
368
|
+
_context3.t4 = {
|
369
|
+
deviceId: _context3.t3
|
339
370
|
};
|
340
|
-
|
341
|
-
env:
|
342
|
-
envInfo:
|
371
|
+
_context3.t5 = {
|
372
|
+
env: _context3.t2,
|
373
|
+
envInfo: _context3.t4
|
343
374
|
};
|
344
|
-
|
345
|
-
|
346
|
-
return (0,
|
375
|
+
_context3.t6 = this.logger;
|
376
|
+
_context3.next = 12;
|
377
|
+
return (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6);
|
347
378
|
case 12:
|
348
|
-
return
|
379
|
+
return _context3.abrupt("return", _context3.sent);
|
349
380
|
case 15:
|
350
|
-
|
351
|
-
|
381
|
+
_context3.prev = 15;
|
382
|
+
_context3.t7 = _context3["catch"](0);
|
352
383
|
case 17:
|
353
384
|
case "end":
|
354
|
-
return
|
385
|
+
return _context3.stop();
|
355
386
|
}
|
356
|
-
},
|
387
|
+
}, _callee3, this, [[0, 15]]);
|
357
388
|
}));
|
358
|
-
function submitPay(
|
389
|
+
function submitPay(_x2) {
|
359
390
|
return _submitPay.apply(this, arguments);
|
360
391
|
}
|
361
392
|
return submitPay;
|
362
393
|
}()
|
363
394
|
}, {
|
364
|
-
key: "
|
365
|
-
value: function
|
366
|
-
var
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
395
|
+
key: "submit",
|
396
|
+
value: function () {
|
397
|
+
var _submit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
398
|
+
var result;
|
399
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
400
|
+
while (1) switch (_context4.prev = _context4.next) {
|
401
|
+
case 0:
|
402
|
+
_context4.prev = 0;
|
403
|
+
_context4.next = 3;
|
404
|
+
return this.startPay();
|
405
|
+
case 3:
|
406
|
+
result = _context4.sent;
|
407
|
+
this.dispatchToApp({
|
408
|
+
context: {
|
409
|
+
event: 'getApplePayToken',
|
410
|
+
data: {
|
411
|
+
success: true,
|
412
|
+
result: result
|
413
|
+
}
|
414
|
+
}
|
415
|
+
});
|
416
|
+
_context4.next = 10;
|
417
|
+
break;
|
418
|
+
case 7:
|
419
|
+
_context4.prev = 7;
|
420
|
+
_context4.t0 = _context4["catch"](0);
|
421
|
+
this.dispatchToApp({
|
422
|
+
context: {
|
423
|
+
event: 'getApplePayToken',
|
424
|
+
data: {
|
425
|
+
success: false,
|
426
|
+
result: _context4.t0
|
427
|
+
}
|
428
|
+
}
|
429
|
+
});
|
430
|
+
case 10:
|
431
|
+
case "end":
|
432
|
+
return _context4.stop();
|
433
|
+
}
|
434
|
+
}, _callee4, this, [[0, 7]]);
|
435
|
+
}));
|
436
|
+
function submit() {
|
437
|
+
return _submit.apply(this, arguments);
|
376
438
|
}
|
377
|
-
|
378
|
-
|
379
|
-
}
|
439
|
+
return submit;
|
440
|
+
}()
|
380
441
|
}, {
|
381
|
-
key: "
|
442
|
+
key: "getDeviceId",
|
382
443
|
value: function () {
|
383
|
-
var
|
384
|
-
var
|
444
|
+
var _getDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
445
|
+
var _yield$BusManager$pub, _this$sessionResult2;
|
385
446
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
386
447
|
while (1) switch (_context5.prev = _context5.next) {
|
387
448
|
case 0:
|
388
|
-
_context5.
|
389
|
-
|
390
|
-
|
449
|
+
_context5.next = 2;
|
450
|
+
return BusManager.publishForResult(new BusMessage(SecuritySDKActionEnum.getSecurityDeviceId, JSON.stringify({
|
451
|
+
deviceIdParameter: {
|
452
|
+
productScene: (_this$sessionResult2 = this.sessionResult) === null || _this$sessionResult2 === void 0 || (_this$sessionResult2 = _this$sessionResult2.paymentSessionConfig) === null || _this$sessionResult2 === void 0 ? void 0 : _this$sessionResult2.productScene
|
453
|
+
}
|
454
|
+
})), {
|
455
|
+
fallback: ''
|
456
|
+
});
|
457
|
+
case 2:
|
458
|
+
_context5.t1 = _yield$BusManager$pub = _context5.sent;
|
459
|
+
_context5.t0 = _context5.t1 === null;
|
460
|
+
if (_context5.t0) {
|
461
|
+
_context5.next = 6;
|
391
462
|
break;
|
392
463
|
}
|
393
|
-
|
394
|
-
case
|
395
|
-
if (
|
396
|
-
_context5.next =
|
464
|
+
_context5.t0 = _yield$BusManager$pub === void 0;
|
465
|
+
case 6:
|
466
|
+
if (!_context5.t0) {
|
467
|
+
_context5.next = 10;
|
397
468
|
break;
|
398
469
|
}
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
this.paymentStatus = PAYMENT_STATUS.NORMAL;
|
403
|
-
return _context5.abrupt("return", Promise.reject({
|
404
|
-
errorCode: APPLEPAYERRORENUM.APPLE_PAY_MISSING_DATA
|
405
|
-
}));
|
406
|
-
case 7:
|
407
|
-
(_this$logger7 = this.logger) === null || _this$logger7 === void 0 || _this$logger7.logInfo({
|
408
|
-
title: 'a3753.b103030.c386485.d507459'
|
409
|
-
});
|
410
|
-
_context5.next = 10;
|
411
|
-
return this.loadApplePaySdk();
|
470
|
+
_context5.t2 = void 0;
|
471
|
+
_context5.next = 11;
|
472
|
+
break;
|
412
473
|
case 10:
|
474
|
+
_context5.t2 = _yield$BusManager$pub.getJSONObject();
|
475
|
+
case 11:
|
476
|
+
return _context5.abrupt("return", _context5.t2);
|
477
|
+
case 12:
|
478
|
+
case "end":
|
479
|
+
return _context5.stop();
|
480
|
+
}
|
481
|
+
}, _callee5, this);
|
482
|
+
}));
|
483
|
+
function getDeviceId() {
|
484
|
+
return _getDeviceId.apply(this, arguments);
|
485
|
+
}
|
486
|
+
return getDeviceId;
|
487
|
+
}()
|
488
|
+
}, {
|
489
|
+
key: "initApplePaySession",
|
490
|
+
value: function () {
|
491
|
+
var _initApplePaySession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
492
|
+
var version, _this$logger8;
|
493
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
494
|
+
while (1) switch (_context6.prev = _context6.next) {
|
495
|
+
case 0:
|
496
|
+
_context6.prev = 0;
|
497
|
+
_context6.next = 3;
|
498
|
+
return this.loadApplePaySdk();
|
499
|
+
case 3:
|
413
500
|
if ('ApplePaySession' in window) {
|
414
|
-
|
501
|
+
_context6.next = 5;
|
415
502
|
break;
|
416
503
|
}
|
417
504
|
throw new Error('Apple Pay not supported');
|
418
|
-
case
|
419
|
-
|
420
|
-
version = recurringInfo ? APPLE_PAY_RECURRING_VERSION : APPLE_PAY_VERSION;
|
505
|
+
case 5:
|
506
|
+
version = this.paymentRequest.version;
|
421
507
|
if (this.isCanMakePayments(version)) {
|
422
|
-
|
508
|
+
_context6.next = 8;
|
423
509
|
break;
|
424
510
|
}
|
425
511
|
throw new Error('Apple Pay not supported');
|
426
|
-
case
|
427
|
-
this.
|
428
|
-
|
512
|
+
case 8:
|
513
|
+
this.applePaySession = new window.ApplePaySession(version, this.initSessionParams);
|
514
|
+
_context6.next = 15;
|
429
515
|
break;
|
430
|
-
case
|
431
|
-
|
432
|
-
|
516
|
+
case 11:
|
517
|
+
_context6.prev = 11;
|
518
|
+
_context6.t0 = _context6["catch"](0);
|
433
519
|
(_this$logger8 = this.logger) === null || _this$logger8 === void 0 || _this$logger8.logError({
|
434
|
-
|
520
|
+
code: 'a3753.b103030.c386485.d507471'
|
521
|
+
}, {
|
522
|
+
paymentRequest: JSON.stringify(this.paymentRequest)
|
435
523
|
});
|
436
|
-
return
|
524
|
+
return _context6.abrupt("return", Promise.reject({
|
437
525
|
errorCode: APPLEPAYERRORENUM.APPLE_PAY_NOT_SUPPORTED
|
438
526
|
}));
|
439
|
-
case
|
527
|
+
case 15:
|
440
528
|
case "end":
|
441
|
-
return
|
529
|
+
return _context6.stop();
|
442
530
|
}
|
443
|
-
},
|
531
|
+
}, _callee6, this, [[0, 11]]);
|
444
532
|
}));
|
445
533
|
function initApplePaySession() {
|
446
534
|
return _initApplePaySession.apply(this, arguments);
|
@@ -448,41 +536,93 @@ export var ApplePaySdk = /*#__PURE__*/function () {
|
|
448
536
|
return initApplePaySession;
|
449
537
|
}()
|
450
538
|
}, {
|
451
|
-
key: "
|
452
|
-
value: function
|
539
|
+
key: "isCanMakePayments",
|
540
|
+
value: function isCanMakePayments() {
|
541
|
+
var _window$ApplePaySessi, _window$ApplePaySessi2;
|
542
|
+
var version = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;
|
543
|
+
return ((_window$ApplePaySessi = window.ApplePaySession) === null || _window$ApplePaySessi === void 0 ? void 0 : _window$ApplePaySessi.canMakePayments()) && ((_window$ApplePaySessi2 = window.ApplePaySession) === null || _window$ApplePaySessi2 === void 0 ? void 0 : _window$ApplePaySessi2.supportsVersion(version));
|
544
|
+
}
|
545
|
+
}, {
|
546
|
+
key: "loadApplePaySdk",
|
547
|
+
value: function loadApplePaySdk() {
|
548
|
+
var _this2 = this;
|
549
|
+
if (device.Android) {
|
550
|
+
return Promise.reject('APPLE_PAY_NOT_SUPPORTED');
|
551
|
+
}
|
552
|
+
// 如果支持或者已经加载sdk直接返回
|
553
|
+
if (this.checkScriptIsLoaded || this.isCanMakePayments()) {
|
554
|
+
return Promise.resolve(true);
|
555
|
+
}
|
556
|
+
return new Promise(function (resolve, reject) {
|
557
|
+
var script = document.createElement('script');
|
558
|
+
script.src = _this2.APPLESDKURL;
|
559
|
+
script.onload = function () {
|
560
|
+
resolve(true);
|
561
|
+
};
|
562
|
+
script.onerror = function () {
|
563
|
+
reject(false);
|
564
|
+
};
|
565
|
+
document.body.appendChild(script);
|
566
|
+
});
|
567
|
+
}
|
568
|
+
}, {
|
569
|
+
key: "abortPaySession",
|
570
|
+
value: function abortPaySession() {
|
453
571
|
try {
|
454
|
-
var _this$
|
572
|
+
var _this$applePaySession5, _this$applePaySession6;
|
455
573
|
this.paymentStatus = PAYMENT_STATUS.NORMAL;
|
456
|
-
this.
|
574
|
+
this.applePaySession && ((_this$applePaySession5 = (_this$applePaySession6 = this.applePaySession).abort) === null || _this$applePaySession5 === void 0 ? void 0 : _this$applePaySession5.call(_this$applePaySession6));
|
457
575
|
} catch (e) {
|
458
576
|
console.error('abortPaySession error', e);
|
459
|
-
} finally {
|
460
|
-
this.session = null;
|
461
577
|
}
|
462
578
|
}
|
579
|
+
}, {
|
580
|
+
key: "addEventListener",
|
581
|
+
value: function addEventListener(reject) {
|
582
|
+
var _this3 = this;
|
583
|
+
var appleModal = document.querySelector('apple-pay-modal');
|
584
|
+
var shadowRoot = appleModal === null || appleModal === void 0 ? void 0 : appleModal.shadowRoot;
|
585
|
+
var closeButton = (shadowRoot === null || shadowRoot === void 0 ? void 0 : shadowRoot.querySelector('.modal-close-button')) || null;
|
586
|
+
var callFn = function callFn() {
|
587
|
+
var _this3$logger;
|
588
|
+
(_this3$logger = _this3.logger) === null || _this3$logger === void 0 || _this3$logger.logInfo({
|
589
|
+
code: 'a3753.b103030.c386485.d507470'
|
590
|
+
});
|
591
|
+
_this3.abortPaySession();
|
592
|
+
closeButton === null || closeButton === void 0 || closeButton.removeEventListener('click', callFn);
|
593
|
+
return reject === null || reject === void 0 ? void 0 : reject({
|
594
|
+
errorCode: APPLEPAYERRORENUM.APPLE_PAY_CANCEL
|
595
|
+
});
|
596
|
+
};
|
597
|
+
closeButton === null || closeButton === void 0 || closeButton.addEventListener('click', callFn, {
|
598
|
+
once: true
|
599
|
+
});
|
600
|
+
}
|
463
601
|
}, {
|
464
602
|
key: "initSessionParams",
|
465
603
|
get: function get() {
|
466
|
-
var _this$
|
467
|
-
var
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
604
|
+
var _this$sessionResult3;
|
605
|
+
var _this$paymentRequest3 = this.paymentRequest,
|
606
|
+
supportedNetworks = _this$paymentRequest3.supportedNetworks,
|
607
|
+
requiredBillingContactFields = _this$paymentRequest3.requiredBillingContactFields,
|
608
|
+
requiredShippingContactFields = _this$paymentRequest3.requiredShippingContactFields,
|
609
|
+
merchantCapabilities = _this$paymentRequest3.merchantCapabilities;
|
610
|
+
var _ref3 = ((_this$sessionResult3 = this.sessionResult) === null || _this$sessionResult3 === void 0 ? void 0 : _this$sessionResult3.paymentSessionFactor) || {},
|
611
|
+
merchantInfo = _ref3.merchantInfo,
|
612
|
+
order = _ref3.order,
|
613
|
+
paymentAmount = _ref3.paymentAmount,
|
614
|
+
recurringInfo = _ref3.recurringInfo;
|
615
|
+
var request = _objectSpread(_objectSpread({
|
474
616
|
countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
|
475
617
|
currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
|
476
|
-
merchantCapabilities:
|
477
|
-
supportedNetworks:
|
618
|
+
merchantCapabilities: merchantCapabilities,
|
619
|
+
supportedNetworks: supportedNetworks,
|
478
620
|
total: {
|
479
621
|
label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
|
480
622
|
type: 'final',
|
481
623
|
amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
|
482
|
-
}
|
483
|
-
|
484
|
-
requiredShippingContactFields: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.requiredShippingContactFields
|
485
|
-
};
|
624
|
+
}
|
625
|
+
}, requiredBillingContactFields ? requiredBillingContactFields : null), requiredShippingContactFields ? requiredShippingContactFields : null);
|
486
626
|
if (recurringInfo) {
|
487
627
|
var _recurringInfo$interv;
|
488
628
|
if (!(order !== null && order !== void 0 && order.orderDescription) || !(recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.managementURL)) {
|
@@ -514,127 +654,24 @@ export var ApplePaySdk = /*#__PURE__*/function () {
|
|
514
654
|
}, {
|
515
655
|
key: "isRequiredParameters",
|
516
656
|
get: function get() {
|
517
|
-
|
518
|
-
var
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
var
|
528
|
-
|
529
|
-
return ((_window$ApplePaySessi = window.ApplePaySession) === null || _window$ApplePaySessi === void 0 ? void 0 : _window$ApplePaySessi.canMakePayments()) && ((_window$ApplePaySessi2 = window.ApplePaySession) === null || _window$ApplePaySessi2 === void 0 ? void 0 : _window$ApplePaySessi2.supportsVersion(version));
|
530
|
-
}
|
531
|
-
}, {
|
532
|
-
key: "loadApplePaySdk",
|
533
|
-
value: function loadApplePaySdk() {
|
534
|
-
var _this2 = this;
|
535
|
-
if (device.Android) {
|
536
|
-
return Promise.reject('APPLE_PAY_NOT_SUPPORTED');
|
537
|
-
}
|
538
|
-
// 如果支持或者已经加载sdk直接返回
|
539
|
-
if (this.checkScriptIsLoaded || this.isCanMakePayments()) {
|
540
|
-
return Promise.resolve(true);
|
541
|
-
}
|
542
|
-
return new Promise(function (resolve, reject) {
|
543
|
-
var script = document.createElement('script');
|
544
|
-
script.src = _this2.APPLESDKURL;
|
545
|
-
script.onload = function () {
|
546
|
-
resolve(true);
|
547
|
-
};
|
548
|
-
script.onerror = function () {
|
549
|
-
reject(false);
|
550
|
-
};
|
551
|
-
document.body.appendChild(script);
|
552
|
-
});
|
657
|
+
if (!this.paymentRequest) return false;
|
658
|
+
var _this$paymentRequest4 = this.paymentRequest,
|
659
|
+
_this$paymentRequest5 = _this$paymentRequest4.supportedNetworks,
|
660
|
+
supportedNetworks = _this$paymentRequest5 === void 0 ? [] : _this$paymentRequest5,
|
661
|
+
_this$paymentRequest6 = _this$paymentRequest4.merchantCapabilities,
|
662
|
+
merchantCapabilities = _this$paymentRequest6 === void 0 ? [] : _this$paymentRequest6,
|
663
|
+
version = _this$paymentRequest4.version;
|
664
|
+
var _ref4 = this.sessionResult || {},
|
665
|
+
paymentSessionFactor = _ref4.paymentSessionFactor;
|
666
|
+
var isSupportedNetworks = Array.isArray(supportedNetworks) && supportedNetworks.length > 0;
|
667
|
+
var isMerchantCapabilities = Array.isArray(merchantCapabilities) && merchantCapabilities.length > 0;
|
668
|
+
return !(!version || !isSupportedNetworks || !(paymentSessionFactor !== null && paymentSessionFactor !== void 0 && paymentSessionFactor.merchantInfo) || !(paymentSessionFactor !== null && paymentSessionFactor !== void 0 && paymentSessionFactor.paymentAmount) || !isMerchantCapabilities);
|
553
669
|
}
|
554
670
|
}, {
|
555
671
|
key: "checkScriptIsLoaded",
|
556
672
|
get: function get() {
|
557
673
|
return !!document.querySelector("script[src=\"".concat(this.APPLESDKURL, "\"]"));
|
558
674
|
}
|
559
|
-
/**
|
560
|
-
* @description 非标方案,sdk目前无法直接监听国内不支持弹窗的关闭操作
|
561
|
-
*/
|
562
|
-
}, {
|
563
|
-
key: "addEventListener",
|
564
|
-
value: function addEventListener(reject) {
|
565
|
-
var _this3 = this;
|
566
|
-
var appleModal = document.querySelector('apple-pay-modal');
|
567
|
-
var shadowRoot = appleModal === null || appleModal === void 0 ? void 0 : appleModal.shadowRoot;
|
568
|
-
var closeButton = (shadowRoot === null || shadowRoot === void 0 ? void 0 : shadowRoot.querySelector('.modal-close-button')) || null;
|
569
|
-
if (!closeButton) {
|
570
|
-
this.logger.logInfo({
|
571
|
-
title: 'a3753.b103030.c386485.d533112'
|
572
|
-
});
|
573
|
-
}
|
574
|
-
var callFn = function callFn() {
|
575
|
-
var _this3$logger;
|
576
|
-
(_this3$logger = _this3.logger) === null || _this3$logger === void 0 || _this3$logger.logInfo({
|
577
|
-
title: 'a3753.b103030.c386485.d507470'
|
578
|
-
});
|
579
|
-
_this3.abortSession();
|
580
|
-
closeButton === null || closeButton === void 0 || closeButton.removeEventListener('click', callFn);
|
581
|
-
reject === null || reject === void 0 || reject();
|
582
|
-
};
|
583
|
-
closeButton === null || closeButton === void 0 || closeButton.addEventListener('click', callFn, {
|
584
|
-
once: true
|
585
|
-
});
|
586
|
-
}
|
587
|
-
}, {
|
588
|
-
key: "getDeviceId",
|
589
|
-
value: function () {
|
590
|
-
var _getDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
591
|
-
var _yield$BusManager$pub, _this$parseData6;
|
592
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
593
|
-
while (1) switch (_context6.prev = _context6.next) {
|
594
|
-
case 0:
|
595
|
-
_context6.next = 2;
|
596
|
-
return BusManager.publishForResult(new BusMessage(SecuritySDKActionEnum.getSecurityDeviceId, JSON.stringify({
|
597
|
-
deviceIdParameter: {
|
598
|
-
productScene: (_this$parseData6 = this.parseData) === null || _this$parseData6 === void 0 || (_this$parseData6 = _this$parseData6.paymentSessionConfig) === null || _this$parseData6 === void 0 ? void 0 : _this$parseData6.productScene
|
599
|
-
}
|
600
|
-
})), {
|
601
|
-
fallback: ''
|
602
|
-
});
|
603
|
-
case 2:
|
604
|
-
_context6.t1 = _yield$BusManager$pub = _context6.sent;
|
605
|
-
_context6.t0 = _context6.t1 === null;
|
606
|
-
if (_context6.t0) {
|
607
|
-
_context6.next = 6;
|
608
|
-
break;
|
609
|
-
}
|
610
|
-
_context6.t0 = _yield$BusManager$pub === void 0;
|
611
|
-
case 6:
|
612
|
-
if (!_context6.t0) {
|
613
|
-
_context6.next = 10;
|
614
|
-
break;
|
615
|
-
}
|
616
|
-
_context6.t2 = void 0;
|
617
|
-
_context6.next = 11;
|
618
|
-
break;
|
619
|
-
case 10:
|
620
|
-
_context6.t2 = _yield$BusManager$pub.getJSONObject();
|
621
|
-
case 11:
|
622
|
-
return _context6.abrupt("return", _context6.t2);
|
623
|
-
case 12:
|
624
|
-
case "end":
|
625
|
-
return _context6.stop();
|
626
|
-
}
|
627
|
-
}, _callee6, this);
|
628
|
-
}));
|
629
|
-
function getDeviceId() {
|
630
|
-
return _getDeviceId.apply(this, arguments);
|
631
|
-
}
|
632
|
-
return getDeviceId;
|
633
|
-
}()
|
634
675
|
}]);
|
635
|
-
return
|
636
|
-
}();
|
637
|
-
export var isSkipRenderPaymentMethod = function isSkipRenderPaymentMethod(parseData) {
|
638
|
-
var _parseData$paymentSes;
|
639
|
-
return (parseData === null || parseData === void 0 ? void 0 : parseData.skipRenderPaymentMethod) && (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionFactor) === null || _parseData$paymentSes === void 0 || (_parseData$paymentSes = _parseData$paymentSes.paymentMethodInfo) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.paymentMethodType) === 'APPLEPAY';
|
640
|
-
};
|
676
|
+
return ApplePayService;
|
677
|
+
}();
|