@alipay/ams-checkout 0.0.1730107332-dev.24 → 0.0.1730107332-dev.26
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/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/core/bus/ability/callback.js +55 -0
- package/esm/core/bus/ability/security.d.ts +10 -0
- package/esm/core/bus/ability/security.js +104 -0
- package/esm/core/bus/ability/tracker.d.ts +9 -0
- package/esm/core/bus/ability/tracker.js +77 -0
- package/esm/core/bus/index.d.ts +125 -0
- package/esm/core/bus/index.js +366 -0
- package/esm/core/bus/interface.d.ts +36 -0
- package/esm/core/bus/interface.js +40 -0
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/core/component/appPreloadProcessing.js +89 -0
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +166 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +531 -0
- package/esm/core/drop-in/index.d.ts +22 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +89 -0
- package/esm/core/instance/index.js +499 -0
- package/esm/foundation/core/index.d.ts +2 -2
- package/esm/foundation/index.d.ts +5 -5
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +2 -2
- package/esm/foundation/product-processor/easysafepay/deps.js +1 -1
- package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -2
- package/esm/foundation/service/api-bus/index.d.ts +2 -2
- package/esm/foundation/service/container/index.d.ts +2 -2
- package/esm/foundation/service/event-center.d.ts +4 -4
- package/esm/foundation/service/event-center.js +10 -10
- package/esm/foundation/service/global-data/index.d.ts +2 -2
- package/esm/foundation/service/index.d.ts +2 -2
- package/esm/foundation/service/log/index.d.ts +2 -2
- package/esm/foundation/service/requester/deps.d.ts +1 -1
- package/esm/foundation/service/requester/requester.d.ts +2 -2
- package/esm/foundation/service/security/index.d.ts +2 -2
- package/esm/foundation/utils/redirect_utils.d.ts +5 -0
- package/esm/foundation/utils/redirect_utils.js +135 -1
- package/esm/foundation/utils/web_app_url_utils.js +1 -1
- package/esm/index.d.ts +27 -2
- package/esm/index.js +131 -6
- package/esm/plugin/applepay/component.d.ts +50 -0
- package/esm/plugin/applepay/component.js +339 -0
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/plugin/applepay/interface.d.ts +161 -0
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/plugin/applepay/service.d.ts +54 -0
- package/esm/plugin/applepay/service.js +289 -0
- package/esm/plugin/component/cashierApp.d.ts +34 -0
- package/esm/plugin/component/cashierApp.js +237 -0
- package/esm/plugin/component/channel.d.ts +21 -0
- package/esm/plugin/component/channel.js +89 -0
- package/esm/plugin/component/component.inline.style.d.ts +10 -0
- package/esm/plugin/component/component.inline.style.js +119 -0
- package/esm/plugin/component/component.popup.style.d.ts +16 -0
- package/esm/plugin/component/component.popup.style.js +174 -0
- package/esm/plugin/component/index.d.ts +126 -0
- package/esm/plugin/component/index.js +1839 -0
- package/esm/plugin/component/popupWindow.style.d.ts +11 -0
- package/esm/plugin/component/popupWindow.style.js +121 -0
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/drop-in/index.d.ts +71 -0
- package/esm/plugin/drop-in/index.js +324 -0
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +6 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +390 -0
- package/esm/plugin/type.d.ts +34 -0
- package/esm/plugin/type.js +1 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/types/index.d.ts +28 -9
- package/esm/types/index.js +5 -1
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +2 -2
- package/esm/util/getBackScheme.js +2 -2
- package/esm/util/index.d.ts +11 -1
- package/esm/util/index.js +84 -3
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/util/security.d.ts +33 -0
- package/esm/util/security.js +182 -0
- package/package.json +2 -2
- package/esm/foundation/types/index.d.ts +0 -4
- package/esm/foundation/types/index.js +0 -4
@@ -0,0 +1,339 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
11
|
+
/**
|
12
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
13
|
+
*
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
15
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
16
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
17
|
+
*/
|
18
|
+
import { EnvironmentEnum, eventCodeEnum, ProductSceneEnum } from "../../types";
|
19
|
+
import ApplePayService from "./service";
|
20
|
+
import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
21
|
+
import { BusManager, BusMessage } from "../../core/bus";
|
22
|
+
import { SecuritySDKActionEnum } from "../../core/bus/interface";
|
23
|
+
export var ApplePayComponentEvent = /*#__PURE__*/function (ApplePayComponentEvent) {
|
24
|
+
ApplePayComponentEvent["sdk_event_appleAvailable"] = "sdk_event_appleAvailable";
|
25
|
+
ApplePayComponentEvent["sdk_event_appleCreateComponent"] = "sdk_event_appleCreateComponent";
|
26
|
+
ApplePayComponentEvent["sdk_event_appleShowPaymentSheet"] = "sdk_event_appleShowPaymentSheet";
|
27
|
+
ApplePayComponentEvent["sdk_event_appleOnvalidatemerchant"] = "sdk_event_appleOnvalidatemerchant";
|
28
|
+
ApplePayComponentEvent["sdk_event_appleSubmitToken"] = "sdk_event_appleSubmitToken";
|
29
|
+
ApplePayComponentEvent["sdk_event_applePaymentResult"] = "sdk_event_applePaymentResult";
|
30
|
+
ApplePayComponentEvent["sdk_event_appleDestroyComponent"] = "sdk_event_appleDestroyComponent";
|
31
|
+
return ApplePayComponentEvent;
|
32
|
+
}({});
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Apple pay Component
|
36
|
+
*/
|
37
|
+
var ApplePayComponent = /*#__PURE__*/function () {
|
38
|
+
function ApplePayComponent(options, logger) {
|
39
|
+
_classCallCheck(this, ApplePayComponent);
|
40
|
+
_defineProperty(this, "_applePayService", void 0);
|
41
|
+
_defineProperty(this, "_parseData", void 0);
|
42
|
+
_defineProperty(this, "_sessionData", void 0);
|
43
|
+
_defineProperty(this, "_isFinish", false);
|
44
|
+
_defineProperty(this, "_options", void 0);
|
45
|
+
_defineProperty(this, "logger", void 0);
|
46
|
+
_defineProperty(this, "isRecurring", false);
|
47
|
+
this.logger = logger;
|
48
|
+
this._options = Object.assign({
|
49
|
+
environment: EnvironmentEnum.prod
|
50
|
+
}, options, {
|
51
|
+
product: ProductSceneEnum.CARD_APPLE_PAY
|
52
|
+
});
|
53
|
+
this._applePayService = new ApplePayService(logger);
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Is Apple Pay Enabled
|
58
|
+
* @param subTypeEnum
|
59
|
+
* @returns
|
60
|
+
*/
|
61
|
+
_createClass(ApplePayComponent, [{
|
62
|
+
key: "canMakePayments",
|
63
|
+
value: function canMakePayments(subTypeEnum) {
|
64
|
+
return ApplePayService.canMakePayments(subTypeEnum);
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Is Apple Pay Enabled
|
69
|
+
* @param subTypeEnum
|
70
|
+
* @returns
|
71
|
+
*/
|
72
|
+
}, {
|
73
|
+
key: "isAppPayEnabled",
|
74
|
+
value: function isAppPayEnabled(subTypeEnum) {
|
75
|
+
return this.canMakePayments(subTypeEnum);
|
76
|
+
}
|
77
|
+
}, {
|
78
|
+
key: "onEventCallback",
|
79
|
+
value: function onEventCallback(state) {
|
80
|
+
var _state$result, _state$result2, _this$_options;
|
81
|
+
this.logger.logInfo({
|
82
|
+
name: 'APPLE_PAY',
|
83
|
+
title: ApplePayComponentEvent.sdk_event_applePaymentResult
|
84
|
+
}, {
|
85
|
+
biz: 'sdk',
|
86
|
+
type: 'funnel',
|
87
|
+
success: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL === (state === null || state === void 0 ? void 0 : state.code),
|
88
|
+
code: state === null || state === void 0 ? void 0 : state.code,
|
89
|
+
errorCode: state === null || state === void 0 || (_state$result = state.result) === null || _state$result === void 0 ? void 0 : _state$result.errorCode,
|
90
|
+
errorMessage: state === null || state === void 0 || (_state$result2 = state.result) === null || _state$result2 === void 0 ? void 0 : _state$result2.errorMessage,
|
91
|
+
recurring: this.isRecurring
|
92
|
+
}).send();
|
93
|
+
(_this$_options = this._options) === null || _this$_options === void 0 || _this$_options.onEventCallback(state);
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Submit Pay
|
98
|
+
* @param paymentSessionData
|
99
|
+
*/
|
100
|
+
}, {
|
101
|
+
key: "submitPay",
|
102
|
+
value: function submitPay(appendParams) {
|
103
|
+
var _appendParams$iframeN,
|
104
|
+
_appendParams$iframeN2,
|
105
|
+
_this$_parseData,
|
106
|
+
_this = this;
|
107
|
+
this._isFinish = false;
|
108
|
+
this._parseData = appendParams === null || appendParams === void 0 || (_appendParams$iframeN = appendParams.iframeNodesParams) === null || _appendParams$iframeN === void 0 ? void 0 : _appendParams$iframeN.paymentSessionMetaData;
|
109
|
+
this._sessionData = appendParams === null || appendParams === void 0 || (_appendParams$iframeN2 = appendParams.iframeNodesParams) === null || _appendParams$iframeN2 === void 0 ? void 0 : _appendParams$iframeN2.sessionData;
|
110
|
+
if (!this._parseData || !this._sessionData) {
|
111
|
+
this.onEventCallback({
|
112
|
+
code: eventCodeEnum.SDK_PAYMENT_FAIL,
|
113
|
+
message: 'Abnormal params paymentSessionData'
|
114
|
+
});
|
115
|
+
this.logger.logError({
|
116
|
+
name: 'APPLE_PAY',
|
117
|
+
title: 'sessionDataNull',
|
118
|
+
msg: 'Abnormal paymentSessionData'
|
119
|
+
}, {
|
120
|
+
type: 'error',
|
121
|
+
biz: 'sdk'
|
122
|
+
}).send();
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
this.isRecurring = ((_this$_parseData = this._parseData) === null || _this$_parseData === void 0 || (_this$_parseData = _this$_parseData.paymentSessionFactor) === null || _this$_parseData === void 0 ? void 0 : _this$_parseData.recurringInfo) !== null;
|
126
|
+
var getDeviceId = /*#__PURE__*/function () {
|
127
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
128
|
+
var _yield$BusManager$pub, _this$_parseData2;
|
129
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
130
|
+
while (1) switch (_context.prev = _context.next) {
|
131
|
+
case 0:
|
132
|
+
_context.next = 2;
|
133
|
+
return BusManager.publishForResult(new BusMessage(SecuritySDKActionEnum.getSecurityDeviceId, JSON.stringify({
|
134
|
+
deviceIdParameter: {
|
135
|
+
productScene: (_this$_parseData2 = _this._parseData) === null || _this$_parseData2 === void 0 || (_this$_parseData2 = _this$_parseData2.paymentSessionConfig) === null || _this$_parseData2 === void 0 ? void 0 : _this$_parseData2.productScene
|
136
|
+
}
|
137
|
+
})), {
|
138
|
+
fallback: ""
|
139
|
+
});
|
140
|
+
case 2:
|
141
|
+
_context.t1 = _yield$BusManager$pub = _context.sent;
|
142
|
+
_context.t0 = _context.t1 === null;
|
143
|
+
if (_context.t0) {
|
144
|
+
_context.next = 6;
|
145
|
+
break;
|
146
|
+
}
|
147
|
+
_context.t0 = _yield$BusManager$pub === void 0;
|
148
|
+
case 6:
|
149
|
+
if (!_context.t0) {
|
150
|
+
_context.next = 10;
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
_context.t2 = void 0;
|
154
|
+
_context.next = 11;
|
155
|
+
break;
|
156
|
+
case 10:
|
157
|
+
_context.t2 = _yield$BusManager$pub.getJSONObject();
|
158
|
+
case 11:
|
159
|
+
return _context.abrupt("return", _context.t2);
|
160
|
+
case 12:
|
161
|
+
case "end":
|
162
|
+
return _context.stop();
|
163
|
+
}
|
164
|
+
}, _callee);
|
165
|
+
}));
|
166
|
+
return function getDeviceId() {
|
167
|
+
return _ref.apply(this, arguments);
|
168
|
+
};
|
169
|
+
}();
|
170
|
+
/**
|
171
|
+
* Get MerchantSession spi
|
172
|
+
* @param event
|
173
|
+
*/
|
174
|
+
var getMerchantSession = /*#__PURE__*/function () {
|
175
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
|
176
|
+
var validationUrl, requestParams;
|
177
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
178
|
+
while (1) switch (_context2.prev = _context2.next) {
|
179
|
+
case 0:
|
180
|
+
validationUrl = _ref2.validationUrl;
|
181
|
+
// get validateUrl
|
182
|
+
requestParams = {
|
183
|
+
validateUrl: validationUrl,
|
184
|
+
paymentSessionData: _this._sessionData
|
185
|
+
}; // get deviceId
|
186
|
+
_context2.t0 = getApplePayPaymentSession;
|
187
|
+
_context2.t1 = _this._sessionData;
|
188
|
+
_context2.t2 = requestParams;
|
189
|
+
_context2.t3 = _this._options.environment;
|
190
|
+
_context2.next = 8;
|
191
|
+
return getDeviceId();
|
192
|
+
case 8:
|
193
|
+
_context2.t4 = _context2.sent;
|
194
|
+
_context2.t5 = {
|
195
|
+
deviceId: _context2.t4
|
196
|
+
};
|
197
|
+
_context2.t6 = {
|
198
|
+
env: _context2.t3,
|
199
|
+
envInfo: _context2.t5
|
200
|
+
};
|
201
|
+
_context2.t7 = _this.logger;
|
202
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1, _context2.t2, _context2.t6, _context2.t7).then(function (res) {
|
203
|
+
if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
|
204
|
+
return Promise.resolve(res.merchantSessionObject);
|
205
|
+
}
|
206
|
+
return Promise.reject({
|
207
|
+
errorCode: res.errorCode,
|
208
|
+
errorMessage: res.errorMessage
|
209
|
+
});
|
210
|
+
}).catch(function (error) {
|
211
|
+
return Promise.reject(error);
|
212
|
+
}));
|
213
|
+
case 13:
|
214
|
+
case "end":
|
215
|
+
return _context2.stop();
|
216
|
+
}
|
217
|
+
}, _callee2);
|
218
|
+
}));
|
219
|
+
return function getMerchantSession(_x) {
|
220
|
+
return _ref3.apply(this, arguments);
|
221
|
+
};
|
222
|
+
}();
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Complete Payment Authorized spi
|
226
|
+
* @param tokens
|
227
|
+
*/
|
228
|
+
var completePaymentAuthorized = /*#__PURE__*/function () {
|
229
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
|
230
|
+
var paymentToken, params;
|
231
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
232
|
+
while (1) switch (_context3.prev = _context3.next) {
|
233
|
+
case 0:
|
234
|
+
paymentToken = _ref4.paymentToken;
|
235
|
+
params = {
|
236
|
+
paymentFactors: {
|
237
|
+
instPaymentToken: paymentToken
|
238
|
+
},
|
239
|
+
paymentSessionData: _this._sessionData
|
240
|
+
};
|
241
|
+
_context3.t0 = submitPayInfo;
|
242
|
+
_context3.t1 = params;
|
243
|
+
_context3.t2 = _this._options.environment;
|
244
|
+
_context3.next = 7;
|
245
|
+
return getDeviceId();
|
246
|
+
case 7:
|
247
|
+
_context3.t3 = _context3.sent;
|
248
|
+
_context3.t4 = {
|
249
|
+
deviceId: _context3.t3
|
250
|
+
};
|
251
|
+
_context3.t5 = {
|
252
|
+
env: _context3.t2,
|
253
|
+
envInfo: _context3.t4
|
254
|
+
};
|
255
|
+
_context3.t6 = _this.logger;
|
256
|
+
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
|
257
|
+
_this.logger.logInfo({
|
258
|
+
name: 'APPLE_PAY',
|
259
|
+
title: 'submitPayStatus',
|
260
|
+
msg: res === null || res === void 0 ? void 0 : res.errorStatus
|
261
|
+
}, {
|
262
|
+
biz: 'sdk'
|
263
|
+
}).send();
|
264
|
+
if (res !== null && res !== void 0 && res.success || (res === null || res === void 0 ? void 0 : res.errorStatus) === 'U') {
|
265
|
+
return Promise.resolve(res);
|
266
|
+
}
|
267
|
+
return Promise.reject({
|
268
|
+
errorCode: res.errorCode,
|
269
|
+
errorMessage: res.errorMessage
|
270
|
+
});
|
271
|
+
}).catch(function (error) {
|
272
|
+
return Promise.reject(error);
|
273
|
+
}));
|
274
|
+
case 12:
|
275
|
+
case "end":
|
276
|
+
return _context3.stop();
|
277
|
+
}
|
278
|
+
}, _callee3);
|
279
|
+
}));
|
280
|
+
return function completePaymentAuthorized(_x2) {
|
281
|
+
return _ref5.apply(this, arguments);
|
282
|
+
};
|
283
|
+
}();
|
284
|
+
var completeApplePay = function completeApplePay(data) {
|
285
|
+
var _data$actionForm;
|
286
|
+
_this._isFinish = true;
|
287
|
+
_this.onEventCallback({
|
288
|
+
code: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL,
|
289
|
+
message: 'Payment successful',
|
290
|
+
result: {
|
291
|
+
redirectUrl: (data === null || data === void 0 || (_data$actionForm = data.actionForm) === null || _data$actionForm === void 0 ? void 0 : _data$actionForm.redirectUrl) || ''
|
292
|
+
}
|
293
|
+
});
|
294
|
+
};
|
295
|
+
var logError = function logError(code, msg, error) {
|
296
|
+
// log error
|
297
|
+
_this.logger.logError({
|
298
|
+
name: 'APPLE_PAY',
|
299
|
+
title: msg,
|
300
|
+
label: msg,
|
301
|
+
code: code,
|
302
|
+
msg: error
|
303
|
+
}, {
|
304
|
+
type: 'error',
|
305
|
+
biz: 'sdk'
|
306
|
+
}).send();
|
307
|
+
if (_this._isFinish) {
|
308
|
+
return;
|
309
|
+
}
|
310
|
+
_this._isFinish = true;
|
311
|
+
if (error !== null && error !== void 0 && error.errorCode) {
|
312
|
+
_this.onEventCallback({
|
313
|
+
code: code,
|
314
|
+
message: msg,
|
315
|
+
result: {
|
316
|
+
errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
|
317
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.errorMessage
|
318
|
+
}
|
319
|
+
});
|
320
|
+
} else {
|
321
|
+
_this.onEventCallback({
|
322
|
+
code: code,
|
323
|
+
message: msg
|
324
|
+
});
|
325
|
+
}
|
326
|
+
};
|
327
|
+
// set Apple Pay params
|
328
|
+
this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError);
|
329
|
+
// init Apple Pay service
|
330
|
+
try {
|
331
|
+
this._applePayService.startPay(this._parseData);
|
332
|
+
} catch (error) {
|
333
|
+
logError(eventCodeEnum.SDK_PAYMENT_ERROR, "appple runtime excepiton", error);
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}]);
|
337
|
+
return ApplePayComponent;
|
338
|
+
}();
|
339
|
+
export default ApplePayComponent;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { Logger } from "../../util/logger";
|
2
|
+
import { BusContext, BusMessage, BusSubscriber } from "../../core/bus";
|
3
|
+
export declare class ApplePayInitMessage {
|
4
|
+
private environment;
|
5
|
+
private locale;
|
6
|
+
}
|
7
|
+
export declare class ApplePayBusSubscriber extends BusSubscriber {
|
8
|
+
private applePay;
|
9
|
+
logger: Logger;
|
10
|
+
constructor(logger: Logger);
|
11
|
+
actionNames(): string[];
|
12
|
+
protected onOptionalInit(context: BusContext, message: BusMessage): void;
|
13
|
+
protected onCanMakePayments(context: BusContext, message: BusMessage): void;
|
14
|
+
protected onCreateComponent(context: BusContext, message: BusMessage): void;
|
15
|
+
protected onDestroyComponent(context: BusContext, message: BusMessage): void;
|
16
|
+
onMessage(context: BusContext, message: BusMessage): void;
|
17
|
+
}
|
@@ -0,0 +1,117 @@
|
|
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 _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); }
|
5
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
6
|
+
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); }; }
|
7
|
+
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); }
|
8
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
9
|
+
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; } }
|
10
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
11
|
+
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); } }
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
14
|
+
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; }
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
16
|
+
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); }
|
17
|
+
import { BusManager, BusMessage, BusSubscriber } from "../../core/bus";
|
18
|
+
import { ApplePayActionEnum, PaymentActionEnum, SDKCallbackActionEnum } from "../../core/bus/interface";
|
19
|
+
import ApplePayComponent, { ApplePayComponentEvent } from "./component";
|
20
|
+
import ApplePayService from "./service";
|
21
|
+
export var ApplePayInitMessage = /*#__PURE__*/_createClass(function ApplePayInitMessage() {
|
22
|
+
_classCallCheck(this, ApplePayInitMessage);
|
23
|
+
_defineProperty(this, "environment", void 0);
|
24
|
+
_defineProperty(this, "locale", void 0);
|
25
|
+
});
|
26
|
+
export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
27
|
+
_inherits(ApplePayBusSubscriber, _BusSubscriber);
|
28
|
+
var _super = _createSuper(ApplePayBusSubscriber);
|
29
|
+
function ApplePayBusSubscriber(logger) {
|
30
|
+
var _this;
|
31
|
+
_classCallCheck(this, ApplePayBusSubscriber);
|
32
|
+
_this = _super.call(this);
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "applePay", void 0);
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
35
|
+
_this.logger = logger;
|
36
|
+
return _this;
|
37
|
+
}
|
38
|
+
_createClass(ApplePayBusSubscriber, [{
|
39
|
+
key: "actionNames",
|
40
|
+
value: function actionNames() {
|
41
|
+
return Object.values(ApplePayActionEnum).concat(Object.values(PaymentActionEnum));
|
42
|
+
}
|
43
|
+
}, {
|
44
|
+
key: "onOptionalInit",
|
45
|
+
value: function onOptionalInit(context, message) {
|
46
|
+
console.log('onOptionalInit', message.getData());
|
47
|
+
}
|
48
|
+
}, {
|
49
|
+
key: "onCanMakePayments",
|
50
|
+
value: function onCanMakePayments(context, message) {
|
51
|
+
var _message$getJSONObjec;
|
52
|
+
console.log('onCanMakePayments', message.getData());
|
53
|
+
var subPaymentMethod = (_message$getJSONObjec = message.getJSONObject()) === null || _message$getJSONObjec === void 0 ? void 0 : _message$getJSONObjec.subPaymentMethod;
|
54
|
+
var canMakePayments = ApplePayService.canMakePayments(subPaymentMethod);
|
55
|
+
context === null || context === void 0 || context.onCallBack(message.result(canMakePayments));
|
56
|
+
this.logger.logInfo({
|
57
|
+
name: 'APPLE_PAY',
|
58
|
+
title: ApplePayComponentEvent.sdk_event_appleAvailable
|
59
|
+
}, {
|
60
|
+
biz: 'sdk',
|
61
|
+
type: 'funnel',
|
62
|
+
success: canMakePayments,
|
63
|
+
recurring: subPaymentMethod === 'ApplePayRecurringPayment'
|
64
|
+
}).send();
|
65
|
+
}
|
66
|
+
}, {
|
67
|
+
key: "onCreateComponent",
|
68
|
+
value: function onCreateComponent(context, message) {
|
69
|
+
var data = message.getJSONObject();
|
70
|
+
console.log('onCreateComponent', message);
|
71
|
+
this.applePay = new ApplePayComponent(_objectSpread(_objectSpread({}, data === null || data === void 0 ? void 0 : data.options), {}, {
|
72
|
+
onEventCallback: function onEventCallback(state) {
|
73
|
+
console.log('onCreateComponent#onEventCallback', state);
|
74
|
+
if (state) {
|
75
|
+
BusManager.publish(new BusMessage(SDKCallbackActionEnum.onEventCallback, JSON.stringify(state)));
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}), this.logger);
|
79
|
+
var appendParams = data === null || data === void 0 ? void 0 : data.appendParams;
|
80
|
+
this.applePay.submitPay(appendParams);
|
81
|
+
}
|
82
|
+
}, {
|
83
|
+
key: "onDestroyComponent",
|
84
|
+
value: function onDestroyComponent(context, message) {
|
85
|
+
this.applePay = null;
|
86
|
+
console.log('onDestroyComponent', context, message);
|
87
|
+
this.logger.logInfo({
|
88
|
+
name: 'APPLE_PAY',
|
89
|
+
title: ApplePayComponentEvent.sdk_event_appleDestroyComponent
|
90
|
+
}, {
|
91
|
+
biz: 'sdk',
|
92
|
+
type: 'funnel'
|
93
|
+
}).send();
|
94
|
+
}
|
95
|
+
}, {
|
96
|
+
key: "onMessage",
|
97
|
+
value: function onMessage(context, message) {
|
98
|
+
switch (message.getAction()) {
|
99
|
+
case PaymentActionEnum.optional_init:
|
100
|
+
this.onOptionalInit(context, message);
|
101
|
+
break;
|
102
|
+
case ApplePayActionEnum.canMakePayments:
|
103
|
+
this.onCanMakePayments(context, message);
|
104
|
+
break;
|
105
|
+
case ApplePayActionEnum.createComponent:
|
106
|
+
this.onCreateComponent(context, message);
|
107
|
+
break;
|
108
|
+
case ApplePayActionEnum.destroyComponent:
|
109
|
+
this.onDestroyComponent(context, message);
|
110
|
+
break;
|
111
|
+
default:
|
112
|
+
console.log("Unknown action: " + message.getAction());
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}]);
|
116
|
+
return ApplePayBusSubscriber;
|
117
|
+
}(BusSubscriber);
|
@@ -0,0 +1,161 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
6
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
|
+
*/
|
8
|
+
export type Version = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
9
|
+
export declare const APPLE_PAY_VERSION = 2;
|
10
|
+
export declare const APPLE_PAY_RECURRING_VERSION = 14;
|
11
|
+
export interface IApplePayValidateMerchantEvent {
|
12
|
+
validationURL: string;
|
13
|
+
}
|
14
|
+
export type ApplePayMerchantCapability = 'supports3DS' | 'supportsEMV' | 'supportsCredit' | 'supportsDebit';
|
15
|
+
export type PaymentNetwork = 'amex' | 'cartesBancaires' | 'chinaUnionPay' | 'discover' | 'eftpos' | 'electron' | 'elo' | 'interac' | 'jcb' | 'mada' | 'maestro' | 'masterCard' | 'privateLabel' | 'visa' | 'vPay';
|
16
|
+
export interface IApplePayContactField {
|
17
|
+
email: string;
|
18
|
+
name: string;
|
19
|
+
phone: string;
|
20
|
+
postalAddress: string;
|
21
|
+
phoneticName: string;
|
22
|
+
}
|
23
|
+
export interface IApplePayPaymentContact {
|
24
|
+
phoneNumber: string;
|
25
|
+
emailAddress: string;
|
26
|
+
givenName: string;
|
27
|
+
familyName: string;
|
28
|
+
phoneticGivenName: string;
|
29
|
+
phoneticFamilyName: string;
|
30
|
+
addressLines: string;
|
31
|
+
subLocality: string;
|
32
|
+
locality: string;
|
33
|
+
postalCode: string;
|
34
|
+
subAdministrativeArea: string;
|
35
|
+
administrativeArea: string;
|
36
|
+
country: string;
|
37
|
+
countryCode: string;
|
38
|
+
}
|
39
|
+
export type IApplePayLineItemType = 'final' | 'pending';
|
40
|
+
export type ApplePayPaymentTiming = "immediate" | "recurring" | "deferred" | "automaticReload";
|
41
|
+
export type ApplePayRecurringPaymentDateUnit = "year" | "month" | "day" | "hour" | "minute";
|
42
|
+
/**
|
43
|
+
*
|
44
|
+
{
|
45
|
+
"label": "Subscription",
|
46
|
+
"amount": "20.00",
|
47
|
+
"type": "final",
|
48
|
+
"paymentTiming": "recurring",
|
49
|
+
"recurringPaymentStartDate": new Date("2022-01-01T00:00:00"),
|
50
|
+
"recurringPaymentIntervalUnit": "month",
|
51
|
+
"recurringPaymentIntervalCount": 6,
|
52
|
+
"recurringPaymentEndDate": new Date("2024-01-01T00:00:00"),
|
53
|
+
}
|
54
|
+
*/
|
55
|
+
export interface IApplePayLineItem {
|
56
|
+
/**
|
57
|
+
* A value that indicates whether the line item is final or pending.
|
58
|
+
*/
|
59
|
+
type: IApplePayLineItemType;
|
60
|
+
/**
|
61
|
+
* A required value that’s a short, localized description of the line item.
|
62
|
+
*/
|
63
|
+
label: string;
|
64
|
+
/**
|
65
|
+
* A required value that’s the monetary amount of the line item.
|
66
|
+
*/
|
67
|
+
amount: string;
|
68
|
+
paymentTiming?: ApplePayPaymentTiming;
|
69
|
+
recurringPaymentStartDate?: Date;
|
70
|
+
recurringPaymentEndDate?: Date;
|
71
|
+
recurringPaymentIntervalUnit?: ApplePayRecurringPaymentDateUnit;
|
72
|
+
recurringPaymentIntervalCount?: number;
|
73
|
+
deferredPaymentDate?: Date;
|
74
|
+
automaticReloadPaymentThresholdAmount?: string;
|
75
|
+
}
|
76
|
+
export type applePayShippingType = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
|
77
|
+
export interface IApplePayShippingMethod {
|
78
|
+
label: string;
|
79
|
+
detail: string;
|
80
|
+
amount: string;
|
81
|
+
identifier: string;
|
82
|
+
}
|
83
|
+
export interface IApplePayPayment {
|
84
|
+
token: any;
|
85
|
+
billingContact?: IApplePayPaymentContact;
|
86
|
+
shippingContact?: IApplePayPaymentContact;
|
87
|
+
}
|
88
|
+
export interface IApplePayPaymentAuthorizedEvent {
|
89
|
+
payment: IApplePayPayment;
|
90
|
+
}
|
91
|
+
export type status = 'STATUS_SUCCESS' | 'STATUS_FAILURE' | 'STATUS_INVALID_BILLING_POSTAL_ADDRESS' | 'STATUS_INVALID_SHIPPING_POSTAL_ADDRESS' | 'STATUS_INVALID_SHIPPING_CONTACT' | 'STATUS_PIN_INCORRECT' | 'STATUS_PIN_LOCKOUT' | 'STATUS_PIN_REQUIRED';
|
92
|
+
export interface IApplePayPaymentAuthorizationResult {
|
93
|
+
status: any;
|
94
|
+
errors?: string[];
|
95
|
+
}
|
96
|
+
export interface IApplePayPaymentRequest {
|
97
|
+
merchantCapabilities: ApplePayMerchantCapability[];
|
98
|
+
supportedNetworks: PaymentNetwork[];
|
99
|
+
countryCode: string;
|
100
|
+
requiredBillingContactFields?: IApplePayContactField[];
|
101
|
+
billingContact?: IApplePayPaymentContact;
|
102
|
+
requiredShippingContactFields?: IApplePayContactField[];
|
103
|
+
shippingContact?: IApplePayPaymentContact;
|
104
|
+
applicationData?: string;
|
105
|
+
supportedCountries?: string[];
|
106
|
+
total: IApplePayLineItem;
|
107
|
+
lineItems?: IApplePayLineItem[];
|
108
|
+
currencyCode: string;
|
109
|
+
shippingType?: applePayShippingType;
|
110
|
+
shippingMethods?: IApplePayShippingMethod[];
|
111
|
+
recurringPaymentRequest?: IApplePayRecurringPaymentRequest;
|
112
|
+
}
|
113
|
+
export interface IApplePayRecurringPaymentRequest {
|
114
|
+
/**
|
115
|
+
* A description of the recurring payment that Apple Pay displays to the user in the payment sheet.
|
116
|
+
*/
|
117
|
+
paymentDescription: string;
|
118
|
+
/**
|
119
|
+
* A localized billing agreement that the payment sheet displays to the user before the user authorizes the payment.
|
120
|
+
*/
|
121
|
+
billingAgreement?: string;
|
122
|
+
/**
|
123
|
+
* The regular billing cycle for the recurring payment, including start and end dates, an interval, and an interval count.
|
124
|
+
*/
|
125
|
+
regularBilling: IApplePayLineItem;
|
126
|
+
/**
|
127
|
+
* 订阅试用的周期控制,暂时不需要
|
128
|
+
* The trial billing cycle for the recurring payment.
|
129
|
+
*/
|
130
|
+
trialBilling?: IApplePayLineItem;
|
131
|
+
/**
|
132
|
+
* A URL to a web page where the user can update or delete the payment method for the recurring payment.
|
133
|
+
*/
|
134
|
+
managementURL: string;
|
135
|
+
/**
|
136
|
+
* A URL you provide for receiving life-cycle notifications from the Apple Pay servers about the Apple Pay merchant token for the recurring payment.
|
137
|
+
*/
|
138
|
+
tokenNotificationURL?: string;
|
139
|
+
}
|
140
|
+
export interface IApplePaySession {
|
141
|
+
supportsVersion?: (version: Version) => boolean;
|
142
|
+
canMakePayments?: () => boolean;
|
143
|
+
canMakePaymentsWithActiveCard?: (merchantIdentifier: string) => Promise<boolean>;
|
144
|
+
begin: () => void;
|
145
|
+
onvalidatemerchant: (event: IApplePayValidateMerchantEvent) => void;
|
146
|
+
completeMerchantValidation: (merchantSession: any) => void;
|
147
|
+
onpaymentauthorized: (event: IApplePayPaymentAuthorizedEvent) => void;
|
148
|
+
completePayment: (result: IApplePayPaymentAuthorizationResult) => void;
|
149
|
+
oncancel?: () => void;
|
150
|
+
abort?: () => void;
|
151
|
+
}
|
152
|
+
export type IGetMerchantSession = (params: {
|
153
|
+
displayName?: string;
|
154
|
+
merchantIdentifier?: string;
|
155
|
+
validationUrl: string;
|
156
|
+
}) => Promise<any>;
|
157
|
+
export type ICompletePaymentAuthorized = (params: {
|
158
|
+
paymentToken?: string;
|
159
|
+
}) => Promise<any>;
|
160
|
+
export type ICompleteApplePay = (data: any) => void;
|
161
|
+
export type ILogError = (code: string, msg: string, error?: any) => void;
|