@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730441340-dev.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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +6 -7
- package/esm/constant/index.js +80 -11
- package/esm/{foundation/service/api-bus → core/bus}/ability/callback.d.ts +2 -2
- package/esm/{foundation/service/api-bus → core/bus}/ability/callback.js +1 -1
- package/esm/{foundation/service/api-bus → core/bus}/ability/security.d.ts +4 -6
- package/esm/{foundation/service/api-bus → core/bus}/ability/security.js +35 -92
- package/esm/{foundation/service/api-bus → core/bus}/ability/tracker.d.ts +4 -4
- package/esm/{foundation/service/api-bus → core/bus}/ability/tracker.js +3 -6
- package/esm/{foundation/service/api-bus/busManager.d.ts → core/bus/index.d.ts} +15 -17
- package/esm/{foundation/service/api-bus/busManager.js → core/bus/index.js} +35 -67
- package/esm/{foundation/service/api-bus → core/bus}/interface.d.ts +0 -12
- package/esm/{foundation/service/api-bus → core/bus}/interface.js +2 -16
- package/esm/core/component/address.d.ts +8 -0
- package/esm/{foundation/service/api-bus/ability/globalData.js → core/component/address.js} +58 -75
- package/esm/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/{foundation/service/container/popup.js → core/component/appPreloadProcessing.js} +83 -97
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +166 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +531 -0
- package/esm/core/drop-in/index.d.ts +22 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +89 -0
- package/esm/core/instance/index.js +499 -0
- package/esm/index.d.ts +28 -5
- package/esm/index.js +158 -29
- package/esm/plugin/applepay/component.d.ts +50 -0
- package/esm/plugin/applepay/component.js +339 -0
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/plugin/applepay/interface.d.ts +161 -0
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/plugin/applepay/service.d.ts +54 -0
- package/esm/plugin/applepay/service.js +289 -0
- package/esm/plugin/component/cashierApp.d.ts +34 -0
- package/esm/plugin/component/cashierApp.js +237 -0
- package/esm/{component → plugin/component}/channel.d.ts +4 -3
- package/esm/{component → plugin/component}/channel.js +37 -1
- package/esm/plugin/component/component.inline.style.d.ts +10 -0
- package/esm/{component → plugin/component}/component.inline.style.js +9 -11
- package/esm/{component → plugin/component}/component.popup.style.d.ts +6 -15
- package/esm/{component → plugin/component}/component.popup.style.js +18 -36
- package/esm/plugin/component/index.d.ts +126 -0
- package/esm/plugin/component/index.js +1839 -0
- package/esm/{component → plugin/component}/popupWindow.style.js +2 -2
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/drop-in/index.d.ts +71 -0
- package/esm/plugin/drop-in/index.js +324 -0
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +6 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +390 -0
- package/esm/plugin/type.d.ts +34 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/types/index.d.ts +55 -61
- package/esm/types/index.js +62 -63
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +2 -2
- package/esm/util/getBackScheme.js +2 -94
- package/esm/util/index.d.ts +11 -1
- package/esm/util/index.js +84 -3
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/{foundation/service/security → util}/security.d.ts +2 -2
- package/esm/{foundation/service/security → util}/security.js +3 -3
- package/esm/util/ua/index.d.ts +2 -0
- package/esm/util/ua/index.js +2 -0
- package/esm/util/ua/isAndroid.d.ts +4 -0
- package/esm/util/ua/isAndroid.js +7 -0
- package/esm/util/ua/isIOS.d.ts +4 -0
- package/esm/util/ua/isIOS.js +7 -0
- package/package.json +2 -2
- package/esm/component/component.inline.style.d.ts +0 -10
- package/esm/foundation/core/index.d.ts +0 -26
- package/esm/foundation/core/index.js +0 -364
- package/esm/foundation/index.d.ts +0 -74
- package/esm/foundation/index.js +0 -42
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +0 -18
- package/esm/foundation/product-processor/easysafepay/deps.js +0 -12
- package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -27
- package/esm/foundation/product-processor/easysafepay/index.js +0 -596
- package/esm/foundation/service/api-bus/ability/globalData.d.ts +0 -10
- package/esm/foundation/service/api-bus/ability/request.d.ts +0 -10
- package/esm/foundation/service/api-bus/ability/request.js +0 -151
- package/esm/foundation/service/api-bus/index.d.ts +0 -20
- package/esm/foundation/service/api-bus/index.js +0 -88
- package/esm/foundation/service/container/index.d.ts +0 -28
- package/esm/foundation/service/container/index.js +0 -256
- package/esm/foundation/service/container/popup.d.ts +0 -17
- package/esm/foundation/service/container/utils.d.ts +0 -7
- package/esm/foundation/service/container/utils.js +0 -48
- package/esm/foundation/service/event-center.d.ts +0 -74
- package/esm/foundation/service/event-center.js +0 -213
- package/esm/foundation/service/global-data/index.d.ts +0 -11
- package/esm/foundation/service/global-data/index.js +0 -68
- package/esm/foundation/service/index.d.ts +0 -19
- package/esm/foundation/service/index.js +0 -82
- package/esm/foundation/service/log/index.d.ts +0 -43
- package/esm/foundation/service/log/index.js +0 -235
- package/esm/foundation/service/log/types.d.ts +0 -32
- package/esm/foundation/service/requester/deps.d.ts +0 -17
- package/esm/foundation/service/requester/deps.js +0 -11
- package/esm/foundation/service/requester/requester.d.ts +0 -22
- package/esm/foundation/service/requester/requester.js +0 -214
- package/esm/foundation/service/security/index.d.ts +0 -28
- package/esm/foundation/service/security/index.js +0 -285
- package/esm/foundation/types/index.d.ts +0 -4
- package/esm/foundation/types/index.js +0 -4
- package/esm/foundation/utils/gray_scale_utils.d.ts +0 -7
- package/esm/foundation/utils/gray_scale_utils.js +0 -40
- package/esm/foundation/utils/payment_context_utils.d.ts +0 -13
- package/esm/foundation/utils/payment_context_utils.js +0 -57
- package/esm/foundation/utils/payment_product_utils.d.ts +0 -13
- package/esm/foundation/utils/payment_product_utils.js +0 -38
- package/esm/foundation/utils/redirect_utils.d.ts +0 -6
- package/esm/foundation/utils/redirect_utils.js +0 -115
- package/esm/foundation/utils/system_events.d.ts +0 -4
- package/esm/foundation/utils/system_events.js +0 -71
- package/esm/foundation/utils/web_app_url_utils.d.ts +0 -46
- package/esm/foundation/utils/web_app_url_utils.js +0 -112
- /package/esm/{component → plugin/component}/popupWindow.style.d.ts +0 -0
- /package/esm/{foundation/service/log/types.js → plugin/type.js} +0 -0
@@ -0,0 +1,104 @@
|
|
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
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
12
|
+
import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
13
|
+
import CheckoutApp from "../../plugin/drop-in";
|
14
|
+
import { messageName, networkModeEnum } 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 === networkModeEnum.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.message);
|
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 (payload) {
|
53
|
+
_this2._redirect(payload).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 (payload) {
|
77
|
+
_this3.eventCenter.emit(EVENT.error.name, payload.context.data);
|
78
|
+
}], [EVENT.ready.name, function (payload) {
|
79
|
+
_this3.eventCenter.emit(EVENT.ready.name, payload.context.data);
|
80
|
+
}], [EVENT.redirect.name, function (payload) {
|
81
|
+
_this3.eventCenter.emit(EVENT.redirect.name, payload.context.data);
|
82
|
+
}], [EVENT.paymentMethodSelected.name, function (payload) {
|
83
|
+
_this3.checkoutState.paymentMethodType = payload.context.data.paymentMethodType;
|
84
|
+
_this3.eventCenter.emit(EVENT.paymentMethodSelected.name, {
|
85
|
+
paymentMethodType: payload.context.data.paymentMethodType
|
86
|
+
});
|
87
|
+
}], [EVENT.sizeChanged.name, function (payload) {
|
88
|
+
_this3.eventCenter.emit(EVENT.sizeChanged.name, payload.context.data);
|
89
|
+
}], [EVENT.log.name, function (payload) {
|
90
|
+
_this3.eventCenter.emit(EVENT.log.name, payload.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
|
+
};
|
@@ -0,0 +1,89 @@
|
|
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 { ComponentActionNamesType } from 'src/plugin/type';
|
9
|
+
import ComponentApp from '../../plugin/component';
|
10
|
+
import type { AMSCheckoutOptions, IAppendParams, InitSecurityConfig, IoptionsParams } from '../../types/index';
|
11
|
+
import { EventCenter } from '../../util/index';
|
12
|
+
import { Logger } from '../../util/logger';
|
13
|
+
import { Security } from '../../util/security';
|
14
|
+
export default class AMSSDK {
|
15
|
+
options: AMSCheckoutOptions;
|
16
|
+
originOptions: IoptionsParams;
|
17
|
+
logger: Logger;
|
18
|
+
_eventCenter: EventCenter;
|
19
|
+
_instanceId: string;
|
20
|
+
_storageId: string;
|
21
|
+
_appendParams: IAppendParams;
|
22
|
+
_componentApp: ComponentApp;
|
23
|
+
protected securitySdkMap: Map<string, Security>;
|
24
|
+
protected plugins: Map<string, any>;
|
25
|
+
constructor(options: IoptionsParams);
|
26
|
+
private preInitSecurity;
|
27
|
+
/**
|
28
|
+
* @description Destroy and process some contents of the plug-in
|
29
|
+
*/
|
30
|
+
unmount(): void;
|
31
|
+
/**
|
32
|
+
* @description init security SDK
|
33
|
+
* @param product Product Scenarios
|
34
|
+
* @param scene Scenario of the product (compatible with old version parameters, about to be deleted)
|
35
|
+
*/
|
36
|
+
initSecurity({ product, scene, }: InitSecurityConfig & {
|
37
|
+
scene?: string;
|
38
|
+
}): void;
|
39
|
+
/**
|
40
|
+
* @description Obtain security SDK through scenario identification
|
41
|
+
*/
|
42
|
+
_getSecuritySDKByProductScene(securityConfig: InitSecurityConfig): Security;
|
43
|
+
/**
|
44
|
+
* @description New security SDK through scenario identification
|
45
|
+
*/
|
46
|
+
_newSecuritySDKByScene(securityConfig: InitSecurityConfig, successCallback?: () => void, failCallback?: (errMsg?: string) => void): Security;
|
47
|
+
/**
|
48
|
+
* @description Obtain risk control configuration in local storage
|
49
|
+
*/
|
50
|
+
private getSecurityConfigStorage;
|
51
|
+
/**
|
52
|
+
* @description Set the sdk basic configuration
|
53
|
+
*/
|
54
|
+
private _setOptions;
|
55
|
+
/**
|
56
|
+
* @description Set environment variables
|
57
|
+
*/
|
58
|
+
private _setEnv;
|
59
|
+
/**
|
60
|
+
* @description Set UI and Network Mode
|
61
|
+
*/
|
62
|
+
private _setMode;
|
63
|
+
/**
|
64
|
+
* @description Initialize event related tasks
|
65
|
+
*/
|
66
|
+
private _initEvent;
|
67
|
+
/**
|
68
|
+
* @description Register plug-in
|
69
|
+
*/
|
70
|
+
protected _registerPlugin(pluginId: string, plugin: any): void;
|
71
|
+
/**
|
72
|
+
* @description Get Plug-in
|
73
|
+
*/
|
74
|
+
protected _getPlugin(pluginId: string): any;
|
75
|
+
/**
|
76
|
+
* @description Execute to open app or jump link
|
77
|
+
*/
|
78
|
+
_redirect(data: {
|
79
|
+
normalUrl?: string;
|
80
|
+
schemeUrl?: string;
|
81
|
+
applinkUrl?: string;
|
82
|
+
callAppJudgeTime?: number;
|
83
|
+
}): Promise<void>;
|
84
|
+
/**
|
85
|
+
* @description Overlay Subscription
|
86
|
+
*/
|
87
|
+
protected _overrideSubscription(name: string, func: any, funcKey: string): void;
|
88
|
+
protected getBusActionNames(): ComponentActionNamesType;
|
89
|
+
}
|