@alipay/ams-checkout 0.0.1694675458-dev.0 → 0.0.1694675458-dev.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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/request.js +3 -3
- package/esm/core/component/index.d.ts +4 -11
- package/esm/core/component/index.js +39 -30
- package/esm/core/drop-in/index.d.ts +0 -7
- package/esm/core/drop-in/index.js +16 -16
- package/esm/core/instance/index.js +1 -0
- package/esm/plugin/component/cashierApp.d.ts +3 -1
- package/esm/plugin/component/cashierApp.js +7 -3
- package/esm/plugin/component/component.inline.style.d.ts +1 -1
- package/esm/plugin/component/component.popup.style.d.ts +1 -1
- package/esm/plugin/component/component.popup.style.js +2 -0
- package/esm/plugin/component/index.d.ts +6 -8
- package/esm/plugin/component/index.js +77 -28
- package/esm/plugin/drop-in/index.d.ts +5 -5
- package/esm/plugin/drop-in/index.js +1 -0
- package/esm/request/index.d.ts +0 -7
- package/esm/request/index.js +23 -14
- package/esm/request/utils.d.ts +1 -1
- package/esm/request/utils.js +3 -0
- package/esm/types/index.d.ts +36 -9
- package/esm/types/index.js +3 -1
- package/esm/util/createIframeNode.js +7 -0
- package/esm/util/get.js +7 -0
- package/esm/util/index.d.ts +3 -3
- package/esm/util/index.js +4 -7
- package/esm/util/security.d.ts +12 -0
- package/esm/util/security.js +107 -0
- package/package.json +1 -1
package/esm/config/request.js
CHANGED
@@ -12,8 +12,8 @@ var _queryParse = queryParse(),
|
|
12
12
|
groupId = _queryParse.groupId,
|
13
13
|
host = _queryParse.requestHost;
|
14
14
|
export var requestHost = {
|
15
|
-
local: 'http://imgs-
|
16
|
-
dev: host || 'http://imgs-
|
15
|
+
local: 'http://imgs-6517.sggz00b.dev.alipay.net/mgw.htm',
|
16
|
+
dev: host || 'http://imgs-6517.sggz00b.dev.alipay.net/mgw.htm',
|
17
17
|
sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
|
18
18
|
pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
|
19
19
|
prod: 'https://imgs-sea-global.alipay.com/mgw.htm',
|
@@ -22,7 +22,7 @@ export var requestHost = {
|
|
22
22
|
export var clientId = '5J5Y8X4E2Y25GR00690';
|
23
23
|
export var tntInstId = 'ALIPW3SG';
|
24
24
|
export var appId = 'ANTOM_PAYMENT_WEB';
|
25
|
-
export var sofaId = groupId || '
|
25
|
+
export var sofaId = groupId || 'GROUP_20230913102142';
|
26
26
|
export var hostSignMap = function hostSignMap(hostSign, env) {
|
27
27
|
var map = {
|
28
28
|
SG: 'https://imgs-sea-global.alipay.com/mgw.htm',
|
@@ -1,12 +1,5 @@
|
|
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
1
|
import ComponentApp from '../../plugin/component';
|
9
|
-
import { IcreateComponent, IoptionsParams, Iselector } from '../../types';
|
2
|
+
import { IcreateComponent, IoptionsParams, Iselector, Isubmit } from '../../types';
|
10
3
|
import CoreInstance from '../instance/index';
|
11
4
|
export declare class AMSComponent extends CoreInstance {
|
12
5
|
_componentApp: ComponentApp;
|
@@ -15,17 +8,17 @@ export declare class AMSComponent extends CoreInstance {
|
|
15
8
|
private pluginAppendIframe;
|
16
9
|
/**
|
17
10
|
* @description Create component application
|
18
|
-
* @param params - The data source created by the component, necessary
|
11
|
+
* @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
19
12
|
*/
|
20
13
|
createComponent(params: IcreateComponent): Promise<void>;
|
21
14
|
/**
|
22
15
|
* @description Create and render components in the specified element area
|
23
|
-
* @param params - The data source created by the component, necessary
|
16
|
+
* @param params - The data source created by the component, necessary sessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
24
17
|
*/
|
25
18
|
mountComponent(params: IcreateComponent, selector: Iselector): Promise<void>;
|
26
19
|
/**
|
27
20
|
* @description Execute payment submission process
|
28
21
|
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
29
22
|
*/
|
30
|
-
submit():
|
23
|
+
submit(data?: Isubmit): Promise<unknown>;
|
31
24
|
}
|
@@ -25,7 +25,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
25
|
* 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
|
26
26
|
* 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.
|
27
27
|
*/
|
28
|
-
|
28
|
+
import { v4 as uuid } from 'uuid';
|
29
29
|
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
30
30
|
import ComponentApp from "../../plugin/component";
|
31
31
|
import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
|
@@ -41,12 +41,12 @@ var getComponentSign = function getComponentSign(params) {
|
|
41
41
|
paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
|
42
42
|
return productScene && paymentMethodCategoryType ? "".concat(productScene, "_").concat(paymentMethodCategoryType) : componentSignEnum.NONE;
|
43
43
|
};
|
44
|
-
var
|
44
|
+
var parseSessionData = function parseSessionData(sessionData) {
|
45
45
|
try {
|
46
|
-
return [JSON.parse(atob(
|
46
|
+
return [JSON.parse(atob(sessionData.split('&&')[3])), sessionData.split('&&').slice(0, 3).join('&&')];
|
47
47
|
} catch (error) {
|
48
|
-
console.error('Parsing
|
49
|
-
return [{},
|
48
|
+
console.error('Parsing sessionData is abnormal and may affect the payment link. Please ensure to use the new version of SDK.');
|
49
|
+
return [{}, sessionData];
|
50
50
|
}
|
51
51
|
};
|
52
52
|
|
@@ -59,23 +59,23 @@ var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
|
|
59
59
|
}
|
60
60
|
}
|
61
61
|
};
|
62
|
-
var
|
63
|
-
var
|
64
|
-
|
65
|
-
parseData =
|
66
|
-
|
62
|
+
var handleSessionData = function handleSessionData(originSessionData) {
|
63
|
+
var _parseSessionData = parseSessionData(originSessionData),
|
64
|
+
_parseSessionData2 = _slicedToArray(_parseSessionData, 2),
|
65
|
+
parseData = _parseSessionData2[0],
|
66
|
+
sessionData = _parseSessionData2[1];
|
67
67
|
resetEasyPaySceneVersion(parseData);
|
68
|
-
return [parseData,
|
68
|
+
return [parseData, sessionData];
|
69
69
|
};
|
70
70
|
var handleParams = function handleParams(params) {
|
71
71
|
var _params = Object.assign({
|
72
72
|
paymentSessionMetaData: {},
|
73
73
|
renderDisplayType: renderDisplayTypeEnum.popup
|
74
74
|
}, params);
|
75
|
-
var
|
76
|
-
|
77
|
-
parseData =
|
78
|
-
|
75
|
+
var _handleSessionData = handleSessionData(_params.sessionData),
|
76
|
+
_handleSessionData2 = _slicedToArray(_handleSessionData, 2),
|
77
|
+
parseData = _handleSessionData2[0],
|
78
|
+
sessionData = _handleSessionData2[1];
|
79
79
|
var componentSign = getComponentSign(parseData);
|
80
80
|
if (componentSign === componentSignEnum.NONE) {
|
81
81
|
// eslint-disable-next-line prefer-promise-reject-errors
|
@@ -84,7 +84,7 @@ var handleParams = function handleParams(params) {
|
|
84
84
|
message: "Abnormal response data, interface failure, or unsupported payment method"
|
85
85
|
});
|
86
86
|
}
|
87
|
-
_params.
|
87
|
+
_params.sessionData = sessionData;
|
88
88
|
_params.paymentSessionMetaData = parseData;
|
89
89
|
return Promise.resolve({
|
90
90
|
iframeNodesParams: _params,
|
@@ -119,7 +119,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
119
119
|
selector: selector,
|
120
120
|
renderDisplayType: renderDisplayType
|
121
121
|
}, params);
|
122
|
-
if (_params && !_params.
|
122
|
+
if (_params && !_params.sessionData) {
|
123
123
|
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
|
124
124
|
}
|
125
125
|
if (this.options.networkMode === networkModeEnum.proxy) {
|
@@ -140,7 +140,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
140
140
|
|
141
141
|
/**
|
142
142
|
* @description Create component application
|
143
|
-
* @param params - The data source created by the component, necessary
|
143
|
+
* @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
144
144
|
*/
|
145
145
|
}, {
|
146
146
|
key: "createComponent",
|
@@ -160,7 +160,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
160
160
|
}
|
161
161
|
/**
|
162
162
|
* @description Create and render components in the specified element area
|
163
|
-
* @param params - The data source created by the component, necessary
|
163
|
+
* @param params - The data source created by the component, necessary sessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
164
164
|
*/
|
165
165
|
}, {
|
166
166
|
key: "mountComponent",
|
@@ -185,17 +185,26 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
185
185
|
*/
|
186
186
|
}, {
|
187
187
|
key: "submit",
|
188
|
-
value: function submit() {
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
188
|
+
value: function submit(data) {
|
189
|
+
var _this4 = this;
|
190
|
+
return new Promise(function (resolve, reject) {
|
191
|
+
try {
|
192
|
+
var eventCallbackId = uuid();
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
194
|
+
_this4._eventCenter.once(eventCallbackId, function (_data) {
|
195
|
+
resolve(_data);
|
196
|
+
});
|
197
|
+
_this4._componentApp.dispatchToApp({
|
198
|
+
context: {
|
199
|
+
event: 'submitPay',
|
200
|
+
eventCallbackId: eventCallbackId,
|
201
|
+
data: data
|
202
|
+
}
|
203
|
+
});
|
204
|
+
} catch (error) {
|
205
|
+
reject(error);
|
206
|
+
}
|
207
|
+
});
|
199
208
|
}
|
200
209
|
}]);
|
201
210
|
return AMSComponent;
|
@@ -1,10 +1,3 @@
|
|
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
1
|
import { IcreatePaymentParams, IoptionsParams } from '../../types';
|
9
2
|
export declare const mixinDropInConstructor: (options: IoptionsParams, context: any) => void;
|
10
3
|
/**
|
@@ -8,7 +8,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
8
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
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
10
|
*/
|
11
|
-
|
11
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
12
12
|
import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
13
13
|
import CheckoutApp from "../../plugin/drop-in";
|
14
14
|
import { messageName, networkModeEnum } from "../../types";
|
@@ -49,8 +49,8 @@ export var createPayment = function createPayment(params) {
|
|
49
49
|
export var confirmPayment = function confirmPayment(result) {
|
50
50
|
var _this2 = this;
|
51
51
|
return new Promise(function (resolve, reject) {
|
52
|
-
_this2.eventCenter.once('onRedirect', function (
|
53
|
-
_this2._redirect(
|
52
|
+
_this2.eventCenter.once('onRedirect', function (payload) {
|
53
|
+
_this2._redirect(payload).then(function () {
|
54
54
|
resolve();
|
55
55
|
}).catch(function (err) {
|
56
56
|
reject(err);
|
@@ -73,21 +73,21 @@ export var confirmPayment = function confirmPayment(result) {
|
|
73
73
|
*/
|
74
74
|
export var _subscribeFromCheckoutPlugin = function _subscribeFromCheckoutPlugin() {
|
75
75
|
var _this3 = this;
|
76
|
-
var eventKeyMap = new Map([[EVENT.error.name, function (
|
77
|
-
_this3.eventCenter.emit(EVENT.error.name,
|
78
|
-
}], [EVENT.ready.name, function (
|
79
|
-
_this3.eventCenter.emit(EVENT.ready.name,
|
80
|
-
}], [EVENT.redirect.name, function (
|
81
|
-
_this3.eventCenter.emit(EVENT.redirect.name,
|
82
|
-
}], [EVENT.paymentMethodSelected.name, function (
|
83
|
-
_this3.checkoutState.paymentMethodType =
|
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
84
|
_this3.eventCenter.emit(EVENT.paymentMethodSelected.name, {
|
85
|
-
paymentMethodType:
|
85
|
+
paymentMethodType: payload.context.data.paymentMethodType
|
86
86
|
});
|
87
|
-
}], [EVENT.sizeChanged.name, function (
|
88
|
-
_this3.eventCenter.emit(EVENT.sizeChanged.name,
|
89
|
-
}], [EVENT.log.name, function (
|
90
|
-
_this3.eventCenter.emit(EVENT.log.name,
|
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
91
|
}]]);
|
92
92
|
var _iterator = _createForOfIteratorHelper(eventKeyMap.keys()),
|
93
93
|
_step;
|
@@ -15,6 +15,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
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
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
17
|
*/
|
18
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
19
|
import { v4 as uuid } from 'uuid';
|
19
20
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
20
21
|
import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { componentSignEnum, Ianalytics } from '../../types';
|
2
|
-
|
2
|
+
import { renderDisplayTypeEnum } from '../../types/index';
|
3
|
+
export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
|
3
4
|
export declare const getAppDomain: (domainParams: {
|
4
5
|
environment: string;
|
5
6
|
appVersion: string;
|
@@ -16,6 +17,7 @@ export declare const getIframeUrl: (iframeParams: {
|
|
16
17
|
extendInfo: string;
|
17
18
|
locale: string;
|
18
19
|
instanceId: string;
|
20
|
+
renderDisplayType: renderDisplayTypeEnum;
|
19
21
|
}) => string;
|
20
22
|
/**
|
21
23
|
* @description Create iframe
|
@@ -22,7 +22,7 @@ var getAppVersion = function getAppVersion(_extendInfo) {
|
|
22
22
|
};
|
23
23
|
var getFinalProductSceneVersion = function getFinalProductSceneVersion(componentSign, productSceneVersion) {
|
24
24
|
var _signSupportMap;
|
25
|
-
var signSupportMap = (_signSupportMap = {}, _defineProperty(_signSupportMap, componentSignEnum.NONE, ['']), _defineProperty(_signSupportMap, componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), _signSupportMap);
|
25
|
+
var signSupportMap = (_signSupportMap = {}, _defineProperty(_signSupportMap, componentSignEnum.NONE, ['']), _defineProperty(_signSupportMap, componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), _defineProperty(_signSupportMap, componentSignEnum.VAULTING_CARD, ['1.0']), _signSupportMap);
|
26
26
|
var supportProductSceneVersion = signSupportMap[componentSign];
|
27
27
|
// 从左到右,从旧到新
|
28
28
|
var isSupport = supportProductSceneVersion.find(function (it) {
|
@@ -69,7 +69,8 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
69
69
|
appVersion = iframeParams.appVersion,
|
70
70
|
extendInfo = iframeParams.extendInfo,
|
71
71
|
locale = iframeParams.locale,
|
72
|
-
instanceId = iframeParams.instanceId
|
72
|
+
instanceId = iframeParams.instanceId,
|
73
|
+
renderDisplayType = iframeParams.renderDisplayType;
|
73
74
|
var path = getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo || '');
|
74
75
|
var initialScale = 1;
|
75
76
|
var scale = getViewPort('initial-scale') || initialScale;
|
@@ -80,8 +81,10 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
80
81
|
requestHost = _queryParse$requestHo === void 0 ? '' : _queryParse$requestHo,
|
81
82
|
_queryParse$groupId = _queryParse.groupId,
|
82
83
|
groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
|
83
|
-
LOCAL_MOCK = _queryParse.LOCAL_MOCK
|
84
|
+
LOCAL_MOCK = _queryParse.LOCAL_MOCK,
|
85
|
+
_displayType = _queryParse._displayType;
|
84
86
|
var urlParams = Object.assign({}, {
|
87
|
+
displayType: renderDisplayType,
|
85
88
|
locale: locale,
|
86
89
|
scale: scale,
|
87
90
|
instanceId: instanceId,
|
@@ -94,6 +97,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
94
97
|
if (groupId) urlParams.groupId = groupId;
|
95
98
|
if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
|
96
99
|
if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
|
100
|
+
if (_displayType) urlParams.displayType = _displayType;
|
97
101
|
var locationSearch = serialize(urlParams);
|
98
102
|
return "".concat(path, "?").concat(locationSearch);
|
99
103
|
};
|
@@ -8,4 +8,4 @@
|
|
8
8
|
import { platformEnum } from '../../types';
|
9
9
|
export declare const inlineComponentAddCss: () => void;
|
10
10
|
export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum) => void;
|
11
|
-
export declare const createInlineBaseElement: (selector: string) => HTMLDivElement
|
11
|
+
export declare const createInlineBaseElement: (selector: string) => HTMLDivElement;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { platformEnum } from '../../types';
|
2
2
|
export declare const componentAddCSS: () => void;
|
3
|
-
export declare const createBaseElement: (platform: platformEnum, closeBtnFunc: () => void) => HTMLDivElement
|
3
|
+
export declare const createBaseElement: (platform: platformEnum, closeBtnFunc: () => void) => HTMLDivElement;
|
4
4
|
export declare const createCloseBtn: (platform: platformEnum, closeBtnFunc: () => void) => void;
|
5
5
|
export declare const createRetentionPopup: (platform: platformEnum, remainBtnFunc: () => void, leaveBtnFunc: () => void) => void;
|
6
6
|
export declare const hideRetentionPopup: () => void;
|
@@ -113,6 +113,8 @@ export var addPopupLoading = function addPopupLoading() {
|
|
113
113
|
var body = document.getElementsByTagName('body')[0];
|
114
114
|
body === null || body === void 0 ? void 0 : body.appendChild(loading);
|
115
115
|
};
|
116
|
+
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
116
118
|
export var handleDeclareInfo = function handleDeclareInfo(_ref) {
|
117
119
|
var _ref$closeDialogData = _ref.closeDialogData,
|
118
120
|
closeDialogData = _ref$closeDialogData === void 0 ? {} : _ref$closeDialogData;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type AMSCheckout from '../../core/instance';
|
2
|
-
import type {
|
2
|
+
import type { eventPayload, eventPayloadContext, IappendIframeNodesParams, Iselector } from '../../types';
|
3
3
|
import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
|
4
4
|
type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
|
5
5
|
export default class ComponentApp {
|
@@ -7,7 +7,7 @@ export default class ComponentApp {
|
|
7
7
|
AMSSDK: AMSCheckout;
|
8
8
|
platform: platformEnum;
|
9
9
|
_performanceData: any[];
|
10
|
-
_loadAppPromiseResolve: ((value:
|
10
|
+
_loadAppPromiseResolve: ((value: boolean) => void) | null;
|
11
11
|
_isInitComponent: boolean;
|
12
12
|
private appDomain;
|
13
13
|
private createIframeNode;
|
@@ -32,6 +32,7 @@ export default class ComponentApp {
|
|
32
32
|
* @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
|
33
33
|
*/
|
34
34
|
setRender(renderFunc: IrenderFuncParams): void;
|
35
|
+
initAPSecurity(): void;
|
35
36
|
/**
|
36
37
|
* @description render iframe content
|
37
38
|
*/
|
@@ -58,7 +59,7 @@ export default class ComponentApp {
|
|
58
59
|
/**
|
59
60
|
* @description Processing messages from iframe
|
60
61
|
*/
|
61
|
-
_handleAppMessage(data:
|
62
|
+
_handleAppMessage(data: eventPayload): void;
|
62
63
|
private handleSizeChanged;
|
63
64
|
private handleRedirect;
|
64
65
|
private handleDeclareInfo;
|
@@ -66,15 +67,12 @@ export default class ComponentApp {
|
|
66
67
|
/**
|
67
68
|
* @description Send message to SDK
|
68
69
|
*/
|
69
|
-
dispatchToSDK(event: string, data: any): void;
|
70
|
+
dispatchToSDK(event: string, data: any, eventCallbackId?: string): void;
|
70
71
|
/**
|
71
72
|
* @description Send message to iframe
|
72
73
|
*/
|
73
74
|
dispatchToApp(payload: {
|
74
|
-
context:
|
75
|
-
event: string;
|
76
|
-
data: any;
|
77
|
-
};
|
75
|
+
context: eventPayloadContext;
|
78
76
|
}): any;
|
79
77
|
/**
|
80
78
|
* @description Subscribe to messages from SDK
|
@@ -15,14 +15,22 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
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
16
|
*/
|
17
17
|
/* eslint-disable no-console */
|
18
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
19
|
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
19
20
|
import { queryPaymentInfo } from "../../service";
|
20
21
|
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
|
21
|
-
import { getType, isJsonString, isPC } from "../../util";
|
22
|
+
import { getType, isJsonString, isPC, queryParse } from "../../util";
|
22
23
|
import { isLocalMock } from "../../util/mock";
|
23
24
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
24
25
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
25
26
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
27
|
+
import APDID from '@alipay/jshield-apdid';
|
28
|
+
import { getSecurityHost, getAppname } from "../../util/security";
|
29
|
+
var _ref = queryParse() || {},
|
30
|
+
preinit = _ref.preinit,
|
31
|
+
rebuild = _ref.rebuild,
|
32
|
+
scene = _ref.scene,
|
33
|
+
region = _ref.region;
|
26
34
|
var _window = window,
|
27
35
|
innerHeight = _window.innerHeight;
|
28
36
|
var ComponentApp = /*#__PURE__*/function () {
|
@@ -86,6 +94,29 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
86
94
|
value: function setRender(renderFunc) {
|
87
95
|
this.createIframeNode = renderFunc;
|
88
96
|
}
|
97
|
+
}, {
|
98
|
+
key: "initAPSecurity",
|
99
|
+
value: function initAPSecurity() {
|
100
|
+
var _this$_renderParams, _this$_renderParams$p;
|
101
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
var securityConfig = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : (_this$_renderParams$p = _this$_renderParams.paymentSessionMetaData) === null || _this$_renderParams$p === void 0 ? void 0 : _this$_renderParams$p.securityConfig;
|
105
|
+
if (!securityConfig) {
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
|
109
|
+
var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
|
110
|
+
if (preinit === 'true' || rebuild === 'true') {
|
111
|
+
appName = getAppname(scene);
|
112
|
+
h5gateway = getSecurityHost(region);
|
113
|
+
}
|
114
|
+
APDID.initToken(appName, {
|
115
|
+
host: h5gateway
|
116
|
+
}, function (success, tokenResult, msg) {
|
117
|
+
console.log("initToken result tokenResult", JSON.stringify(tokenResult));
|
118
|
+
});
|
119
|
+
}
|
89
120
|
|
90
121
|
/**
|
91
122
|
* @description render iframe content
|
@@ -104,6 +135,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
104
135
|
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
105
136
|
this._renderDisplayType = renderParams.renderDisplayType;
|
106
137
|
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
138
|
+
this.initAPSecurity();
|
107
139
|
this._performanceData.push({
|
108
140
|
key: 'sdk_create_component',
|
109
141
|
value: Date.now()
|
@@ -179,32 +211,45 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
179
211
|
value: Date.now()
|
180
212
|
});
|
181
213
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
182
|
-
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
|
214
|
+
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3, _this3$_renderParams4, _this3$_renderParams5;
|
183
215
|
var params = {
|
184
|
-
paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.
|
216
|
+
paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.sessionData) || '',
|
185
217
|
paymentSessionConfig: (_this3$_renderParams2 = _this3._renderParams) === null || _this3$_renderParams2 === void 0 ? void 0 : (_this3$_renderParams3 = _this3$_renderParams2.paymentSessionMetaData) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.paymentSessionConfig
|
186
218
|
};
|
187
219
|
/**
|
188
220
|
* @description card
|
189
221
|
*/
|
190
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
|
222
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign || componentSignEnum.VAULTING_CARD === _this3._componentSign) {
|
191
223
|
params.paymentMethodType = 'CARD';
|
192
224
|
}
|
225
|
+
var needDeviceId = false;
|
226
|
+
var waitTime = '3000';
|
227
|
+
var securityConfig = (_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : (_this3$_renderParams5 = _this3$_renderParams4.paymentSessionMetaData) === null || _this3$_renderParams5 === void 0 ? void 0 : _this3$_renderParams5.securityConfig;
|
228
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign && securityConfig) {
|
229
|
+
var _this3$_renderParams6, _this3$_renderParams7;
|
230
|
+
var extendInfo = ((_this3$_renderParams6 = _this3._renderParams) === null || _this3$_renderParams6 === void 0 ? void 0 : (_this3$_renderParams7 = _this3$_renderParams6.paymentSessionMetaData) === null || _this3$_renderParams7 === void 0 ? void 0 : _this3$_renderParams7.extendInfo) || '';
|
231
|
+
var info = JSON.parse(extendInfo);
|
232
|
+
if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
|
233
|
+
needDeviceId = true;
|
234
|
+
waitTime = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.tokenCollectTime;
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
193
238
|
/**
|
194
239
|
* @description easyPay
|
195
240
|
*/
|
196
241
|
if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
|
197
|
-
var _this3$
|
198
|
-
var
|
199
|
-
|
200
|
-
productSceneVersion =
|
201
|
-
|
202
|
-
productScene =
|
203
|
-
var
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
autoDebitWithToken =
|
242
|
+
var _this3$_renderParams8;
|
243
|
+
var _ref2 = params.paymentSessionConfig || {},
|
244
|
+
_ref2$productSceneVer = _ref2.productSceneVersion,
|
245
|
+
productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
|
246
|
+
_ref2$productScene = _ref2.productScene,
|
247
|
+
productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
|
248
|
+
var _ref3 = ((_this3$_renderParams8 = _this3._renderParams) === null || _this3$_renderParams8 === void 0 ? void 0 : _this3$_renderParams8.paymentSessionMetaData) || {},
|
249
|
+
_ref3$action = _ref3.action,
|
250
|
+
_ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
|
251
|
+
_ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
|
252
|
+
autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb;
|
208
253
|
if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
|
209
254
|
// if EASY_PAY 2.0 , no need to query payment request
|
210
255
|
return resolve({
|
@@ -218,8 +263,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
218
263
|
* @description autoDebit
|
219
264
|
*/
|
220
265
|
if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
|
221
|
-
var _this3$
|
222
|
-
var action = ((_this3$
|
266
|
+
var _this3$_renderParams9, _this3$_renderParams10, _action$web, _action$wap;
|
267
|
+
var action = ((_this3$_renderParams9 = _this3._renderParams) === null || _this3$_renderParams9 === void 0 ? void 0 : (_this3$_renderParams10 = _this3$_renderParams9.paymentSessionMetaData) === null || _this3$_renderParams10 === void 0 ? void 0 : _this3$_renderParams10.action) || {};
|
223
268
|
var signType = isPC() ? action === null || action === void 0 ? void 0 : (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 ? void 0 : (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
224
269
|
if (signType === 'SMS') {
|
225
270
|
return resolve({
|
@@ -243,7 +288,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
243
288
|
}
|
244
289
|
queryPaymentInfo(params, {
|
245
290
|
env: _this3.AMSSDK.options.env.environment,
|
246
|
-
locale: _this3.AMSSDK.options.locale
|
291
|
+
locale: _this3.AMSSDK.options.locale,
|
292
|
+
needDeviceId: needDeviceId,
|
293
|
+
waitTime: waitTime
|
247
294
|
}).then(function (res) {
|
248
295
|
_this3._performanceData.push({
|
249
296
|
key: 'sdk_action_query_end',
|
@@ -323,6 +370,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
323
370
|
});
|
324
371
|
this.app = createIframe(this.AMSSDK.options.mode, this.platform);
|
325
372
|
this.app.src = getIframeUrl({
|
373
|
+
renderDisplayType: renderParams.renderDisplayType,
|
326
374
|
componentSign: this._componentSign,
|
327
375
|
analytics: this.AMSSDK.options.analytics,
|
328
376
|
productSceneVersion: productSceneVersion,
|
@@ -455,7 +503,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
455
503
|
}
|
456
504
|
|
457
505
|
// The plug-in communicates with the sdk after processing
|
458
|
-
this.dispatchToSDK(data.context.event, data.context.data);
|
506
|
+
this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
|
459
507
|
}
|
460
508
|
}, {
|
461
509
|
key: "handleSizeChanged",
|
@@ -562,9 +610,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
562
610
|
}
|
563
611
|
}, {
|
564
612
|
key: "handleDeclareInfo",
|
565
|
-
value: function handleDeclareInfo(
|
566
|
-
var
|
567
|
-
closeDialogData =
|
613
|
+
value: function handleDeclareInfo(_ref4) {
|
614
|
+
var _ref4$closeDialogData = _ref4.closeDialogData,
|
615
|
+
closeDialogData = _ref4$closeDialogData === void 0 ? {} : _ref4$closeDialogData;
|
568
616
|
_handleDeclareInfo({
|
569
617
|
closeDialogData: closeDialogData
|
570
618
|
});
|
@@ -585,8 +633,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
585
633
|
*/
|
586
634
|
}, {
|
587
635
|
key: "dispatchToSDK",
|
588
|
-
value: function dispatchToSDK(event, data) {
|
636
|
+
value: function dispatchToSDK(event, data, eventCallbackId) {
|
589
637
|
this.AMSSDK._eventCenter.emit(event, data);
|
638
|
+
if (eventCallbackId) this.AMSSDK._eventCenter.emit(eventCallbackId, data);
|
590
639
|
}
|
591
640
|
|
592
641
|
/**
|
@@ -630,7 +679,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
630
679
|
key: "sendRenderEvent",
|
631
680
|
value: function () {
|
632
681
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
633
|
-
var _this$
|
682
|
+
var _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, res;
|
634
683
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
635
684
|
while (1) switch (_context.prev = _context.next) {
|
636
685
|
case 0:
|
@@ -654,11 +703,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
654
703
|
event: 'renderComponent',
|
655
704
|
data: {
|
656
705
|
queryResult: res,
|
657
|
-
sessionResult: (_this$
|
658
|
-
paymentSessionData: (_this$
|
706
|
+
sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
|
707
|
+
paymentSessionData: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData,
|
659
708
|
heightOfVisible: Math.max(innerHeight, window.innerHeight),
|
660
|
-
renderDisplayType: (_this$
|
661
|
-
appearance: (_this$
|
709
|
+
renderDisplayType: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.renderDisplayType,
|
710
|
+
appearance: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.appearance,
|
662
711
|
envInfo: {
|
663
712
|
screenHeight: screen.height,
|
664
713
|
screenWidth: screen.width
|