@alipay/ams-checkout 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +1 -15
- package/esm/config/index.js +9 -62
- package/esm/config/request.d.ts +21 -0
- package/esm/config/request.js +67 -0
- package/esm/constant/index.d.ts +1 -0
- package/esm/constant/index.js +1 -0
- package/esm/core/component/index.d.ts +3 -3
- package/esm/core/component/index.js +51 -90
- package/esm/core/instance/index.d.ts +2 -10
- package/esm/core/instance/index.js +0 -22
- package/esm/plugin/component/cashierApp.d.ts +4 -5
- package/esm/plugin/component/cashierApp.js +32 -49
- package/esm/plugin/component/component.style.js +1 -1
- package/esm/plugin/component/index.d.ts +3 -3
- package/esm/plugin/component/index.js +31 -24
- package/esm/request/index.d.ts +1 -1
- package/esm/request/index.js +5 -4
- package/esm/service/index.d.ts +2 -2
- package/esm/types/index.d.ts +29 -7
- package/esm/types/index.js +8 -5
- package/package.json +1 -1
@@ -9,74 +9,57 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
9
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
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
11
|
*/
|
12
|
-
import { sdkVersion } from "../../config/index";
|
13
|
-
import {
|
12
|
+
import { marmptMap, sdkVersion } from "../../config/index";
|
13
|
+
import { componentSignEnum } from "../../types";
|
14
14
|
import { getViewPort, queryParse, serialize } from "../../util/index";
|
15
|
+
var getAppVersion = function getAppVersion(_extendInfo) {
|
16
|
+
try {
|
17
|
+
var info = JSON.parse(_extendInfo);
|
18
|
+
return info.versionMap.web[sdkVersion].targetWebVerison;
|
19
|
+
} catch (error) {
|
20
|
+
return '';
|
21
|
+
}
|
22
|
+
};
|
23
|
+
var getFinalProductSceneVersion = function getFinalProductSceneVersion(componentSign, productSceneVersion) {
|
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);
|
26
|
+
var supportProductSceneVersion = signSupportMap[componentSign];
|
27
|
+
// 从左到右,从旧到新
|
28
|
+
var isSupport = supportProductSceneVersion.find(function (it) {
|
29
|
+
return it === productSceneVersion;
|
30
|
+
});
|
31
|
+
var finalProductSceneVersion = supportProductSceneVersion[supportProductSceneVersion.length - 1];
|
32
|
+
return isSupport ? productSceneVersion : finalProductSceneVersion;
|
33
|
+
};
|
15
34
|
export var getAppPath = function getAppPath() {
|
16
|
-
var _componentMap;
|
17
35
|
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
18
36
|
var appVersion = arguments.length > 1 ? arguments[1] : undefined;
|
19
|
-
var
|
37
|
+
var componentSign = arguments.length > 2 ? arguments[2] : undefined;
|
20
38
|
var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
|
21
39
|
var extendInfo = arguments.length > 4 ? arguments[4] : undefined;
|
22
40
|
var _ref = queryParse() || {},
|
23
41
|
urlTestHost = _ref.host;
|
24
|
-
var
|
25
|
-
var
|
26
|
-
|
27
|
-
var info = JSON.parse(_extendInfo);
|
28
|
-
return info.versionMap.web[sdkVersion].targetWebVerison || appVersion;
|
29
|
-
} catch (error) {
|
30
|
-
return appVersion;
|
31
|
-
}
|
32
|
-
};
|
33
|
-
var marmptMap = {
|
34
|
-
dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
|
35
|
-
sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
|
36
|
-
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app',
|
37
|
-
sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
38
|
-
light_sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
39
|
-
prod: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app'
|
40
|
-
};
|
41
|
-
var finalAppVersion = getAppVersion(extendInfo);
|
42
|
-
var getFinalProductSceneVersion = function getFinalProductSceneVersion(supportProductSceneVersion) {
|
43
|
-
// 从左到右,从旧到新
|
44
|
-
var isSupport = supportProductSceneVersion.find(function (it) {
|
45
|
-
return it === productSceneVersion;
|
46
|
-
});
|
47
|
-
var finalProductSceneVersion = supportProductSceneVersion[supportProductSceneVersion.length - 1];
|
48
|
-
if (isSupport) finalProductSceneVersion = productSceneVersion;
|
49
|
-
return finalProductSceneVersion;
|
50
|
-
};
|
51
|
-
var componentMap = (_componentMap = {}, _defineProperty(_componentMap, componentNameEnum.card, function () {
|
52
|
-
host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.card, "/index.").concat(finalAppVersion, ".html");
|
53
|
-
}), _defineProperty(_componentMap, componentNameEnum.easyPay, function () {
|
54
|
-
var finalProductSceneVersion = getFinalProductSceneVersion(['1.0', '2.0']);
|
55
|
-
host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.easyPay, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
56
|
-
}), _defineProperty(_componentMap, componentNameEnum.autoDebit, function () {
|
57
|
-
var finalProductSceneVersion = getFinalProductSceneVersion(['1.0']);
|
58
|
-
host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.autoDebit, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
59
|
-
}), _componentMap);
|
60
|
-
if (componentMap[componentName]) componentMap[componentName]();
|
42
|
+
var finalAppVersion = getAppVersion(extendInfo) || appVersion;
|
43
|
+
var finalProductSceneVersion = getFinalProductSceneVersion(componentSign, productSceneVersion);
|
44
|
+
|
61
45
|
// only for test while testurl?host=https://xxxxx.test.html
|
62
46
|
if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
|
63
47
|
return urlTestHost;
|
64
48
|
}
|
65
|
-
return
|
49
|
+
return "".concat(marmptMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
66
50
|
};
|
67
51
|
export var getAppDomain = function getAppDomain(domainParams) {
|
68
52
|
var environment = domainParams.environment,
|
69
53
|
appVersion = domainParams.appVersion,
|
70
|
-
|
54
|
+
componentSign = domainParams.componentSign,
|
71
55
|
productSceneVersion = domainParams.productSceneVersion,
|
72
56
|
extendInfo = domainParams.extendInfo;
|
73
57
|
var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
|
74
|
-
var macth = reg.exec(getAppPath(environment, appVersion,
|
58
|
+
var macth = reg.exec(getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo));
|
75
59
|
return macth && macth[0] || '';
|
76
60
|
};
|
77
61
|
export var getIframeUrl = function getIframeUrl(iframeParams) {
|
78
|
-
var
|
79
|
-
appearance = iframeParams.appearance,
|
62
|
+
var componentSign = iframeParams.componentSign,
|
80
63
|
_iframeParams$analyti = iframeParams.analytics,
|
81
64
|
analytics = _iframeParams$analyti === void 0 ? {
|
82
65
|
enabled: true
|
@@ -87,7 +70,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
87
70
|
extendInfo = iframeParams.extendInfo,
|
88
71
|
locale = iframeParams.locale,
|
89
72
|
instanceId = iframeParams.instanceId;
|
90
|
-
var path = getAppPath(environment, appVersion,
|
73
|
+
var path = getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo || '');
|
91
74
|
var initialScale = 1;
|
92
75
|
var scale = getViewPort('initial-scale') || initialScale;
|
93
76
|
var _queryParse = queryParse(),
|
@@ -98,7 +81,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
98
81
|
_queryParse$groupId = _queryParse.groupId,
|
99
82
|
groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
|
100
83
|
LOCAL_MOCK = _queryParse.LOCAL_MOCK;
|
101
|
-
var urlParams = Object.assign({
|
84
|
+
var urlParams = Object.assign({}, {
|
102
85
|
locale: locale,
|
103
86
|
scale: scale,
|
104
87
|
instanceId: instanceId,
|
@@ -110,7 +93,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
110
93
|
requestHost: requestHost,
|
111
94
|
groupId: groupId,
|
112
95
|
LOCAL_MOCK: LOCAL_MOCK
|
113
|
-
}
|
96
|
+
});
|
114
97
|
var locationSearch = serialize(urlParams);
|
115
98
|
return "".concat(path, "?").concat(locationSearch);
|
116
99
|
};
|
@@ -6,7 +6,7 @@
|
|
6
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
7
|
*/
|
8
8
|
|
9
|
-
var componentCss = ".ams-component-container-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n}\n.ams-component-container-mobile-animation{\n animation: ams-component-container-slide-in 0.3s ease-in-out;\n}\n\n.ams-component-section-desktop {\n font-size: 0;\n}\n\n.ams-component-container-hidden-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n background-color: transparent;\n border-radius: 12px 12px 0 0;\n animation: ams-component-container-slide-out 0.26s ease-in forwards;\n overflow: hidden;\n}\n\n.ams-component-section-mobile {\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n font-size: 0;\n}\n\n.ams-component-container-desktop {\n display: block;\n width: 672px;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n transform-origin: 50% 50%;\n}\n.ams-component-container-desktop-animation{\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n@keyframes ams-component-container-zoom-out {\n 0% {\n transform:
|
9
|
+
var componentCss = ".ams-component-container-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n}\n.ams-component-container-mobile-animation{\n animation: ams-component-container-slide-in 0.3s ease-in-out;\n}\n\n.ams-component-section-desktop {\n font-size: 0;\n}\n\n.ams-component-container-hidden-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n background-color: transparent;\n border-radius: 12px 12px 0 0;\n animation: ams-component-container-slide-out 0.26s ease-in forwards;\n overflow: hidden;\n}\n\n.ams-component-section-mobile {\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n font-size: 0;\n}\n\n.ams-component-container-desktop {\n display: block;\n width: 672px;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n transform-origin: 50% 50%;\n}\n.ams-component-container-desktop-animation{\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n@keyframes ams-component-container-zoom-out {\n 0% {\n transform: translate(-50%, -50%) scale(1);\n -webkit-transform: translate(-50%, -50%) scale(1);\n opacity: 1\n }\n \n 100% {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.4);\n -webkit-transform: translate(-50%, -50%) scale(0.4);\n }\n}\n\n@keyframes ams-component-container-zoom-in {\n 0% {\n transform: translateX(-50%) translateY(-50%) scale(0.4);\n opacity: 0\n }\n\n 80% {\n opacity: 1\n }\n\n 100% {\n opacity: 1;\n transform: translateX(-50%) translateY(-50%) scale(1);\n }\n}\n\n.ams-component-container-hidden-desktop {\n display: block;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n animation-fill-mode: forwards;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n transform-origin: 50% 50%;\n}\n\n.ams-component-loading {\n width: 0.8em;\n height:0.8em;\n background: rgba(0, 0, 0, 0.5);\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-loading .line div:before,\n.ams-component-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: #fcfcfc;\n border-radius: 5.3px;\n}\n.ams-component-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n\n}\n\n.ams-component-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n\n.asm-component-close-block-desktop {\n position: absolute;\n width: 40px;\n height: 40px;\n right: 0;\n top: 0;\n cursor: pointer;\n}\n.asm-component-close-btn-desktop {\n width: 11px;\n height: 11px;\n object-fit: fill;\n position: absolute;\n right: 18.7px;\n top: 26.7px;\n}\n.asm-component-close-block-hidden {\n width: 0px !important;\n height: 0px !important;\n visibility: hidden;\n}\n.asm-component-close-block-mobile {\n position: absolute;\n width: 0.4em;\n height: 0.4em;\n right: 0;\n top: 0;\n cursor: pointer;\n z-index: 1009;\n}\n\n.asm-component-close-btn-mobile {\n width: 0.11em;\n height: 0.11em;\n object-fit: fill;\n position: absolute;\n right: 0.147em;\n top: 0.167em;\n}\n\n\n.ams-component-container-opacity{\n opacity: 1;\n}\n\n.ams-component-container-opacity:after{\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n display: block;\n content: \"\";\n z-index: 1010;\n background-color: rgba(0, 0, 0, 0.35);\n}\n\n#ams-component-retention {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n transform-origin: 50%;\n height: auto;\n display: none;\n z-index: 1009;\n}\n\n.ams-component-retention-show {\n display: flex !important;\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-hidden {\n display: flex !important;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n -webkit-animation: ams-component-container-zoom-out 0.3s ease-in-out;\n animation-fill-mode: forwards;\n -webkit-animation-fill-mode: forwards;\n}\n\n.ams-component-retention-mobile {\n width: 294px;\n border-radius: 12px;\n padding: 24px 0;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-desktop {\n width: 544px;\n border-radius: 12px;\n padding: 32px;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n@media screen and (max-width: 300px) {\n .ams-component-retention-mobile {\n transform: translate(-50%, -50%) scale(0.8);\n }\n}\n\n.ams-component-retention-title-mobile {\n width: 100%;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-title-desktop {\n text-align: left;\n width: 100%;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n}\n\n.ams-component-retention-sub-title-mobile {\n width: 100%;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 8px;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-sub-title-desktop {\n text-align: left;\n font-style: normal;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 10px;\n}\n\n.ams-component-retention-btn-block-mobile {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n margin-top: 24px;\n padding: 0 24px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-btn-block-desktop {\n width: 100%;\n margin-top: 24px;\n}\n\n#ams-component-retention-remain {\n background: #0079FF;\n border-radius: 100px;\n font-style: normal;\n font-weight: 600;\n text-align: center;\n box-sizing: border-box;\n color: #FFFFFF;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ams-component-retention-remain-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n padding: 0 6px;\n}\n\n.ams-component-retention-remain-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n display: inline-block;\n padding: 0 24px;\n float: right;\n cursor: pointer;\n padding: 0 8px;\n max-width: 225px;\n}\n\n#ams-component-retention-leave {\n border-radius: 100px;\n border: 1px solid #0079FF;\n font-style: normal;\n font-weight: 600;\n text-align: center;\n box-sizing: border-box;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ams-component-retention-leave-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n margin-top: 12px;\n padding: 0 6px;\n}\n\n.ams-component-retention-leave-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n display: inline-block;\n padding: 0 24px;\n float: right;\n margin-right: 16px;\n cursor: pointer;\n padding: 0 8px;\n max-width: 225px;\n}\n\n";
|
10
10
|
export function componentAddCSS() {
|
11
11
|
var style = document.createElement('style');
|
12
12
|
style.type = 'text/css';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type AMSCheckout from '../../core/instance';
|
2
2
|
import type { IappendIframeNodesParams, IcreateComponent } from '../../types';
|
3
|
-
import {
|
3
|
+
import { CashierSdkActionQueryResult, componentSignEnum } from '../../types';
|
4
4
|
export default class ComponentApp {
|
5
5
|
app: any;
|
6
6
|
appDomain: string;
|
@@ -12,7 +12,7 @@ export default class ComponentApp {
|
|
12
12
|
private _isRetention;
|
13
13
|
private _actionQueryPromise;
|
14
14
|
private _renderParams;
|
15
|
-
private
|
15
|
+
private _componentSign;
|
16
16
|
private _performanceData;
|
17
17
|
private _isInitComponent;
|
18
18
|
private _clickEventName;
|
@@ -32,7 +32,7 @@ export default class ComponentApp {
|
|
32
32
|
/**
|
33
33
|
* @description render iframe content
|
34
34
|
*/
|
35
|
-
appendIframeNodes(
|
35
|
+
appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void | [void, CashierSdkActionQueryResult | null]>;
|
36
36
|
/**
|
37
37
|
* @description Interface request
|
38
38
|
*/
|
@@ -17,9 +17,9 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
* 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.
|
18
18
|
*/
|
19
19
|
/* eslint-disable no-console */
|
20
|
-
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
20
|
+
import { closeImg, COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
21
21
|
import { queryPaymentInfo } from "../../service";
|
22
|
-
import {
|
22
|
+
import { componentSignEnum, messageName, productSceneEnum, Target } from "../../types";
|
23
23
|
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
|
24
24
|
import { isLocalMock } from "../../util/mock";
|
25
25
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
@@ -58,11 +58,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
58
58
|
_defineProperty(this, "_isRetention", void 0);
|
59
59
|
_defineProperty(this, "_actionQueryPromise", null);
|
60
60
|
_defineProperty(this, "_renderParams", null);
|
61
|
-
_defineProperty(this, "
|
61
|
+
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
62
62
|
_defineProperty(this, "_performanceData", []);
|
63
63
|
_defineProperty(this, "_isInitComponent", void 0);
|
64
64
|
_defineProperty(this, "_clickEventName", void 0);
|
65
|
-
this._appVersion = '1.
|
65
|
+
this._appVersion = '1.4.0';
|
66
66
|
this._isInitComponent = false;
|
67
67
|
this._selector = '#ams-component-section';
|
68
68
|
this.createIframeNode = function () {
|
@@ -112,13 +112,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
112
112
|
*/
|
113
113
|
}, {
|
114
114
|
key: "appendIframeNodes",
|
115
|
-
value: function appendIframeNodes(
|
115
|
+
value: function appendIframeNodes(componentSign, renderParams) {
|
116
116
|
var _renderParams$appeara,
|
117
117
|
_this = this;
|
118
118
|
if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
119
119
|
this._isInitComponent = true;
|
120
120
|
this._renderParams = renderParams;
|
121
|
-
this.
|
121
|
+
this._componentSign = componentSign;
|
122
122
|
this._performanceData.push({
|
123
123
|
key: 'sdk_create_component',
|
124
124
|
value: Date.now()
|
@@ -158,12 +158,17 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
158
158
|
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
|
159
159
|
paymentSessionConfig: (_this2$_renderParams2 = _this2._renderParams) === null || _this2$_renderParams2 === void 0 ? void 0 : (_this2$_renderParams3 = _this2$_renderParams2.paymentSessionMetaData) === null || _this2$_renderParams3 === void 0 ? void 0 : _this2$_renderParams3.paymentSessionConfig
|
160
160
|
};
|
161
|
-
|
161
|
+
/**
|
162
|
+
* @description card
|
163
|
+
*/
|
164
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign) {
|
162
165
|
params.paymentMethodType = 'CARD';
|
163
166
|
}
|
164
|
-
|
167
|
+
/**
|
168
|
+
* @description easyPay
|
169
|
+
*/
|
170
|
+
if (componentSignEnum.EASY_PAY_WALLET === _this2._componentSign) {
|
165
171
|
var _this2$_renderParams4;
|
166
|
-
// if EASY_PAY 2.0 , no need to query payment request
|
167
172
|
var _ref = params.paymentSessionConfig || {},
|
168
173
|
_ref$productSceneVers = _ref.productSceneVersion,
|
169
174
|
productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
|
@@ -174,27 +179,29 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
174
179
|
_ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
|
175
180
|
_ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
|
176
181
|
autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
|
177
|
-
if (productScene ===
|
178
|
-
//
|
179
|
-
// eslint-disable-next-line no-promise-executor-return
|
182
|
+
if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
|
183
|
+
// if EASY_PAY 2.0 , no need to query payment request
|
180
184
|
return resolve({
|
181
|
-
message: 'sdk no need to make query request'
|
185
|
+
message: 'sdk no need to make query request',
|
186
|
+
success: true
|
182
187
|
});
|
183
188
|
}
|
184
189
|
}
|
185
190
|
/**
|
186
191
|
* @author tianqiang
|
187
|
-
* @description
|
192
|
+
* @description autoDebit
|
188
193
|
*/
|
189
|
-
if (
|
194
|
+
if (componentSignEnum.AUTO_DEBIT_WALLET === _this2._componentSign) {
|
190
195
|
var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
|
191
196
|
var action = ((_this2$_renderParams5 = _this2._renderParams) === null || _this2$_renderParams5 === void 0 ? void 0 : (_this2$_renderParams6 = _this2$_renderParams5.paymentSessionMetaData) === null || _this2$_renderParams6 === void 0 ? void 0 : _this2$_renderParams6.action) || {};
|
192
|
-
var signType =
|
197
|
+
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;
|
193
198
|
if (signType === 'SMS') {
|
194
199
|
return resolve({
|
195
|
-
message: 'sdk no need to make query request'
|
200
|
+
message: 'sdk no need to make query request',
|
201
|
+
success: true
|
196
202
|
});
|
197
|
-
}
|
203
|
+
}
|
204
|
+
if (!signType || signType !== 'REDIRECT') {
|
198
205
|
return resolve({
|
199
206
|
success: false
|
200
207
|
});
|
@@ -204,7 +211,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
204
211
|
// mock
|
205
212
|
if (isLocalMock()) {
|
206
213
|
return resolve({
|
207
|
-
message: 'sdk no need to make query request'
|
214
|
+
message: 'sdk no need to make query request',
|
215
|
+
success: true
|
208
216
|
});
|
209
217
|
}
|
210
218
|
queryPaymentInfo(params, {
|
@@ -263,14 +271,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
263
271
|
this.appDomain = getAppDomain({
|
264
272
|
environment: environment,
|
265
273
|
appVersion: this._appVersion,
|
266
|
-
|
274
|
+
componentSign: this._componentSign,
|
267
275
|
productSceneVersion: productSceneVersion,
|
268
276
|
extendInfo: extendInfo
|
269
277
|
});
|
270
278
|
this.app = createIframe(this.AMSSDK.options.mode);
|
271
279
|
this.app.src = getIframeUrl({
|
272
|
-
|
273
|
-
appearance: (renderParams === null || renderParams === void 0 ? void 0 : renderParams.appearance) || {},
|
280
|
+
componentSign: this._componentSign,
|
274
281
|
analytics: this.AMSSDK.options.analytics,
|
275
282
|
productSceneVersion: productSceneVersion,
|
276
283
|
environment: environment,
|
@@ -328,9 +335,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
328
335
|
}, {
|
329
336
|
key: "_addEventListener",
|
330
337
|
value: function _addEventListener() {
|
338
|
+
this._removeEventListener();
|
331
339
|
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
|
332
340
|
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
|
333
|
-
this._removeEventListener();
|
334
341
|
window.addEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
|
335
342
|
window.addEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
336
343
|
}
|
@@ -768,7 +775,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
768
775
|
var _this5 = this;
|
769
776
|
var container = document.getElementById('ams-component-container');
|
770
777
|
// close btn
|
771
|
-
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"
|
778
|
+
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
|
772
779
|
var closeBlock = document.createElement('div');
|
773
780
|
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
|
774
781
|
closeBlock.id = 'asm-component-section-close-block';
|
package/esm/request/index.d.ts
CHANGED
@@ -12,4 +12,4 @@ import { RequestConfig } from '../types';
|
|
12
12
|
* @param options 请求配置
|
13
13
|
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
14
14
|
*/
|
15
|
-
export declare function request(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<
|
15
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<T>;
|
package/esm/request/index.js
CHANGED
@@ -15,7 +15,8 @@ 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
|
|
18
|
-
import {
|
18
|
+
import { sdkVersion } from "../config/index";
|
19
|
+
import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
|
19
20
|
import { ERROR } from "../types";
|
20
21
|
import { get } from "../util/get";
|
21
22
|
import axios from 'axios';
|
@@ -76,7 +77,7 @@ function _request() {
|
|
76
77
|
browserUserAgent: navigator.userAgent,
|
77
78
|
browserColorDepth: screen.colorDepth
|
78
79
|
},
|
79
|
-
locale:
|
80
|
+
locale: options.locale || 'en_US',
|
80
81
|
deviceLanguage: navigator.language,
|
81
82
|
screenWidth: screen.width,
|
82
83
|
screenHeight: screen.height,
|
@@ -129,11 +130,11 @@ function _request() {
|
|
129
130
|
});
|
130
131
|
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? ERROR.TIMEOUT : '';
|
131
132
|
errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
|
132
|
-
return _context.abrupt("return", {
|
133
|
+
return _context.abrupt("return", Promise.reject({
|
133
134
|
success: false,
|
134
135
|
errorCode: errorCode,
|
135
136
|
errorMessage: ''
|
136
|
-
});
|
137
|
+
}));
|
137
138
|
case 28:
|
138
139
|
case "end":
|
139
140
|
return _context.stop();
|
package/esm/service/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import { CashierSdkActionQueryRequest, RequestConfig } from '../types';
|
2
|
-
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: RequestConfig): Promise<
|
1
|
+
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, RequestConfig } from '../types';
|
2
|
+
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: RequestConfig): Promise<CashierSdkActionQueryResult>;
|
package/esm/types/index.d.ts
CHANGED
@@ -11,7 +11,6 @@
|
|
11
11
|
export interface optionsParams {
|
12
12
|
environment?: string;
|
13
13
|
locale?: string;
|
14
|
-
onReady?: any;
|
15
14
|
onError?: callOnError;
|
16
15
|
onSizeChanged?: callOnSizeChanged;
|
17
16
|
onPaymentMethodSelected?: callonPaymentMethodSelected;
|
@@ -33,10 +32,12 @@ export interface createPaymentParams {
|
|
33
32
|
backgroundColor?: string;
|
34
33
|
};
|
35
34
|
}
|
36
|
-
export declare enum
|
37
|
-
'
|
38
|
-
'
|
39
|
-
'
|
35
|
+
export declare enum componentSignEnum {
|
36
|
+
'EASY_PAY_WALLET' = "EASY_PAY_WALLET",
|
37
|
+
'CASHIER_PAYMENT_CARD' = "CASHIER_PAYMENT_CARD",
|
38
|
+
'CASHIER_PAYMENT_BANK' = "CASHIER_PAYMENT_BANK",
|
39
|
+
'AUTO_DEBIT_WALLET' = "AUTO_DEBIT_WALLET",
|
40
|
+
'NONE' = "NONE"
|
40
41
|
}
|
41
42
|
export declare enum productSceneEnum {
|
42
43
|
'EASY_PAY' = "EASY_PAY",
|
@@ -45,7 +46,8 @@ export declare enum productSceneEnum {
|
|
45
46
|
}
|
46
47
|
export declare enum paymentMethodCategoryTypeEnum {
|
47
48
|
'CARD' = "CARD",
|
48
|
-
'WALLET' = "WALLET"
|
49
|
+
'WALLET' = "WALLET",
|
50
|
+
'BANK' = "BANK"
|
49
51
|
}
|
50
52
|
export interface IcreateComponent {
|
51
53
|
paymentSessionData: string;
|
@@ -120,7 +122,10 @@ export type callOnSizeChanged = (state: {
|
|
120
122
|
width: string;
|
121
123
|
height: string;
|
122
124
|
}) => void;
|
123
|
-
export type callOnLog = (
|
125
|
+
export type callOnLog = (state: {
|
126
|
+
code: string;
|
127
|
+
message: string;
|
128
|
+
}) => void;
|
124
129
|
export declare enum messageName {
|
125
130
|
SDK_TO_APP = "SDK_TO_APP",
|
126
131
|
APP_TO_SDK = "APP_TO_SDK",
|
@@ -182,6 +187,23 @@ export interface CashierSdkActionQueryRequest {
|
|
182
187
|
paymentMethodType?: string;
|
183
188
|
extParams?: any;
|
184
189
|
}
|
190
|
+
export interface CashierSdkActionQueryResult {
|
191
|
+
supportedLanguages?: any[];
|
192
|
+
amountConfirmRequired?: boolean;
|
193
|
+
orderAmount?: Record<string, string>;
|
194
|
+
paymentMethodView?: Record<string, string>;
|
195
|
+
autoDebitWithToken?: boolean;
|
196
|
+
success: boolean;
|
197
|
+
errorCode?: string;
|
198
|
+
errorMessage?: string;
|
199
|
+
message?: string;
|
200
|
+
errorStatus?: string;
|
201
|
+
redirectUrl?: string;
|
202
|
+
normalUrl?: string;
|
203
|
+
applinkUrl?: string;
|
204
|
+
schemeUrl?: string;
|
205
|
+
authUrl?: string;
|
206
|
+
}
|
185
207
|
declare global {
|
186
208
|
interface Window {
|
187
209
|
[key: string]: any;
|
package/esm/types/index.js
CHANGED
@@ -10,11 +10,13 @@
|
|
10
10
|
* SDK options
|
11
11
|
*/
|
12
12
|
|
13
|
-
export var
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
|
14
|
+
componentSignEnum["EASY_PAY_WALLET"] = "EASY_PAY_WALLET";
|
15
|
+
componentSignEnum["CASHIER_PAYMENT_CARD"] = "CASHIER_PAYMENT_CARD";
|
16
|
+
componentSignEnum["CASHIER_PAYMENT_BANK"] = "CASHIER_PAYMENT_BANK";
|
17
|
+
componentSignEnum["AUTO_DEBIT_WALLET"] = "AUTO_DEBIT_WALLET";
|
18
|
+
componentSignEnum["NONE"] = "NONE";
|
19
|
+
return componentSignEnum;
|
18
20
|
}({});
|
19
21
|
export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
20
22
|
productSceneEnum["EASY_PAY"] = "EASY_PAY";
|
@@ -25,6 +27,7 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
|
25
27
|
export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
|
26
28
|
paymentMethodCategoryTypeEnum["CARD"] = "CARD";
|
27
29
|
paymentMethodCategoryTypeEnum["WALLET"] = "WALLET";
|
30
|
+
paymentMethodCategoryTypeEnum["BANK"] = "BANK";
|
28
31
|
return paymentMethodCategoryTypeEnum;
|
29
32
|
}({});
|
30
33
|
export var localeEnum = /*#__PURE__*/function (localeEnum) {
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@alipay/ams-checkout","version":"1.
|
1
|
+
{"name":"@alipay/ams-checkout","version":"1.4.0","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
|