@alipay/ams-checkout 1.3.1 → 1.4.0

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 (58) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +2 -0
  3. package/esm/config/index.js +17 -0
  4. package/esm/config/request.d.ts +21 -0
  5. package/esm/config/request.js +67 -0
  6. package/esm/constant/index.d.ts +136 -0
  7. package/esm/constant/index.js +136 -0
  8. package/esm/core/component/index.d.ts +17 -0
  9. package/esm/core/component/index.js +100 -0
  10. package/esm/core/drop-in/index.d.ts +29 -0
  11. package/esm/core/drop-in/index.js +104 -0
  12. package/esm/core/instance/index.d.ts +59 -0
  13. package/esm/core/instance/index.js +254 -0
  14. package/esm/image/cta.svg +9 -0
  15. package/esm/index.d.ts +22 -0
  16. package/esm/plugin/component/cashierApp.d.ts +23 -0
  17. package/esm/plugin/component/cashierApp.js +122 -0
  18. package/esm/plugin/component/component.style.d.ts +8 -0
  19. package/esm/plugin/component/component.style.js +15 -0
  20. package/esm/plugin/component/index.d.ts +102 -0
  21. package/esm/plugin/component/index.js +900 -0
  22. package/esm/plugin/drop-in/index.d.ts +73 -0
  23. package/esm/plugin/drop-in/index.js +323 -0
  24. package/esm/request/index.d.ts +15 -0
  25. package/esm/request/index.js +145 -0
  26. package/esm/request/utils.d.ts +28 -0
  27. package/esm/request/utils.js +59 -0
  28. package/esm/service/index.d.ts +2 -0
  29. package/esm/service/index.js +40 -0
  30. package/esm/types/index.d.ts +216 -0
  31. package/esm/types/index.js +97 -0
  32. package/esm/util/createIframeNode.d.ts +5 -0
  33. package/esm/util/createIframeNode.js +35 -0
  34. package/esm/util/get.d.ts +25 -0
  35. package/esm/util/get.js +145 -0
  36. package/esm/util/index.d.ts +53 -0
  37. package/esm/util/index.js +237 -0
  38. package/esm/util/intl-callapp/es/browser.d.ts +21 -0
  39. package/esm/util/intl-callapp/es/browser.js +42 -0
  40. package/esm/util/intl-callapp/es/evoke.d.ts +13 -0
  41. package/esm/util/intl-callapp/es/evoke.js +39 -0
  42. package/esm/util/intl-callapp/es/generate.d.ts +29 -0
  43. package/esm/util/intl-callapp/es/generate.js +44 -0
  44. package/esm/util/intl-callapp/es/index.d.ts +43 -0
  45. package/esm/util/intl-callapp/es/index.js +298 -0
  46. package/esm/util/intl-callapp/es/main.d.ts +41 -0
  47. package/esm/util/intl-callapp/es/main.js +305 -0
  48. package/esm/util/intl-callapp/es/openWallet.d.ts +15 -0
  49. package/esm/util/intl-callapp/es/openWallet.js +197 -0
  50. package/esm/util/intl-callapp/es/types.d.ts +46 -0
  51. package/esm/util/intl-callapp/es/types.js +1 -0
  52. package/esm/util/intl-callapp/es/utils/config.d.ts +24 -0
  53. package/esm/util/intl-callapp/es/utils/config.js +57 -0
  54. package/esm/util/intl-callapp/es/utils/index.d.ts +15 -0
  55. package/esm/util/intl-callapp/es/utils/index.js +98 -0
  56. package/esm/util/mock.d.ts +1 -0
  57. package/esm/util/mock.js +4 -0
  58. package/package.json +1 -1
@@ -0,0 +1,59 @@
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
+
9
+ import { ERROR } from "../types";
10
+ import { get } from "../util/get";
11
+ export var safeJson = function safeJson(data, obj) {
12
+ try {
13
+ return JSON.parse(data) || obj;
14
+ } catch (_unused) {
15
+ return obj;
16
+ }
17
+ };
18
+
19
+ // 判断header 中的resultStatus
20
+ export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
21
+ var resultStatus = get(headers, 'Result-Status') || get(headers, 'result-status', '');
22
+ // 请求静态数据情况
23
+ if (!resultStatus) return null;
24
+ // 未登录
25
+ if (+resultStatus === 2000) {
26
+ return {
27
+ success: false,
28
+ traceId: traceId,
29
+ errorCode: ERROR.LOGIN,
30
+ resultStatus: resultStatus
31
+ };
32
+ }
33
+ // 网关超时
34
+ if (+resultStatus === 4001) {
35
+ return {
36
+ success: false,
37
+ traceId: traceId,
38
+ errorCode: ERROR.TIMEOUT,
39
+ resultStatus: resultStatus
40
+ };
41
+ }
42
+ if (+resultStatus !== 1000) {
43
+ var tips = get(headers, 'Tips') || get(headers, 'tips', '');
44
+ var memo = get(headers, 'Memo') || get(headers, 'memo', '');
45
+ return {
46
+ success: false,
47
+ traceId: traceId,
48
+ errorCode: ERROR.GATEWAY,
49
+ errorMessage: decodeURIComponent(tips || ''),
50
+ result: {
51
+ resultStatus: resultStatus || '',
52
+ tips: decodeURIComponent(tips || ''),
53
+ memo: decodeURIComponent(memo || '')
54
+ },
55
+ resultStatus: resultStatus
56
+ };
57
+ }
58
+ return null;
59
+ };
@@ -0,0 +1,2 @@
1
+ import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, RequestConfig } from '../types';
2
+ export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: RequestConfig): Promise<CashierSdkActionQueryResult>;
@@ -0,0 +1,40 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ 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); } }
9
+ 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); }); }; }
10
+ /**
11
+ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
12
+ *
13
+ * 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:
14
+ * 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
15
+ * 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.
16
+ */
17
+ import { request } from "../request";
18
+ export function queryPaymentInfo(_x, _x2) {
19
+ return _queryPaymentInfo.apply(this, arguments);
20
+ }
21
+ function _queryPaymentInfo() {
22
+ _queryPaymentInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params, options) {
23
+ var hostSign;
24
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
25
+ while (1) switch (_context.prev = _context.next) {
26
+ case 0:
27
+ hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
28
+ return _context.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
29
+ hostSign: hostSign,
30
+ needEnvInfo: true,
31
+ 'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
32
+ })));
33
+ case 2:
34
+ case "end":
35
+ return _context.stop();
36
+ }
37
+ }, _callee);
38
+ }));
39
+ return _queryPaymentInfo.apply(this, arguments);
40
+ }
@@ -0,0 +1,216 @@
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
+ /**
9
+ * SDK options
10
+ */
11
+ export interface optionsParams {
12
+ environment?: string;
13
+ locale?: string;
14
+ onError?: callOnError;
15
+ onSizeChanged?: callOnSizeChanged;
16
+ onPaymentMethodSelected?: callonPaymentMethodSelected;
17
+ onLog?: callOnLog;
18
+ onEventCallback?: (state: any) => void;
19
+ onClose?: () => void;
20
+ networkMode?: string;
21
+ mode?: string;
22
+ analytics?: {
23
+ enabled: boolean;
24
+ };
25
+ }
26
+ export interface createPaymentParams {
27
+ paymentMethodsResult?: any;
28
+ paymentSessionData?: string;
29
+ selector: string | HTMLElement;
30
+ appearance?: {
31
+ displayType?: checkoutDisplay;
32
+ backgroundColor?: string;
33
+ };
34
+ }
35
+ export declare enum componentSignEnum {
36
+ 'EASY_PAY_WALLET' = "EASY_PAY_WALLET",
37
+ 'CASHIER_PAYMENT_CARD' = "CASHIER_PAYMENT_CARD",
38
+ 'CASHIER_PAYMENT_BANK' = "CASHIER_PAYMENT_BANK",
39
+ 'AUTO_DEBIT_WALLET' = "AUTO_DEBIT_WALLET",
40
+ 'NONE' = "NONE"
41
+ }
42
+ export declare enum productSceneEnum {
43
+ 'EASY_PAY' = "EASY_PAY",
44
+ 'CASHIER_PAYMENT' = "CASHIER_PAYMENT",
45
+ 'AUTO_DEBIT' = "AUTO_DEBIT"
46
+ }
47
+ export declare enum paymentMethodCategoryTypeEnum {
48
+ 'CARD' = "CARD",
49
+ 'WALLET' = "WALLET",
50
+ 'BANK' = "BANK"
51
+ }
52
+ export interface IcreateComponent {
53
+ paymentSessionData: string;
54
+ selector?: string | HTMLElement;
55
+ appearance?: Record<string, any>;
56
+ }
57
+ export interface IappendIframeNodesParams extends IcreateComponent {
58
+ paymentSessionMetaData?: IpaymentSessionMetaData;
59
+ }
60
+ interface IpaymentSessionConfig {
61
+ productScene: productSceneEnum;
62
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
63
+ productSceneVersion: string;
64
+ }
65
+ export interface IpaymentSessionMetaData {
66
+ paymentSessionConfig?: IpaymentSessionConfig;
67
+ moneyView?: any;
68
+ extendInfo?: string;
69
+ paymentMethodInfoView?: any;
70
+ action?: {
71
+ autoDebitWithToken: boolean;
72
+ };
73
+ }
74
+ export declare enum localeEnum {
75
+ 'en-US' = "en-US"
76
+ }
77
+ export declare enum checkoutDisplay {
78
+ horizon = "horizon",
79
+ vertical = "vertical"
80
+ }
81
+ export declare enum mode {
82
+ dropin = "dropin",
83
+ component = "component"
84
+ }
85
+ export declare enum networkMode {
86
+ proxy = "proxy",
87
+ session = "session"
88
+ }
89
+ export interface checkoutState {
90
+ paymentMethodType: string;
91
+ }
92
+ export declare enum environment {
93
+ sandbox = "sandbox",
94
+ prod = "prod",
95
+ light_sandbox = "light_sandbox"
96
+ }
97
+ export declare enum osType {
98
+ IOS = "IOS",
99
+ ANDROID = "ANDROID",
100
+ ELSE = "ELSE"
101
+ }
102
+ export declare enum terminalType {
103
+ WEB = "WEB",
104
+ WAP = "WAP",
105
+ APP = "APP",
106
+ MINI_APP = "MINI_APP"
107
+ }
108
+ export interface env {
109
+ osType?: osType;
110
+ terminalType: terminalType;
111
+ environment: string;
112
+ }
113
+ export type callOnError = (state: {
114
+ errorMessage: string;
115
+ errorCode: string;
116
+ stack?: any;
117
+ }) => void;
118
+ export type callonPaymentMethodSelected = (state: {
119
+ paymentMethodType: string;
120
+ }) => void;
121
+ export type callOnSizeChanged = (state: {
122
+ width: string;
123
+ height: string;
124
+ }) => void;
125
+ export type callOnLog = (state: {
126
+ code: string;
127
+ message: string;
128
+ }) => void;
129
+ export declare enum messageName {
130
+ SDK_TO_APP = "SDK_TO_APP",
131
+ APP_TO_SDK = "APP_TO_SDK",
132
+ APP_TO_APP = "APP_TO_APP"
133
+ }
134
+ export interface eventPlayload {
135
+ name: messageName;
136
+ mode?: string;
137
+ appId?: string;
138
+ instanceId: string;
139
+ context: {
140
+ event: string;
141
+ data: any;
142
+ };
143
+ }
144
+ export interface AMSCheckoutOptions {
145
+ env: env;
146
+ locale: string;
147
+ networkMode: string;
148
+ mode: string;
149
+ analytics?: Ianalytics;
150
+ }
151
+ export interface Ianalytics {
152
+ enabled: boolean;
153
+ }
154
+ export declare enum ERROR {
155
+ PARAMS = "PARAMS",
156
+ TIMEOUT = "TIMEOUT",
157
+ NETWORK = "NETWORK",
158
+ SYSTEM = "SYSTEM",
159
+ LOGIN = "LOGIN",
160
+ GATEWAY = "GATEWAY",
161
+ VALIDATION = "VALIDATION",
162
+ TAOBAOBINDALIPAY = "TAOBAOBINDALIPAY",
163
+ REGISTERWALLET = "REGISTERWALLET",
164
+ NOALIPAYID = "NOALIPAYID",
165
+ TRUSTLOGINERROR = "TRUSTLOGINERROR",
166
+ SIGNIN = "SIGNIN",
167
+ GETSIGNPARAMSERROR = "GETSIGNPARAMSERROR"
168
+ }
169
+ export interface RequestConfig {
170
+ env?: string;
171
+ baseURL?: string;
172
+ timeout?: number;
173
+ headers?: any;
174
+ withCredentials?: boolean;
175
+ method?: string;
176
+ workspaceId?: string;
177
+ 'Operation-Type'?: string;
178
+ beforerRequest?: () => void;
179
+ afterRequest?: () => void;
180
+ needEnvInfo?: boolean;
181
+ locale?: string;
182
+ hostSign?: string;
183
+ }
184
+ export interface CashierSdkActionQueryRequest {
185
+ paymentSessionData: string;
186
+ paymentSessionConfig?: IpaymentSessionConfig;
187
+ paymentMethodType?: string;
188
+ extParams?: any;
189
+ }
190
+ export interface CashierSdkActionQueryResult {
191
+ supportedLanguages?: any[];
192
+ amountConfirmRequired?: boolean;
193
+ orderAmount?: Record<string, string>;
194
+ paymentMethodView?: Record<string, string>;
195
+ autoDebitWithToken?: boolean;
196
+ success: boolean;
197
+ errorCode?: string;
198
+ errorMessage?: string;
199
+ message?: string;
200
+ errorStatus?: string;
201
+ redirectUrl?: string;
202
+ normalUrl?: string;
203
+ applinkUrl?: string;
204
+ schemeUrl?: string;
205
+ authUrl?: string;
206
+ }
207
+ declare global {
208
+ interface Window {
209
+ [key: string]: any;
210
+ }
211
+ }
212
+ export declare enum Target {
213
+ BLANK = "_blank",
214
+ SELF = "_self"
215
+ }
216
+ export {};
@@ -0,0 +1,97 @@
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
+
9
+ /**
10
+ * SDK options
11
+ */
12
+
13
+ export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
14
+ componentSignEnum["EASY_PAY_WALLET"] = "EASY_PAY_WALLET";
15
+ componentSignEnum["CASHIER_PAYMENT_CARD"] = "CASHIER_PAYMENT_CARD";
16
+ componentSignEnum["CASHIER_PAYMENT_BANK"] = "CASHIER_PAYMENT_BANK";
17
+ componentSignEnum["AUTO_DEBIT_WALLET"] = "AUTO_DEBIT_WALLET";
18
+ componentSignEnum["NONE"] = "NONE";
19
+ return componentSignEnum;
20
+ }({});
21
+ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
22
+ productSceneEnum["EASY_PAY"] = "EASY_PAY";
23
+ productSceneEnum["CASHIER_PAYMENT"] = "CASHIER_PAYMENT";
24
+ productSceneEnum["AUTO_DEBIT"] = "AUTO_DEBIT";
25
+ return productSceneEnum;
26
+ }({});
27
+ export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
28
+ paymentMethodCategoryTypeEnum["CARD"] = "CARD";
29
+ paymentMethodCategoryTypeEnum["WALLET"] = "WALLET";
30
+ paymentMethodCategoryTypeEnum["BANK"] = "BANK";
31
+ return paymentMethodCategoryTypeEnum;
32
+ }({});
33
+ export var localeEnum = /*#__PURE__*/function (localeEnum) {
34
+ localeEnum["en-US"] = "en-US";
35
+ return localeEnum;
36
+ }({});
37
+ export var checkoutDisplay = /*#__PURE__*/function (checkoutDisplay) {
38
+ checkoutDisplay["horizon"] = "horizon";
39
+ checkoutDisplay["vertical"] = "vertical";
40
+ return checkoutDisplay;
41
+ }({});
42
+ export var mode = /*#__PURE__*/function (mode) {
43
+ mode["dropin"] = "dropin";
44
+ mode["component"] = "component";
45
+ return mode;
46
+ }({});
47
+ export var networkMode = /*#__PURE__*/function (networkMode) {
48
+ networkMode["proxy"] = "proxy";
49
+ networkMode["session"] = "session";
50
+ return networkMode;
51
+ }({});
52
+ export var environment = /*#__PURE__*/function (environment) {
53
+ environment["sandbox"] = "sandbox";
54
+ environment["prod"] = "prod";
55
+ environment["light_sandbox"] = "light_sandbox";
56
+ return environment;
57
+ }({});
58
+ export var osType = /*#__PURE__*/function (osType) {
59
+ osType["IOS"] = "IOS";
60
+ osType["ANDROID"] = "ANDROID";
61
+ osType["ELSE"] = "ELSE";
62
+ return osType;
63
+ }({});
64
+ export var terminalType = /*#__PURE__*/function (terminalType) {
65
+ terminalType["WEB"] = "WEB";
66
+ terminalType["WAP"] = "WAP";
67
+ terminalType["APP"] = "APP";
68
+ terminalType["MINI_APP"] = "MINI_APP";
69
+ return terminalType;
70
+ }({});
71
+ export var messageName = /*#__PURE__*/function (messageName) {
72
+ messageName["SDK_TO_APP"] = "SDK_TO_APP";
73
+ messageName["APP_TO_SDK"] = "APP_TO_SDK";
74
+ messageName["APP_TO_APP"] = "APP_TO_APP";
75
+ return messageName;
76
+ }({});
77
+ export var ERROR = /*#__PURE__*/function (ERROR) {
78
+ ERROR["PARAMS"] = "PARAMS";
79
+ ERROR["TIMEOUT"] = "TIMEOUT";
80
+ ERROR["NETWORK"] = "NETWORK";
81
+ ERROR["SYSTEM"] = "SYSTEM";
82
+ ERROR["LOGIN"] = "LOGIN";
83
+ ERROR["GATEWAY"] = "GATEWAY";
84
+ ERROR["VALIDATION"] = "VALIDATION";
85
+ ERROR["TAOBAOBINDALIPAY"] = "TAOBAOBINDALIPAY";
86
+ ERROR["REGISTERWALLET"] = "REGISTERWALLET";
87
+ ERROR["NOALIPAYID"] = "NOALIPAYID";
88
+ ERROR["TRUSTLOGINERROR"] = "TRUSTLOGINERROR";
89
+ ERROR["SIGNIN"] = "SIGNIN";
90
+ ERROR["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
91
+ return ERROR;
92
+ }({});
93
+ export var Target = /*#__PURE__*/function (Target) {
94
+ Target["BLANK"] = "_blank";
95
+ Target["SELF"] = "_self";
96
+ return Target;
97
+ }({});
@@ -0,0 +1,5 @@
1
+ import { createPaymentParams, IcreateComponent } from '../types';
2
+ /**
3
+ * @description context中需要包含app节点,用于插入params.selector中
4
+ */
5
+ export declare const createIframeNode: (context: any, params: createPaymentParams | IcreateComponent) => Promise<void>;
@@ -0,0 +1,35 @@
1
+ import { getType } from '.';
2
+ import { ERRORMESSAGE, EVENT } from "../constant";
3
+ import { messageName } from "../types";
4
+ /**
5
+ * @description context中需要包含app节点,用于插入params.selector中
6
+ */
7
+ export var createIframeNode = function createIframeNode(context, params) {
8
+ return new Promise(function (resolve, reject) {
9
+ var dorpinDom = null;
10
+ if (getType(params.selector) === 'string') {
11
+ dorpinDom = document.querySelector(params.selector);
12
+ }
13
+ if (dorpinDom === null) {
14
+ var error = {
15
+ errorCode: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.errorCode,
16
+ errorMessage: "Failed to execute 'querySelector' on 'Document': ".concat(params.selector, " is not a valid selector")
17
+ };
18
+ reject(error);
19
+ context._dispatchToSDK({
20
+ name: messageName.APP_TO_SDK,
21
+ instanceId: context.AMSSDK._instanceId,
22
+ context: {
23
+ event: EVENT.error.name,
24
+ data: error
25
+ }
26
+ });
27
+ return;
28
+ }
29
+ dorpinDom.innerHTML = '';
30
+ if (context.app) {
31
+ dorpinDom.appendChild(context.app);
32
+ }
33
+ resolve();
34
+ });
35
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Gets the value at `path` of `object`. If the resolved value is
3
+ * `undefined`, the `defaultValue` is returned in its place.
4
+ *
5
+ * @since 3.7.0
6
+ * @category Object
7
+ * @param {Object} object The object to query.
8
+ * @param {Array|string} path The path of the property to get.
9
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
10
+ * @returns {*} Returns the resolved value.
11
+ * @see has, hasIn, set, unset
12
+ * @example
13
+ *
14
+ * const object = { 'a': [{ 'b': { 'c': 3 } }] }
15
+ *
16
+ * get(object, 'a[0].b.c')
17
+ * // => 3
18
+ *
19
+ * get(object, ['a', '0', 'b', 'c'])
20
+ * // => 3
21
+ *
22
+ * get(object, 'a.b.c', 'default')
23
+ * // => 'default'
24
+ */
25
+ export declare function get(object: any, path: string, defaultValue?: any): any;
@@ -0,0 +1,145 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-nocheck
4
+ var charCodeOfDot = '.'.charCodeAt(0);
5
+ var reEscapeChar = /\\(\\)?/g;
6
+ var rePropName = RegExp(
7
+ // Match anything that isn't a dot or bracket.
8
+ '[^.[\\]]+' + '|' +
9
+ // Or match property names within brackets.
10
+ '\\[(?:' +
11
+ // Match a non-string expression.
12
+ '([^"\'][^[]*)' + '|' +
13
+ // Or match strings (supports escaping characters).
14
+ '(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2' + ')\\]' + '|' +
15
+ // Or match "" as the space between consecutive dots or empty brackets.
16
+ '(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))', 'g');
17
+
18
+ /**
19
+ * Converts `string` to a property path array.
20
+ *
21
+ * @private
22
+ * @param {string} string The string to convert.
23
+ * @returns {Array} Returns the property path array.
24
+ */
25
+ var stringToPath = function stringToPath(string) {
26
+ var result = [];
27
+ if (string.charCodeAt(0) === charCodeOfDot) {
28
+ result.push('');
29
+ }
30
+ string.replace(rePropName, function (match, expression, quote, subString) {
31
+ var key = match;
32
+ if (quote) {
33
+ key = subString.replace(reEscapeChar, '$1');
34
+ } else if (expression) {
35
+ key = expression.trim();
36
+ }
37
+ result.push(key);
38
+ return '';
39
+ });
40
+ return result;
41
+ };
42
+
43
+ /** Used to match property names within property paths. */
44
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
45
+ var reIsPlainProp = /^\w*$/;
46
+
47
+ /**
48
+ * Checks if `value` is a property name and not a property path.
49
+ *
50
+ * @private
51
+ * @param {*} value The value to check.
52
+ * @param {Object} [object] The object to query keys on.
53
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
54
+ */
55
+ function isKey(value, object) {
56
+ if (Array.isArray(value)) {
57
+ return false;
58
+ }
59
+ var type = _typeof(value);
60
+ if (type === 'number' || type === 'boolean' || value === null) {
61
+ return true;
62
+ }
63
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object !== null && value in Object(object);
64
+ }
65
+
66
+ /** Used as references for various `Number` constants. */
67
+ var INFINITY = 1 / 0;
68
+
69
+ /**
70
+ * Converts `value` to a string key if it's not a string or symbol.
71
+ *
72
+ * @private
73
+ * @param {*} value The value to inspect.
74
+ * @returns {string|symbol} Returns the key.
75
+ */
76
+ function toKey(value) {
77
+ if (typeof value === 'string') {
78
+ return value;
79
+ }
80
+ var result = "".concat(value);
81
+ return result === '0' && 1 / value === -INFINITY ? '-0' : result;
82
+ }
83
+
84
+ /**
85
+ * Casts `value` to a path array if it's not one.
86
+ *
87
+ * @private
88
+ * @param {*} value The value to inspect.
89
+ * @param {Object} [object] The object to query keys on.
90
+ * @returns {Array} Returns the cast property path array.
91
+ */
92
+ function castPath(value, object) {
93
+ if (Array.isArray(value)) {
94
+ return value;
95
+ }
96
+ return isKey(value, object) ? [value] : stringToPath(value);
97
+ }
98
+
99
+ /**
100
+ * The base implementation of `get` without support for default values.
101
+ *
102
+ * @private
103
+ * @param {Object} object The object to query.
104
+ * @param {Array|string} path The path of the property to get.
105
+ * @returns {*} Returns the resolved value.
106
+ */
107
+ function baseGet(object, path) {
108
+ var pathList = castPath(path, object);
109
+ var index = 0;
110
+ var length = pathList.length;
111
+ var _object = object;
112
+ while (_object !== null && index < length) {
113
+ _object = _object[toKey(pathList[index++])];
114
+ }
115
+ return index && index === length ? _object : undefined;
116
+ }
117
+
118
+ /**
119
+ * Gets the value at `path` of `object`. If the resolved value is
120
+ * `undefined`, the `defaultValue` is returned in its place.
121
+ *
122
+ * @since 3.7.0
123
+ * @category Object
124
+ * @param {Object} object The object to query.
125
+ * @param {Array|string} path The path of the property to get.
126
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
127
+ * @returns {*} Returns the resolved value.
128
+ * @see has, hasIn, set, unset
129
+ * @example
130
+ *
131
+ * const object = { 'a': [{ 'b': { 'c': 3 } }] }
132
+ *
133
+ * get(object, 'a[0].b.c')
134
+ * // => 3
135
+ *
136
+ * get(object, ['a', '0', 'b', 'c'])
137
+ * // => 3
138
+ *
139
+ * get(object, 'a.b.c', 'default')
140
+ * // => 'default'
141
+ */
142
+ export function get(object, path, defaultValue) {
143
+ var result = object === null ? undefined : baseGet(object, path);
144
+ return result === undefined ? defaultValue : result;
145
+ }