@alipay/ams-checkout 1.3.1-dev → 1.3.1

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 (57) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/package.json +1 -54
  3. package/dist/esm/config/index.d.ts +0 -22
  4. package/dist/esm/config/index.js +0 -69
  5. package/dist/esm/constant/index.d.ts +0 -135
  6. package/dist/esm/constant/index.js +0 -135
  7. package/dist/esm/core/component/index.d.ts +0 -17
  8. package/dist/esm/core/component/index.js +0 -127
  9. package/dist/esm/core/drop-in/index.d.ts +0 -29
  10. package/dist/esm/core/drop-in/index.js +0 -104
  11. package/dist/esm/core/instance/index.d.ts +0 -67
  12. package/dist/esm/core/instance/index.js +0 -276
  13. package/dist/esm/image/cta.svg +0 -9
  14. package/dist/esm/index.d.ts +0 -22
  15. package/dist/esm/plugin/component/cashierApp.d.ts +0 -24
  16. package/dist/esm/plugin/component/cashierApp.js +0 -140
  17. package/dist/esm/plugin/component/component.style.d.ts +0 -8
  18. package/dist/esm/plugin/component/component.style.js +0 -15
  19. package/dist/esm/plugin/component/index.d.ts +0 -101
  20. package/dist/esm/plugin/component/index.js +0 -875
  21. package/dist/esm/plugin/drop-in/index.d.ts +0 -73
  22. package/dist/esm/plugin/drop-in/index.js +0 -323
  23. package/dist/esm/request/index.d.ts +0 -15
  24. package/dist/esm/request/index.js +0 -145
  25. package/dist/esm/request/utils.d.ts +0 -28
  26. package/dist/esm/request/utils.js +0 -59
  27. package/dist/esm/service/index.d.ts +0 -2
  28. package/dist/esm/service/index.js +0 -40
  29. package/dist/esm/types/index.d.ts +0 -194
  30. package/dist/esm/types/index.js +0 -94
  31. package/dist/esm/util/createIframeNode.d.ts +0 -5
  32. package/dist/esm/util/createIframeNode.js +0 -35
  33. package/dist/esm/util/get.d.ts +0 -25
  34. package/dist/esm/util/get.js +0 -145
  35. package/dist/esm/util/index.d.ts +0 -53
  36. package/dist/esm/util/index.js +0 -235
  37. package/dist/esm/util/intl-callapp/es/browser.d.ts +0 -21
  38. package/dist/esm/util/intl-callapp/es/browser.js +0 -42
  39. package/dist/esm/util/intl-callapp/es/evoke.d.ts +0 -13
  40. package/dist/esm/util/intl-callapp/es/evoke.js +0 -39
  41. package/dist/esm/util/intl-callapp/es/generate.d.ts +0 -29
  42. package/dist/esm/util/intl-callapp/es/generate.js +0 -44
  43. package/dist/esm/util/intl-callapp/es/index.d.ts +0 -43
  44. package/dist/esm/util/intl-callapp/es/index.js +0 -298
  45. package/dist/esm/util/intl-callapp/es/main.d.ts +0 -41
  46. package/dist/esm/util/intl-callapp/es/main.js +0 -305
  47. package/dist/esm/util/intl-callapp/es/openWallet.d.ts +0 -15
  48. package/dist/esm/util/intl-callapp/es/openWallet.js +0 -197
  49. package/dist/esm/util/intl-callapp/es/types.d.ts +0 -46
  50. package/dist/esm/util/intl-callapp/es/types.js +0 -1
  51. package/dist/esm/util/intl-callapp/es/utils/config.d.ts +0 -24
  52. package/dist/esm/util/intl-callapp/es/utils/config.js +0 -57
  53. package/dist/esm/util/intl-callapp/es/utils/index.d.ts +0 -15
  54. package/dist/esm/util/intl-callapp/es/utils/index.js +0 -98
  55. package/dist/esm/util/mock.d.ts +0 -1
  56. package/dist/esm/util/mock.js +0 -4
  57. /package/{dist/esm → esm}/index.js +0 -0
@@ -1,104 +0,0 @@
1
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
- /**
5
- * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
6
- *
7
- * 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:
8
- * 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
9
- * 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.
10
- */
11
-
12
- import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
13
- import CheckoutApp from "../../plugin/drop-in";
14
- import { messageName, networkMode } from "../../types";
15
- import { createIframeNode } from "../../util/createIframeNode";
16
- export var mixinDropInConstructor = function mixinDropInConstructor(options, context) {
17
- // Instantiate the plug-in and set render
18
- var checkoutPlugin = new CheckoutApp();
19
- checkoutPlugin.setRender(createIframeNode);
20
- // Register Cashier Application Plug in
21
- context._registerPlugin(BASEPLUGINID, checkoutPlugin);
22
- context._subscribeFromCheckoutPlugin();
23
- };
24
-
25
- /**
26
- * @description Create checkout application
27
- * @description drop-in
28
- */
29
- export var createPayment = function createPayment(params) {
30
- var _this = this;
31
- if (this.options.networkMode === networkMode.proxy) {
32
- return new Promise(function (resolve, reject) {
33
- try {
34
- var checkoutApp = _this._getPlugin(BASEPLUGINID);
35
- resolve(checkoutApp.render(params));
36
- } catch (error) {
37
- reject(error);
38
- }
39
- });
40
- } else {
41
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
42
- return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
43
- }
44
- };
45
- /**
46
- * @description Take action on the interface result of payment submission
47
- * @description drop-in
48
- */
49
- export var confirmPayment = function confirmPayment(result) {
50
- var _this2 = this;
51
- return new Promise(function (resolve, reject) {
52
- _this2.eventCenter.once('onRedirect', function (playload) {
53
- _this2._redirect(playload).then(function () {
54
- resolve();
55
- }).catch(function (err) {
56
- reject(err);
57
- });
58
- });
59
- _this2.eventCenter.emit("".concat(BASEPLUGINID, "-handleRequestPayment"), {
60
- name: messageName.SDK_TO_APP,
61
- mode: _this2.options.mode,
62
- appId: BASEPLUGINID,
63
- instanceId: _this2._instanceId,
64
- context: {
65
- event: 'handleRequestPayment',
66
- data: result
67
- }
68
- });
69
- });
70
- };
71
- /**
72
- * @description Subscribe to the message of the cashier application plug-in
73
- */
74
- export var _subscribeFromCheckoutPlugin = function _subscribeFromCheckoutPlugin() {
75
- var _this3 = this;
76
- var eventKeyMap = new Map([[EVENT.error.name, function (playload) {
77
- _this3.eventCenter.emit(EVENT.error.name, playload.context.data);
78
- }], [EVENT.ready.name, function (playload) {
79
- _this3.eventCenter.emit(EVENT.ready.name, playload.context.data);
80
- }], [EVENT.redirect.name, function (playload) {
81
- _this3.eventCenter.emit(EVENT.redirect.name, playload.context.data);
82
- }], [EVENT.paymentMethodSelected.name, function (playload) {
83
- _this3.checkoutState.paymentMethodType = playload.context.data.paymentMethodType;
84
- _this3.eventCenter.emit(EVENT.paymentMethodSelected.name, {
85
- paymentMethodType: playload.context.data.paymentMethodType
86
- });
87
- }], [EVENT.sizeChanged.name, function (playload) {
88
- _this3.eventCenter.emit(EVENT.sizeChanged.name, playload.context.data);
89
- }], [EVENT.log.name, function (playload) {
90
- _this3.eventCenter.emit(EVENT.log.name, playload.context.data);
91
- }]]);
92
- var _iterator = _createForOfIteratorHelper(eventKeyMap.keys()),
93
- _step;
94
- try {
95
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
96
- var key = _step.value;
97
- this.eventCenter.on("".concat(BASEPLUGINID, "-").concat(key), eventKeyMap.get(key));
98
- }
99
- } catch (err) {
100
- _iterator.e(err);
101
- } finally {
102
- _iterator.f();
103
- }
104
- };
@@ -1,67 +0,0 @@
1
- import type { AMSCheckoutOptions, callOnError, callOnSizeChanged, checkoutState, optionsParams } from '../../types/index';
2
- import { EventCenter } from '../../util/index';
3
- export default class AMSSDK {
4
- options: AMSCheckoutOptions;
5
- checkoutState: checkoutState;
6
- eventCenter: EventCenter;
7
- protected plugins: Map<string, any>;
8
- _instanceId: string;
9
- constructor(options: optionsParams);
10
- /**
11
- * @description Destroy and process some contents of the plug-in
12
- */
13
- destroy(): void;
14
- /**
15
- * @description Set the sdk basic configuration
16
- */
17
- private _setOptions;
18
- /**
19
- * @description Set environment variables
20
- */
21
- private _setEnv;
22
- /**
23
- * @description Set UI and Network Mode
24
- */
25
- private _setMode;
26
- /**
27
- * @description Initialize event related tasks
28
- */
29
- private _initEvent;
30
- /**
31
- * @description Register plug-in
32
- */
33
- protected _registerPlugin(pluginId: string, plugin: any): void;
34
- /**
35
- * @description Get Plug-in
36
- */
37
- _getPlugin(pluginId: string): any;
38
- /**
39
- * @description Execute to open app or jump link
40
- */
41
- _redirect(data: {
42
- normalUrl?: string;
43
- schemeUrl?: string;
44
- applinkUrl?: string;
45
- }): Promise<void>;
46
- /**
47
- * @description Overlay Subscription
48
- */
49
- protected _overrideSubscription(name: string, func: any, funcKey: string): void;
50
- /**
51
- * @description Create an event handler, called when an error occurs in AMSCheckout.
52
- */
53
- onError(event: callOnError): void;
54
- /**
55
- * @description Create an event handler, called when the checkout view is available for interaction.
56
- * mode: dropin
57
- */
58
- /**
59
- * @description Create an event handler, called after the user selects the payment method
60
- * mode: dropin
61
- */
62
- /**
63
- * @description Create an event handler
64
- */
65
- onSizeChanged(event: callOnSizeChanged): void;
66
- onLog(event: callOnSizeChanged): void;
67
- }
@@ -1,276 +0,0 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
- 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); }
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 { v4 as uuid } from 'uuid';
19
- import { ERRORMESSAGE, EVENT } from "../../constant";
20
- import { environment, mode, networkMode, osType, terminalType } from "../../types/index";
21
- import { device, EventCenter, getType, queryParse } from "../../util/index";
22
- import CallApp from "../../util/intl-callapp/es/main";
23
- var AMSSDK = /*#__PURE__*/function () {
24
- function AMSSDK(options) {
25
- _classCallCheck(this, AMSSDK);
26
- _defineProperty(this, "options", void 0);
27
- _defineProperty(this, "checkoutState", void 0);
28
- _defineProperty(this, "eventCenter", void 0);
29
- _defineProperty(this, "plugins", void 0);
30
- _defineProperty(this, "_instanceId", void 0);
31
- this._instanceId = uuid();
32
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
33
- this.options = {};
34
- this.eventCenter = new EventCenter();
35
- this.checkoutState = {
36
- paymentMethodType: ''
37
- };
38
- this._initEvent(options);
39
- this._setOptions(options);
40
- this.plugins = new Map();
41
- }
42
- /**
43
- * @description Destroy and process some contents of the plug-in
44
- */
45
- _createClass(AMSSDK, [{
46
- key: "destroy",
47
- value: function destroy() {
48
- var _iterator = _createForOfIteratorHelper(this.plugins.values()),
49
- _step;
50
- try {
51
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
52
- var plugin = _step.value;
53
- try {
54
- plugin.logoutPlugin();
55
- // eslint-disable-next-line no-empty
56
- } catch (error) {}
57
- }
58
- } catch (err) {
59
- _iterator.e(err);
60
- } finally {
61
- _iterator.f();
62
- }
63
- }
64
- /**
65
- * @description Set the sdk basic configuration
66
- */
67
- }, {
68
- key: "_setOptions",
69
- value: function _setOptions(options) {
70
- this._setMode(options);
71
- this._setEnv(options);
72
- this.options.locale = (options === null || options === void 0 ? void 0 : options.locale) || '';
73
- }
74
- /**
75
- * @description Set environment variables
76
- */
77
- }, {
78
- key: "_setEnv",
79
- value: function _setEnv(options) {
80
- var _queryParse = queryParse(),
81
- _moreEnv = _queryParse._moreEnv;
82
- if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in environment) && _moreEnv !== 'true') {
83
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.errorMessage);
84
- options.environment = 'prod';
85
- }
86
- this.options.env = {
87
- terminalType: device.isMobile ? terminalType.WAP : terminalType.WEB,
88
- environment: (options === null || options === void 0 ? void 0 : options.environment) || 'prod'
89
- };
90
- if (this.options.env.terminalType === terminalType.WAP) {
91
- // eslint-disable-next-line no-nested-ternary
92
- this.options.env.osType = device.iOS ? osType.IOS : device.Android ? osType.ANDROID : osType.ELSE;
93
- }
94
- }
95
- /**
96
- * @description Set UI and Network Mode
97
- */
98
- }, {
99
- key: "_setMode",
100
- value: function _setMode(options) {
101
- this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) || mode.dropin;
102
- if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in mode)) {
103
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.errorMessage);
104
- this.options.mode = mode.component;
105
- }
106
- this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) || networkMode.session;
107
- if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in networkMode)) {
108
- console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
109
- this.options.networkMode = networkMode.proxy;
110
- }
111
- }
112
- /**
113
- * @description Initialize event related tasks
114
- */
115
- }, {
116
- key: "_initEvent",
117
- value: function _initEvent(options) {
118
- if (options !== null && options !== void 0 && options.onError) {
119
- if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
120
- this._overrideSubscription(EVENT.error.name, options.onError, EVENT.error.uniqueKey);
121
- }
122
- if (options !== null && options !== void 0 && options.onPaymentMethodSelected) {
123
- if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
124
- this._overrideSubscription(EVENT.paymentMethodSelected.name, options.onPaymentMethodSelected, EVENT.paymentMethodSelected.uniqueKey);
125
- }
126
- if (options !== null && options !== void 0 && options.onReady) {
127
- if (getType(options.onReady) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
128
- this._overrideSubscription(EVENT.ready.name, options.onReady, EVENT.ready.uniqueKey);
129
- }
130
- if (options !== null && options !== void 0 && options.onSizeChanged) {
131
- if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
132
- this._overrideSubscription(EVENT.sizeChanged.name, options.onSizeChanged, EVENT.sizeChanged.uniqueKey);
133
- }
134
- if (options !== null && options !== void 0 && options.onLog) {
135
- if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
136
- this._overrideSubscription(EVENT.log.name, options.onLog, EVENT.log.uniqueKey);
137
- }
138
- if (options !== null && options !== void 0 && options.onEventCallback) {
139
- if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
140
- this._overrideSubscription(EVENT.eventCallback.name, options.onEventCallback, EVENT.eventCallback.uniqueKey);
141
- }
142
- if (options !== null && options !== void 0 && options.onClose) {
143
- if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
144
- this._overrideSubscription(EVENT.onClose.name, options.onClose, EVENT.onClose.uniqueKey);
145
- }
146
- }
147
- /**
148
- * @description Register plug-in
149
- */
150
- }, {
151
- key: "_registerPlugin",
152
- value: function _registerPlugin(pluginId, plugin) {
153
- this.plugins.set(pluginId, plugin);
154
- try {
155
- plugin.applyPlugin(this);
156
- } catch (error) {
157
- this.plugins.delete(pluginId);
158
- if (getType(error) === 'error') throw error;
159
- throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
160
- }
161
- }
162
- /**
163
- * @description Get Plug-in
164
- */
165
- }, {
166
- key: "_getPlugin",
167
- value: function _getPlugin(pluginId) {
168
- if (!this.plugins.has(pluginId)) {
169
- console.warn("".concat(pluginId, "Plugin unregistered"));
170
- return null;
171
- }
172
- return this.plugins.get(pluginId);
173
- }
174
- /**
175
- * @description Execute to open app or jump link
176
- */
177
- }, {
178
- key: "_redirect",
179
- value: function _redirect(data) {
180
- var _this = this;
181
- return new Promise(function (resolve, reject) {
182
- var isWeb = _this.options.env.terminalType === terminalType.WEB;
183
- var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';
184
- var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';
185
- var applinkUrl = (data === null || data === void 0 ? void 0 : data.applinkUrl) || '';
186
- var jumpFunc = function jumpFunc() {
187
- if (normalUrl) {
188
- resolve();
189
- window.location.href = normalUrl;
190
- return;
191
- }
192
- reject(ERRORMESSAGE.SDK_CALL_URL_ERROR.REDIRECT_ERROR);
193
- };
194
- var callAppFunc = function callAppFunc() {
195
- if (!schemeUrl && !applinkUrl) {
196
- jumpFunc();
197
- return;
198
- }
199
- var config = {
200
- fallback: function fallback() {
201
- jumpFunc();
202
- },
203
- successCb: function successCb() {
204
- resolve();
205
- },
206
- delay: 0
207
- };
208
- try {
209
- var callLib = new CallApp(config);
210
- callLib.open({
211
- scheme: schemeUrl,
212
- link: applinkUrl
213
- });
214
- } catch (error) {
215
- jumpFunc();
216
- }
217
- };
218
- if (isWeb) {
219
- jumpFunc();
220
- } else {
221
- callAppFunc();
222
- }
223
- });
224
- }
225
- /**
226
- * @description Overlay Subscription
227
- */
228
- }, {
229
- key: "_overrideSubscription",
230
- value: function _overrideSubscription(name, func, funcKey) {
231
- this.eventCenter.off(name, func, funcKey);
232
- this.eventCenter.on(name, func, funcKey);
233
- }
234
- /**
235
- * @description Create an event handler, called when an error occurs in AMSCheckout.
236
- */
237
- }, {
238
- key: "onError",
239
- value: function onError(event) {
240
- this._overrideSubscription(EVENT.error.name, event, EVENT.error.uniqueKey);
241
- }
242
- /**
243
- * @description Create an event handler, called when the checkout view is available for interaction.
244
- * mode: dropin
245
- */
246
- // onReady(event: () => void) {
247
- // this._overrideSubscription(EVENT.ready.name, event, EVENT.ready.uniqueKey);
248
- // }
249
- /**
250
- * @description Create an event handler, called after the user selects the payment method
251
- * mode: dropin
252
- */
253
- // onPaymentMethodSelected(event: callonPaymentMethodSelected) {
254
- // this._overrideSubscription(
255
- // EVENT.paymentMethodSelected.name,
256
- // event,
257
- // EVENT.paymentMethodSelected.uniqueKey,
258
- // );
259
- // }
260
- /**
261
- * @description Create an event handler
262
- */
263
- }, {
264
- key: "onSizeChanged",
265
- value: function onSizeChanged(event) {
266
- this._overrideSubscription(EVENT.sizeChanged.name, event, EVENT.sizeChanged.uniqueKey);
267
- }
268
- }, {
269
- key: "onLog",
270
- value: function onLog(event) {
271
- this._overrideSubscription(EVENT.log.name, event, EVENT.log.uniqueKey);
272
- }
273
- }]);
274
- return AMSSDK;
275
- }();
276
- export { AMSSDK as default };
@@ -1,9 +0,0 @@
1
- <svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="">
2
- <path d="M-9.61651e-07 22C-1.49276e-06 9.84974 9.84973 -4.30546e-07 22 -9.61651e-07C34.1503 -1.49276e-06 44 9.84973 44 22C44 34.1503 34.1503 44 22 44C9.84974 44 -4.30546e-07 34.1503 -9.61651e-07 22ZM4 22C4 31.9411 12.0589 40 22 40C31.9411 40 40 31.9411 40 22C40 12.0589 31.9411 4 22 4C12.0589 4 4 12.0589 4 22Z" fill="url(#paint0_angular_2884_126722)"/>
3
- <defs>
4
- <radialGradient id="paint0_angular_2884_126722" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(22 22) rotate(180) scale(22)">
5
- <stop stop-color="#889CB8"/>
6
- <stop offset="1" stop-color="#CFD8E5" stop-opacity="0"/>
7
- </radialGradient>
8
- </defs>
9
- </svg>
@@ -1,22 +0,0 @@
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 { IcreateComponentFunc } from './core/component/index';
9
- import { IconfirmPaymentFunc, IcreatePaymentFunc } from './core/drop-in/index';
10
- import AMSSDK from './core/instance';
11
- import { optionsParams } from './types';
12
- export * from './types';
13
- export declare class AMSCheckout extends AMSSDK {
14
- createComponent: IcreateComponentFunc;
15
- createPayment: IcreatePaymentFunc;
16
- confirmPayment: IconfirmPaymentFunc;
17
- constructor(options: optionsParams);
18
- }
19
- export declare class AMSAutoDebit extends AMSCheckout {
20
- constructor(options: optionsParams);
21
- }
22
- export default AMSCheckout;
@@ -1,24 +0,0 @@
1
- import { Ianalytics } from '../../types';
2
- export declare const getAppPath: (environment: string | undefined, appVersion: string, componentName: string, productSceneVersion: string, extendInfo: string) => any;
3
- export declare const getAppDomain: (domainParams: {
4
- environment: string;
5
- appVersion: string;
6
- componentName: string;
7
- productSceneVersion: string;
8
- extendInfo: string;
9
- }) => string;
10
- export declare const getIframeUrl: (iframeParams: {
11
- componentName: string;
12
- appearance: Record<string, string>;
13
- analytics?: Ianalytics;
14
- productSceneVersion: string;
15
- environment: string;
16
- appVersion: string;
17
- extendInfo: string;
18
- locale: string;
19
- instanceId: string;
20
- }) => string;
21
- /**
22
- * @description Create iframe
23
- */
24
- export declare const createIframe: (UIMode: string) => HTMLIFrameElement;
@@ -1,140 +0,0 @@
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 _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; }
3
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
- 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); }
5
- /**
6
- * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
7
- *
8
- * 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:
9
- * 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
10
- * 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.
11
- */
12
- import json from "../../../package.json";
13
- import { componentNameEnum } from "../../types";
14
- import { getViewPort, queryParse, serialize } from "../../util/index";
15
- export var getAppPath = function getAppPath() {
16
- var _componentMap;
17
- var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
18
- var appVersion = arguments.length > 1 ? arguments[1] : undefined;
19
- var componentName = arguments.length > 2 ? arguments[2] : undefined;
20
- var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
21
- var extendInfo = arguments.length > 4 ? arguments[4] : undefined;
22
- var _ref = queryParse() || {},
23
- urlTestHost = _ref.host,
24
- _ref$_appVersion = _ref._appVersion,
25
- _appVersion = _ref$_appVersion === void 0 ? '' : _ref$_appVersion;
26
- var host = '';
27
- var getAppVersion = function getAppVersion(_extendInfo) {
28
- try {
29
- // Configure the specified version number
30
- if (_appVersion && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) return _appVersion;
31
- var info = JSON.parse(_extendInfo);
32
- return info.versionMap.web[json.version].targetWebVerison || appVersion;
33
- } catch (error) {
34
- return appVersion;
35
- }
36
- };
37
- var marmptMap = {
38
- dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
39
- sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
40
- pre: 'https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app',
41
- sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
42
- light_sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
43
- prod: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app'
44
- };
45
- var finalAppVersion = getAppVersion(extendInfo);
46
- var getFinalProductSceneVersion = function getFinalProductSceneVersion(supportProductSceneVersion) {
47
- // 从左到右,从旧到新
48
- var isSupport = supportProductSceneVersion.find(function (it) {
49
- return it === productSceneVersion;
50
- });
51
- var finalProductSceneVersion = supportProductSceneVersion[supportProductSceneVersion.length - 1];
52
- if (isSupport) finalProductSceneVersion = productSceneVersion;
53
- return finalProductSceneVersion;
54
- };
55
- var componentMap = (_componentMap = {}, _defineProperty(_componentMap, componentNameEnum.card, function () {
56
- host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.card, "/index.").concat(finalAppVersion, ".html");
57
- }), _defineProperty(_componentMap, componentNameEnum.easyPay, function () {
58
- var finalProductSceneVersion = getFinalProductSceneVersion(['1.0', '2.0']);
59
- host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.easyPay, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
60
- }), _defineProperty(_componentMap, componentNameEnum.autoDebit, function () {
61
- var finalProductSceneVersion = getFinalProductSceneVersion(['1.0']);
62
- host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.autoDebit, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
63
- }), _componentMap);
64
- if (componentMap[componentName]) componentMap[componentName]();
65
- // only for test while testurl?host=https://xxxxx.test.html
66
- if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
67
- return urlTestHost;
68
- }
69
- return host;
70
- };
71
- export var getAppDomain = function getAppDomain(domainParams) {
72
- var environment = domainParams.environment,
73
- appVersion = domainParams.appVersion,
74
- componentName = domainParams.componentName,
75
- productSceneVersion = domainParams.productSceneVersion,
76
- extendInfo = domainParams.extendInfo;
77
- var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
78
- var macth = reg.exec(getAppPath(environment, appVersion, componentName, productSceneVersion, extendInfo));
79
- return macth && macth[0] || '';
80
- };
81
- export var getIframeUrl = function getIframeUrl(iframeParams) {
82
- var componentName = iframeParams.componentName,
83
- appearance = iframeParams.appearance,
84
- _iframeParams$analyti = iframeParams.analytics,
85
- analytics = _iframeParams$analyti === void 0 ? {
86
- enabled: true
87
- } : _iframeParams$analyti,
88
- productSceneVersion = iframeParams.productSceneVersion,
89
- environment = iframeParams.environment,
90
- appVersion = iframeParams.appVersion,
91
- extendInfo = iframeParams.extendInfo,
92
- locale = iframeParams.locale,
93
- instanceId = iframeParams.instanceId;
94
- var path = getAppPath(environment, appVersion, componentName, productSceneVersion, extendInfo || '');
95
- var scale = getViewPort('initial-scale') || 1;
96
- var _queryParse = queryParse(),
97
- _sandbox = _queryParse._sandbox,
98
- _light_sandbox = _queryParse._light_sandbox,
99
- _queryParse$requestHo = _queryParse.requestHost,
100
- requestHost = _queryParse$requestHo === void 0 ? '' : _queryParse$requestHo,
101
- _queryParse$groupId = _queryParse.groupId,
102
- groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
103
- LOCAL_MOCK = _queryParse.LOCAL_MOCK;
104
- var urlParams = Object.assign({
105
- locale: locale,
106
- scale: scale,
107
- instanceId: instanceId,
108
- sandbox: environment === 'light_sandbox' || _light_sandbox === 'true' ? 'true' : 'false',
109
- analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
110
- sdkVersion: json.version,
111
- refUrl: window.location.href,
112
- shadow: environment === 'sandbox' || _sandbox === 'true' ? 'true' : 'false',
113
- requestHost: requestHost,
114
- groupId: groupId,
115
- LOCAL_MOCK: LOCAL_MOCK
116
- }, appearance);
117
- var locationSearch = serialize(urlParams);
118
- return "".concat(path, "?").concat(locationSearch);
119
- };
120
- var getIframeId = function getIframeId(UIMode) {
121
- var IdMap = {
122
- dropin: 'checkout-dropin',
123
- component: 'checkout-component'
124
- };
125
- return IdMap[UIMode] || 'checkout-component';
126
- };
127
-
128
- /**
129
- * @description Create iframe
130
- */
131
- export var createIframe = function createIframe(UIMode) {
132
- var iframe = document.createElement('iframe');
133
- var iframeId = getIframeId(UIMode);
134
- iframe.id = iframeId;
135
- iframe.style.height = '0px';
136
- iframe.style.width = '100%';
137
- iframe.style.border = '0';
138
- iframe.style.overflow = 'hidden';
139
- return iframe;
140
- };
@@ -1,8 +0,0 @@
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 declare function componentAddCSS(): void;