@alipay/ams-checkout 0.0.1730107332-dev.25 → 0.0.1730107332-dev.27

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.
Files changed (94) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.inline.style.js +1 -1
  3. package/esm/config/index.d.ts +7 -7
  4. package/esm/config/index.js +7 -7
  5. package/esm/constant/index.d.ts +3 -0
  6. package/esm/constant/index.js +3 -0
  7. package/esm/core/bus/ability/callback.d.ts +9 -0
  8. package/esm/core/bus/ability/callback.js +55 -0
  9. package/esm/core/bus/ability/security.d.ts +10 -0
  10. package/esm/core/bus/ability/security.js +104 -0
  11. package/esm/core/bus/ability/tracker.d.ts +9 -0
  12. package/esm/core/bus/ability/tracker.js +77 -0
  13. package/esm/core/bus/index.d.ts +125 -0
  14. package/esm/core/bus/index.js +366 -0
  15. package/esm/core/bus/interface.d.ts +36 -0
  16. package/esm/core/bus/interface.js +40 -0
  17. package/esm/core/component/address.d.ts +8 -0
  18. package/esm/core/component/address.js +72 -0
  19. package/esm/core/component/appPreloadProcessing.d.ts +1 -0
  20. package/esm/core/component/appPreloadProcessing.js +89 -0
  21. package/esm/core/component/ckp/index.d.ts +27 -0
  22. package/esm/core/component/ckp/index.js +166 -0
  23. package/esm/core/component/index.d.ts +51 -0
  24. package/esm/core/component/index.js +531 -0
  25. package/esm/core/drop-in/index.d.ts +22 -0
  26. package/esm/core/drop-in/index.js +104 -0
  27. package/esm/core/instance/index.d.ts +89 -0
  28. package/esm/core/instance/index.js +499 -0
  29. package/esm/foundation/core/index.d.ts +2 -2
  30. package/esm/foundation/index.d.ts +5 -5
  31. package/esm/foundation/product-processor/easysafepay/deps.d.ts +2 -2
  32. package/esm/foundation/product-processor/easysafepay/deps.js +1 -1
  33. package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -2
  34. package/esm/foundation/service/api-bus/index.d.ts +2 -2
  35. package/esm/foundation/service/container/index.d.ts +2 -2
  36. package/esm/foundation/service/event-center.d.ts +4 -4
  37. package/esm/foundation/service/event-center.js +10 -10
  38. package/esm/foundation/service/global-data/index.d.ts +2 -2
  39. package/esm/foundation/service/index.d.ts +2 -2
  40. package/esm/foundation/service/log/index.d.ts +2 -2
  41. package/esm/foundation/service/requester/deps.d.ts +1 -1
  42. package/esm/foundation/service/requester/requester.d.ts +2 -2
  43. package/esm/foundation/service/security/index.d.ts +2 -2
  44. package/esm/foundation/utils/redirect_utils.d.ts +5 -0
  45. package/esm/foundation/utils/redirect_utils.js +135 -1
  46. package/esm/foundation/utils/web_app_url_utils.js +1 -1
  47. package/esm/index.d.ts +27 -2
  48. package/esm/index.js +131 -6
  49. package/esm/plugin/applepay/component.d.ts +50 -0
  50. package/esm/plugin/applepay/component.js +339 -0
  51. package/esm/plugin/applepay/index.d.ts +17 -0
  52. package/esm/plugin/applepay/index.js +117 -0
  53. package/esm/plugin/applepay/interface.d.ts +161 -0
  54. package/esm/plugin/applepay/interface.js +69 -0
  55. package/esm/plugin/applepay/service.d.ts +54 -0
  56. package/esm/plugin/applepay/service.js +289 -0
  57. package/esm/plugin/component/cashierApp.d.ts +34 -0
  58. package/esm/plugin/component/cashierApp.js +237 -0
  59. package/esm/plugin/component/channel.d.ts +21 -0
  60. package/esm/plugin/component/channel.js +89 -0
  61. package/esm/plugin/component/component.inline.style.d.ts +10 -0
  62. package/esm/plugin/component/component.inline.style.js +119 -0
  63. package/esm/plugin/component/component.popup.style.d.ts +16 -0
  64. package/esm/plugin/component/component.popup.style.js +174 -0
  65. package/esm/plugin/component/index.d.ts +126 -0
  66. package/esm/plugin/component/index.js +1839 -0
  67. package/esm/plugin/component/popupWindow.style.d.ts +11 -0
  68. package/esm/plugin/component/popupWindow.style.js +121 -0
  69. package/esm/plugin/const.d.ts +2 -0
  70. package/esm/plugin/const.js +33 -0
  71. package/esm/plugin/drop-in/index.d.ts +71 -0
  72. package/esm/plugin/drop-in/index.js +324 -0
  73. package/esm/plugin/payment-element/utils.d.ts +2 -0
  74. package/esm/plugin/payment-element/utils.js +6 -0
  75. package/esm/plugin/paypal/index.d.ts +20 -0
  76. package/esm/plugin/paypal/index.js +390 -0
  77. package/esm/plugin/type.d.ts +34 -0
  78. package/esm/plugin/type.js +1 -0
  79. package/esm/plugin/utils.d.ts +6 -0
  80. package/esm/plugin/utils.js +21 -0
  81. package/esm/types/index.d.ts +28 -9
  82. package/esm/types/index.js +5 -1
  83. package/esm/util/createIframeNode.d.ts +6 -0
  84. package/esm/util/createIframeNode.js +48 -0
  85. package/esm/util/getBackScheme.d.ts +2 -2
  86. package/esm/util/getBackScheme.js +2 -2
  87. package/esm/util/index.d.ts +11 -1
  88. package/esm/util/index.js +84 -3
  89. package/esm/util/intl-callapp/es/index.js +0 -1
  90. package/esm/util/security.d.ts +33 -0
  91. package/esm/util/security.js +182 -0
  92. package/package.json +2 -2
  93. package/esm/foundation/types/index.d.ts +0 -4
  94. package/esm/foundation/types/index.js +0 -4
@@ -0,0 +1,69 @@
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
+ /* eslint-disable @typescript-eslint/no-explicit-any */
9
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_on_the_web_version_history
10
+
11
+ export var APPLE_PAY_VERSION = 2;
12
+ export var APPLE_PAY_RECURRING_VERSION = 14;
13
+
14
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayvalidatemerchantevent
15
+
16
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaymerchantcapability
17
+
18
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/1916122-supportednetworks
19
+
20
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaycontactfield
21
+
22
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentcontact
23
+
24
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitemtype
25
+
26
+ //https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymenttiming
27
+
28
+ //https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentdateunit
29
+
30
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitem
31
+ /**
32
+ *
33
+ {
34
+ "label": "Subscription",
35
+ "amount": "20.00",
36
+ "type": "final",
37
+ "paymentTiming": "recurring",
38
+ "recurringPaymentStartDate": new Date("2022-01-01T00:00:00"),
39
+ "recurringPaymentIntervalUnit": "month",
40
+ "recurringPaymentIntervalCount": 6,
41
+ "recurringPaymentEndDate": new Date("2024-01-01T00:00:00"),
42
+ }
43
+ */
44
+
45
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingtype
46
+
47
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingmethod
48
+
49
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment
50
+
51
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentauthorizedevent
52
+
53
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/apple_pay_status_codes
54
+
55
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentauthorizationresult
56
+
57
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
58
+
59
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest
60
+
61
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession
62
+
63
+ // IGetMerchantSession spi type
64
+
65
+ // ICompletePaymentAuthorized spi type
66
+
67
+ // ICompleteApplePay spi type
68
+
69
+ // ILogError spi type
@@ -0,0 +1,54 @@
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
+ import { IGetMerchantSession, ICompletePaymentAuthorized, ICompleteApplePay, ILogError } from './interface';
9
+ import { ApplePaySubTypeEnum, IPaymentSessionMetaData } from '../../types';
10
+ import type { Logger } from '../../util/logger';
11
+ /**
12
+ * Apple Pay Service
13
+ */
14
+ declare class ApplePayService {
15
+ private merchantIdentifier;
16
+ private merchantName;
17
+ private session;
18
+ private paymentState;
19
+ private getMerchantSession;
20
+ private completePaymentAuthorized;
21
+ private completeApplePay;
22
+ private logError;
23
+ private isRecurring;
24
+ private logger;
25
+ constructor(logger: Logger);
26
+ /**
27
+ * set Apple Pay Params
28
+ * @param getMerchantSession
29
+ * @param completePaymentAuthorized
30
+ * @param completeApplePay
31
+ * @param logError
32
+ * @param applePayTrace
33
+ */
34
+ setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError): void;
35
+ /**
36
+ * Is Apple Pay Enabled
37
+ * @param subTypeEnum
38
+ * @returns
39
+ */
40
+ static canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): any;
41
+ /**
42
+ * has Active Card in Apple Pay
43
+ * @param merchantIdentifier
44
+ */
45
+ hasActiveCard(merchantIdentifier: string): Promise<boolean>;
46
+ private onvalidatemerchant;
47
+ private sessionAbort;
48
+ private onpaymentauthorized;
49
+ /**
50
+ * Start Pay
51
+ */
52
+ startPay: (param: IPaymentSessionMetaData) => void;
53
+ }
54
+ export default ApplePayService;
@@ -0,0 +1,289 @@
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
+ /* eslint-disable @typescript-eslint/no-explicit-any */
19
+ import { APPLE_PAY_VERSION, APPLE_PAY_RECURRING_VERSION } from "./interface";
20
+ import { eventCodeEnum } from "../../types";
21
+ import { ApplePayComponentEvent } from "./component";
22
+ var PaymentState = /*#__PURE__*/function (PaymentState) {
23
+ PaymentState[PaymentState["notStarted"] = 0] = "notStarted";
24
+ PaymentState[PaymentState["pending"] = 1] = "pending";
25
+ PaymentState[PaymentState["fail"] = 2] = "fail";
26
+ PaymentState[PaymentState["success"] = 3] = "success";
27
+ return PaymentState;
28
+ }(PaymentState || {});
29
+ /**
30
+ * Apple Pay Service
31
+ */
32
+ var ApplePayService = /*#__PURE__*/function () {
33
+ function ApplePayService(logger) {
34
+ var _this = this;
35
+ _classCallCheck(this, ApplePayService);
36
+ _defineProperty(this, "merchantIdentifier", void 0);
37
+ _defineProperty(this, "merchantName", void 0);
38
+ _defineProperty(this, "session", void 0);
39
+ _defineProperty(this, "paymentState", void 0);
40
+ _defineProperty(this, "getMerchantSession", void 0);
41
+ _defineProperty(this, "completePaymentAuthorized", void 0);
42
+ _defineProperty(this, "completeApplePay", void 0);
43
+ _defineProperty(this, "logError", void 0);
44
+ _defineProperty(this, "isRecurring", false);
45
+ _defineProperty(this, "logger", void 0);
46
+ _defineProperty(this, "onvalidatemerchant", function (event) {
47
+ var success = false;
48
+ _this.getMerchantSession({
49
+ displayName: _this.merchantName,
50
+ merchantIdentifier: _this.merchantIdentifier,
51
+ validationUrl: event.validationURL
52
+ }).then(function (merchantSessionObjectString) {
53
+ console.log("onvalidatemerchant#merchantSessionObjectString", merchantSessionObjectString);
54
+ var merchantSessionObject = JSON.parse(merchantSessionObjectString);
55
+ _this.session.completeMerchantValidation(merchantSessionObject);
56
+ success = true;
57
+ }).catch(function (error) {
58
+ _this.logError(eventCodeEnum.SDK_PAYMENT_FAIL, 'MerchantValidationError', error);
59
+ _this.sessionAbort();
60
+ });
61
+ _this.logger.logInfo({
62
+ name: 'APPLE_PAY',
63
+ title: ApplePayComponentEvent.sdk_event_appleCreateComponent
64
+ }, {
65
+ biz: 'sdk',
66
+ type: 'funnel',
67
+ success: success,
68
+ recurring: _this.isRecurring
69
+ }).send();
70
+ });
71
+ _defineProperty(this, "onpaymentauthorized", function (event) {
72
+ var _event$payment;
73
+ var _window = window,
74
+ ApplePaySession = _window.ApplePaySession;
75
+ var success = false;
76
+ var exception = function exception(error) {
77
+ _this.session.completePayment(ApplePaySession.STATUS_FAILURE);
78
+ _this.logError(eventCodeEnum.SDK_PAYMENT_FAIL, 'PaymentAuthorizedError', error);
79
+ _this.sessionAbort();
80
+ };
81
+ if (event !== null && event !== void 0 && (_event$payment = event.payment) !== null && _event$payment !== void 0 && _event$payment.token) {
82
+ _this.paymentState = PaymentState.pending;
83
+ _this.completePaymentAuthorized({
84
+ paymentToken: JSON.stringify(event.payment.token)
85
+ }).then(function (data) {
86
+ _this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
87
+ _this.completeApplePay(data);
88
+ _this.paymentState = PaymentState.success;
89
+ success = true;
90
+ }).catch(function (error) {
91
+ exception(error);
92
+ _this.paymentState = PaymentState.fail;
93
+ });
94
+ } else {
95
+ exception();
96
+ }
97
+ _this.logger.logInfo({
98
+ name: 'APPLE_PAY',
99
+ title: ApplePayComponentEvent.sdk_event_appleSubmitToken
100
+ }, {
101
+ biz: 'sdk',
102
+ type: 'funnel',
103
+ success: success,
104
+ recurring: _this.isRecurring
105
+ }).send();
106
+ });
107
+ /**
108
+ * Start Pay
109
+ */
110
+ _defineProperty(this, "startPay", function (param) {
111
+ var paymentSessionFactor = param.paymentSessionFactor;
112
+ var extendInfo = paymentSessionFactor.extendInfo,
113
+ merchantInfo = paymentSessionFactor.merchantInfo,
114
+ paymentAmount = paymentSessionFactor.paymentAmount,
115
+ order = paymentSessionFactor.order,
116
+ recurringInfo = paymentSessionFactor.recurringInfo;
117
+ _this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
118
+ var _window2 = window,
119
+ ApplePaySession = _window2.ApplePaySession;
120
+ _this.isRecurring = recurringInfo !== null;
121
+ _this.logger.logInfo({
122
+ name: 'APPLE_PAY',
123
+ title: ApplePayComponentEvent.sdk_event_appleCreateComponent
124
+ }, {
125
+ biz: 'sdk',
126
+ type: 'funnel',
127
+ success: ApplePaySession !== null,
128
+ recurring: _this.isRecurring
129
+ }).send();
130
+ if (!ApplePaySession) {
131
+ _this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "ApplePaySession is only support in Safari");
132
+ return;
133
+ }
134
+ if (!(extendInfo !== null && extendInfo !== void 0 && extendInfo.merchantCapabilities) || !(extendInfo !== null && extendInfo !== void 0 && extendInfo.supportedNetworks) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.registeredCountry) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.currency) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.value) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.merchantName)) {
135
+ _this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "Abnormal params paymentSessionFactor");
136
+ return;
137
+ }
138
+ if (recurringInfo) {
139
+ var _recurringInfo$interv;
140
+ if (!(order !== null && order !== void 0 && order.orderDescription) || !(recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.managementURL)) {
141
+ _this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "Abnormal params recurringInfo");
142
+ return;
143
+ }
144
+ var lineItem = {
145
+ type: 'final',
146
+ label: recurringInfo.title,
147
+ amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value,
148
+ paymentTiming: "recurring",
149
+ recurringPaymentStartDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.startDate ? new Date(Number(recurringInfo.startDate) * 1000) : null,
150
+ recurringPaymentEndDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.endDate ? new Date(Number(recurringInfo.endDate) * 1000) : null,
151
+ recurringPaymentIntervalUnit: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.intervalUnit ? recurringInfo.intervalUnit : "month",
152
+ recurringPaymentIntervalCount: (_recurringInfo$interv = recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.intervalCount) !== null && _recurringInfo$interv !== void 0 ? _recurringInfo$interv : 1
153
+ };
154
+ var recurringRequest = {
155
+ // 不知道显示在哪里
156
+ paymentDescription: order === null || order === void 0 ? void 0 : order.orderDescription,
157
+ billingAgreement: recurringInfo.agreementDescription,
158
+ regularBilling: lineItem,
159
+ managementURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.managementURL,
160
+ tokenNotificationURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.tokenNotificationURL
161
+ };
162
+ var request = {
163
+ merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
164
+ supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
165
+ countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
166
+ currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
167
+ total: lineItem,
168
+ recurringPaymentRequest: recurringRequest,
169
+ lineItems: [lineItem]
170
+ };
171
+ _this.session = new ApplePaySession(APPLE_PAY_RECURRING_VERSION, request);
172
+ } else {
173
+ var _request = {
174
+ merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
175
+ supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
176
+ countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
177
+ currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
178
+ total: {
179
+ type: 'final',
180
+ label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
181
+ amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
182
+ }
183
+ };
184
+ _this.session = new ApplePaySession(APPLE_PAY_VERSION, _request);
185
+ }
186
+ // 核身前触发
187
+ _this.session.onvalidatemerchant = _this.onvalidatemerchant;
188
+ // 核身后触发
189
+ _this.session.onpaymentauthorized = _this.onpaymentauthorized;
190
+ _this.session.oncancel = function () {
191
+ if (_this.paymentState === PaymentState.pending) {
192
+ _this.logError(eventCodeEnum.SDK_PAYMENT_PROCESSING, 'Payment processing but user dismissed the sheet');
193
+ } else {
194
+ _this.logError(eventCodeEnum.SDK_PAYMENT_CANCEL, 'User dismissed the sheet');
195
+ }
196
+ _this.sessionAbort();
197
+ };
198
+ _this.session.begin();
199
+ _this.logger.logInfo({
200
+ name: 'APPLE_PAY',
201
+ title: ApplePayComponentEvent.sdk_event_appleShowPaymentSheet
202
+ }, {
203
+ biz: 'sdk',
204
+ type: 'funnel',
205
+ success: true,
206
+ recurring: recurringInfo !== null
207
+ }).send();
208
+ });
209
+ this.logger = logger;
210
+ }
211
+
212
+ /**
213
+ * set Apple Pay Params
214
+ * @param getMerchantSession
215
+ * @param completePaymentAuthorized
216
+ * @param completeApplePay
217
+ * @param logError
218
+ * @param applePayTrace
219
+ */
220
+ _createClass(ApplePayService, [{
221
+ key: "setApplePayParams",
222
+ value: function setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError) {
223
+ this.getMerchantSession = getMerchantSession;
224
+ this.completePaymentAuthorized = completePaymentAuthorized;
225
+ this.completeApplePay = completeApplePay;
226
+ this.logError = logError;
227
+ this.paymentState = PaymentState.notStarted;
228
+ }
229
+
230
+ /**
231
+ * Is Apple Pay Enabled
232
+ * @param subTypeEnum
233
+ * @returns
234
+ */
235
+ }, {
236
+ key: "hasActiveCard",
237
+ value: (
238
+ /**
239
+ * has Active Card in Apple Pay
240
+ * @param merchantIdentifier
241
+ */
242
+ function () {
243
+ var _hasActiveCard = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(merchantIdentifier) {
244
+ var _window3, ApplePaySession;
245
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
246
+ while (1) switch (_context.prev = _context.next) {
247
+ case 0:
248
+ _window3 = window, ApplePaySession = _window3.ApplePaySession;
249
+ if (!ApplePaySession) {
250
+ _context.next = 3;
251
+ break;
252
+ }
253
+ return _context.abrupt("return", ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier));
254
+ case 3:
255
+ return _context.abrupt("return", Promise.resolve(false));
256
+ case 4:
257
+ case "end":
258
+ return _context.stop();
259
+ }
260
+ }, _callee);
261
+ }));
262
+ function hasActiveCard(_x) {
263
+ return _hasActiveCard.apply(this, arguments);
264
+ }
265
+ return hasActiveCard;
266
+ }())
267
+ }, {
268
+ key: "sessionAbort",
269
+ value: function sessionAbort() {
270
+ if (this.session) {
271
+ try {
272
+ this.session.abort();
273
+ } catch (error) {
274
+ console.log("session.abort() error");
275
+ }
276
+ }
277
+ }
278
+ }], [{
279
+ key: "canMakePayments",
280
+ value: function canMakePayments(subTypeEnum) {
281
+ if ('ApplePayRecurringPayment' === subTypeEnum) {
282
+ return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_RECURRING_VERSION) : false;
283
+ }
284
+ return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_VERSION) : false;
285
+ }
286
+ }]);
287
+ return ApplePayService;
288
+ }();
289
+ export default ApplePayService;
@@ -0,0 +1,34 @@
1
+ import { ComponentSignEnum, Ianalytics, DisplayTypeEnum } from '../../types';
2
+ export declare const getAppPath: (environment: string, appVersion: string, componentSign: ComponentSignEnum, productScene: string, productSceneVersion: string, extendInfo: string, mid: string, sendLog?: boolean) => any;
3
+ export declare const getAppDomain: (domainParams: {
4
+ environment: string;
5
+ appVersion: string;
6
+ componentSign: ComponentSignEnum;
7
+ productScene: string;
8
+ productSceneVersion: string;
9
+ extendInfo: string;
10
+ mid: string;
11
+ }) => string;
12
+ export declare const getIframeUrl: (iframeParams: {
13
+ componentSign: ComponentSignEnum;
14
+ analytics?: Ianalytics;
15
+ productScene: string;
16
+ productSceneVersion: string;
17
+ environment: string;
18
+ appVersion: string;
19
+ extendInfo?: string;
20
+ locale?: string;
21
+ instanceId: string;
22
+ renderDisplayType: DisplayTypeEnum;
23
+ isPreload?: string;
24
+ hostSign?: string;
25
+ mid?: string;
26
+ }) => {
27
+ path: string;
28
+ locationSearch: string;
29
+ };
30
+ /**
31
+ * @description Create iframe
32
+ */
33
+ export declare const createIframe: (mode: string, platform: 'mobile' | 'desktop') => HTMLIFrameElement;
34
+ export declare const createPreloadIframe: (channelType: any, version: any) => HTMLIFrameElement;