@alipay/ams-checkout 0.0.1690894389-dev.1 → 0.0.1691379784-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/esm/config/index.d.ts +2 -22
- package/dist/esm/config/index.js +9 -61
- package/dist/esm/config/request.d.ts +21 -0
- package/dist/esm/config/request.js +67 -0
- package/dist/esm/constant/index.d.ts +1 -0
- package/dist/esm/constant/index.js +1 -0
- package/dist/esm/core/component/index.d.ts +3 -3
- package/dist/esm/core/component/index.js +42 -88
- package/dist/esm/core/instance/index.d.ts +2 -10
- package/dist/esm/core/instance/index.js +0 -22
- package/dist/esm/plugin/component/cashierApp.d.ts +23 -0
- package/dist/esm/plugin/component/cashierApp.js +122 -0
- package/dist/esm/plugin/component/component.style.js +1 -1
- package/dist/esm/plugin/component/index.d.ts +9 -15
- package/dist/esm/plugin/component/index.js +116 -144
- package/dist/esm/request/index.d.ts +1 -1
- package/dist/esm/request/index.js +5 -5
- package/dist/esm/service/index.d.ts +2 -2
- package/dist/esm/types/index.d.ts +42 -13
- package/dist/esm/types/index.js +8 -5
- package/dist/esm/util/index.js +1 -1
- package/dist/umd/ams-checkout.min.js +1 -1
- package/package.json +1 -1
- package/dist/esm/plugin/component/appPath.d.ts +0 -2
- package/dist/esm/plugin/component/appPath.js +0 -75
@@ -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
|
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: translateX(-50%) translateY(-50%) scale(1);\n opacity: 1\n }\n\n 80% {\n opacity: 0\n }\n \n 100% {\n opacity: 0;\n transform: translateX(-50%) translateY(-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 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}\n\n.ams-component-retention-remain-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\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}\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}\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}\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}\n\n";
|
10
10
|
export function componentAddCSS() {
|
11
11
|
var style = document.createElement('style');
|
12
12
|
style.type = 'text/css';
|
@@ -1,9 +1,8 @@
|
|
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
|
-
paymentMethodsResult: any;
|
7
6
|
appDomain: string;
|
8
7
|
AMSSDK: AMSCheckout;
|
9
8
|
platform: 'desktop' | 'mobile';
|
@@ -13,7 +12,7 @@ export default class ComponentApp {
|
|
13
12
|
private _isRetention;
|
14
13
|
private _actionQueryPromise;
|
15
14
|
private _renderParams;
|
16
|
-
private
|
15
|
+
private _componentSign;
|
17
16
|
private _performanceData;
|
18
17
|
private _isInitComponent;
|
19
18
|
private _clickEventName;
|
@@ -33,23 +32,18 @@ export default class ComponentApp {
|
|
33
32
|
/**
|
34
33
|
* @description render iframe content
|
35
34
|
*/
|
36
|
-
appendIframeNodes(
|
37
|
-
|
35
|
+
appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void | [void, CashierSdkActionQueryResult | null]>;
|
36
|
+
/**
|
37
|
+
* @description Interface request
|
38
|
+
*/
|
39
|
+
private createActionQueryPromise;
|
38
40
|
private cleanApp;
|
39
41
|
/**
|
40
42
|
* @description Create app
|
41
43
|
*/
|
42
44
|
private createApp;
|
43
|
-
private
|
44
|
-
|
45
|
-
* @description Create iframe
|
46
|
-
*/
|
47
|
-
private createIframe;
|
48
|
-
/**
|
49
|
-
* @description Get iftame id
|
50
|
-
*/
|
51
|
-
private _getIframeId;
|
52
|
-
private _listener;
|
45
|
+
private listener;
|
46
|
+
private resizeListener;
|
53
47
|
/**
|
54
48
|
* @description Initialize subscription iframe message
|
55
49
|
*/
|
@@ -17,18 +17,20 @@ 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
|
21
|
-
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
20
|
+
import { closeImg, COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
22
21
|
import { queryPaymentInfo } from "../../service";
|
23
|
-
import {
|
24
|
-
import { getDesignFontSize,
|
22
|
+
import { componentSignEnum, messageName, productSceneEnum, Target } from "../../types";
|
23
|
+
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
|
25
24
|
import { isLocalMock } from "../../util/mock";
|
26
|
-
import { getAppDomain,
|
25
|
+
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
27
26
|
import { componentAddCSS } from "./component.style";
|
27
|
+
var _window = window,
|
28
|
+
innerHeight = _window.innerHeight;
|
28
29
|
var amsSetSize = function amsSetSize(event, dom) {
|
29
30
|
try {
|
30
31
|
var _dom = dom || document.getElementById('ams-component-container');
|
31
32
|
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
|
33
|
+
innerHeight = window.innerHeight;
|
32
34
|
// eslint-disable-next-line no-empty
|
33
35
|
} catch (error) {}
|
34
36
|
};
|
@@ -40,15 +42,13 @@ var addEvent = function addEvent() {
|
|
40
42
|
window.addEventListener('pageShow', amsSetSize);
|
41
43
|
window.addEventListener('DOMContentLoaded', amsSetSize);
|
42
44
|
};
|
43
|
-
var _window = window,
|
44
|
-
innerHeight = _window.innerHeight;
|
45
45
|
var mockupId = 'ams-component-mockup';
|
46
46
|
var loadingId = 'ams-component-loading';
|
47
|
+
var listenerPrefix = '_ams_sdk_component_listener';
|
47
48
|
var ComponentApp = /*#__PURE__*/function () {
|
48
49
|
function ComponentApp() {
|
49
50
|
_classCallCheck(this, ComponentApp);
|
50
51
|
_defineProperty(this, "app", void 0);
|
51
|
-
_defineProperty(this, "paymentMethodsResult", void 0);
|
52
52
|
_defineProperty(this, "appDomain", void 0);
|
53
53
|
_defineProperty(this, "AMSSDK", void 0);
|
54
54
|
_defineProperty(this, "platform", void 0);
|
@@ -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,11 +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
|
+
this._renderParams = renderParams;
|
121
|
+
this._componentSign = componentSign;
|
120
122
|
this._performanceData.push({
|
121
123
|
key: 'sdk_create_component',
|
122
124
|
value: Date.now()
|
@@ -131,19 +133,20 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
131
133
|
this.showLoading();
|
132
134
|
}
|
133
135
|
this.showCashier();
|
134
|
-
this._renderParams = renderParams;
|
135
|
-
this._componentName = componentName;
|
136
136
|
this.createApp(renderParams);
|
137
|
-
this.
|
137
|
+
this.createActionQueryPromise();
|
138
138
|
return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
|
139
139
|
selector: this._selector
|
140
140
|
})), this._actionQueryPromise]).catch(function () {
|
141
141
|
_this._isInitComponent = false;
|
142
142
|
});
|
143
143
|
}
|
144
|
+
/**
|
145
|
+
* @description Interface request
|
146
|
+
*/
|
144
147
|
}, {
|
145
|
-
key: "
|
146
|
-
value: function
|
148
|
+
key: "createActionQueryPromise",
|
149
|
+
value: function createActionQueryPromise() {
|
147
150
|
var _this2 = this;
|
148
151
|
this._performanceData.push({
|
149
152
|
key: 'sdk_action_query_start',
|
@@ -152,59 +155,64 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
152
155
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
153
156
|
var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
|
154
157
|
var params = {
|
155
|
-
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData),
|
156
|
-
paymentSessionConfig: (
|
158
|
+
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
|
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
|
157
160
|
};
|
158
|
-
|
159
|
-
|
161
|
+
/**
|
162
|
+
* @description card
|
163
|
+
*/
|
164
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign) {
|
160
165
|
params.paymentMethodType = 'CARD';
|
161
|
-
params.paymentSessionConfig = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : (_this2$_renderParams5 = _this2$_renderParams4.paymentSessionMetaData) === null || _this2$_renderParams5 === void 0 ? void 0 : _this2$_renderParams5.paymentSessionConfig) || {};
|
162
166
|
}
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
var
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
productScene =
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
//
|
167
|
+
/**
|
168
|
+
* @description easyPay
|
169
|
+
*/
|
170
|
+
if (componentSignEnum.EASY_PAY_WALLET === _this2._componentSign) {
|
171
|
+
var _this2$_renderParams4;
|
172
|
+
var _ref = params.paymentSessionConfig || {},
|
173
|
+
_ref$productSceneVers = _ref.productSceneVersion,
|
174
|
+
productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
|
175
|
+
_ref$productScene = _ref.productScene,
|
176
|
+
productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
|
177
|
+
var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
|
178
|
+
_ref2$action = _ref2.action,
|
179
|
+
_ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
|
180
|
+
_ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
|
181
|
+
autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
|
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 (
|
190
|
-
var _this2$
|
191
|
-
var action = ((_this2$
|
192
|
-
var signType =
|
194
|
+
if (componentSignEnum.AUTO_DEBIT_WALLET === _this2._componentSign) {
|
195
|
+
var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
|
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) || {};
|
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
|
});
|
201
208
|
}
|
202
209
|
}
|
203
210
|
|
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, {
|
@@ -215,7 +223,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
215
223
|
key: 'sdk_action_query_end',
|
216
224
|
value: Date.now()
|
217
225
|
});
|
218
|
-
if (res && res.success) {
|
226
|
+
if (res !== null && res !== void 0 && res.success) {
|
219
227
|
resolve(res);
|
220
228
|
} else {
|
221
229
|
resolve(res);
|
@@ -259,9 +267,25 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
259
267
|
var _renderParams$payment, _renderParams$payment2, _renderParams$payment3;
|
260
268
|
var productSceneVersion = (renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$payment = renderParams.paymentSessionMetaData) === null || _renderParams$payment === void 0 ? void 0 : (_renderParams$payment2 = _renderParams$payment.paymentSessionConfig) === null || _renderParams$payment2 === void 0 ? void 0 : _renderParams$payment2.productSceneVersion) || '';
|
261
269
|
var extendInfo = (renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$payment3 = renderParams.paymentSessionMetaData) === null || _renderParams$payment3 === void 0 ? void 0 : _renderParams$payment3.extendInfo) || '';
|
262
|
-
|
263
|
-
this.
|
264
|
-
|
270
|
+
var environment = this.AMSSDK.options.env.environment;
|
271
|
+
this.appDomain = getAppDomain({
|
272
|
+
environment: environment,
|
273
|
+
appVersion: this._appVersion,
|
274
|
+
componentSign: this._componentSign,
|
275
|
+
productSceneVersion: productSceneVersion,
|
276
|
+
extendInfo: extendInfo
|
277
|
+
});
|
278
|
+
this.app = createIframe(this.AMSSDK.options.mode);
|
279
|
+
this.app.src = getIframeUrl({
|
280
|
+
componentSign: this._componentSign,
|
281
|
+
analytics: this.AMSSDK.options.analytics,
|
282
|
+
productSceneVersion: productSceneVersion,
|
283
|
+
environment: environment,
|
284
|
+
appVersion: this._appVersion,
|
285
|
+
extendInfo: extendInfo,
|
286
|
+
locale: this.AMSSDK.options.locale,
|
287
|
+
instanceId: this.AMSSDK._instanceId
|
288
|
+
});
|
265
289
|
|
266
290
|
// Subscribe to messages from iframe
|
267
291
|
this._addEventListener();
|
@@ -272,76 +296,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
272
296
|
}
|
273
297
|
}
|
274
298
|
}, {
|
275
|
-
key: "
|
276
|
-
value: function
|
277
|
-
var _this$_renderParams, _this$_renderParams$p;
|
278
|
-
var analytics = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
279
|
-
var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
|
280
|
-
var path = getAppPath(this.AMSSDK.options.env.environment, this._appVersion, componentName, productSceneVersion, ((_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.extendInfo) || '');
|
281
|
-
var scale = getViewPort('initial-scale') || 1;
|
282
|
-
var _queryParse = queryParse(),
|
283
|
-
_sandbox = _queryParse._sandbox,
|
284
|
-
_light_sandbox = _queryParse._light_sandbox,
|
285
|
-
_queryParse$requestHo = _queryParse.requestHost,
|
286
|
-
requestHost = _queryParse$requestHo === void 0 ? '' : _queryParse$requestHo,
|
287
|
-
_queryParse$groupId = _queryParse.groupId,
|
288
|
-
groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
|
289
|
-
LOCAL_MOCK = _queryParse.LOCAL_MOCK;
|
290
|
-
var urlParams = Object.assign({
|
291
|
-
locale: this.AMSSDK.options.locale,
|
292
|
-
scale: scale,
|
293
|
-
merchantDomain: window.btoa(getOrigin()),
|
294
|
-
instanceId: this.AMSSDK._instanceId,
|
295
|
-
sandbox: this.AMSSDK.options.env.environment === 'light_sandbox' || _light_sandbox === 'true' ? 'true' : 'false',
|
296
|
-
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
297
|
-
sdkVersion: json.version,
|
298
|
-
refUrl: window.location.href,
|
299
|
-
shadow: this.AMSSDK.options.env.environment === 'sandbox' || _sandbox === 'true' ? 'true' : 'false',
|
300
|
-
requestHost: requestHost,
|
301
|
-
groupId: groupId,
|
302
|
-
LOCAL_MOCK: LOCAL_MOCK
|
303
|
-
}, appearance);
|
304
|
-
var locationSearch = serialize(urlParams);
|
305
|
-
return "".concat(path, "?").concat(locationSearch);
|
306
|
-
}
|
307
|
-
|
308
|
-
/**
|
309
|
-
* @description Create iframe
|
310
|
-
*/
|
311
|
-
}, {
|
312
|
-
key: "createIframe",
|
313
|
-
value: function createIframe() {
|
314
|
-
var iframe = document.createElement('iframe');
|
315
|
-
var iframeId = this._getIframeId(this.AMSSDK.options.mode);
|
316
|
-
iframe.id = iframeId;
|
317
|
-
iframe.style.height = '0px';
|
318
|
-
iframe.style.width = '100%';
|
319
|
-
iframe.style.border = '0';
|
320
|
-
iframe.style.overflow = 'hidden';
|
321
|
-
return iframe;
|
322
|
-
}
|
323
|
-
|
324
|
-
/**
|
325
|
-
* @description Get iftame id
|
326
|
-
*/
|
327
|
-
}, {
|
328
|
-
key: "_getIframeId",
|
329
|
-
value: function _getIframeId(UIMode) {
|
330
|
-
var id = 'checkout-dropin';
|
331
|
-
// eslint-disable-next-line default-case
|
332
|
-
switch (UIMode) {
|
333
|
-
case 'dropin':
|
334
|
-
id = 'checkout-dropin';
|
335
|
-
break;
|
336
|
-
case 'component':
|
337
|
-
id = 'checkout-component';
|
338
|
-
break;
|
339
|
-
}
|
340
|
-
return id;
|
341
|
-
}
|
342
|
-
}, {
|
343
|
-
key: "_listener",
|
344
|
-
value: function _listener(e) {
|
299
|
+
key: "listener",
|
300
|
+
value: function listener(e) {
|
345
301
|
if (e.origin !== this.appDomain) {
|
346
302
|
return;
|
347
303
|
}
|
@@ -357,6 +313,21 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
357
313
|
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.NOT_JSON_FORMAT);
|
358
314
|
}
|
359
315
|
}
|
316
|
+
}, {
|
317
|
+
key: "resizeListener",
|
318
|
+
value: function resizeListener() {
|
319
|
+
var cashier = document.getElementById('ams-component-container');
|
320
|
+
cashier.style.transition = 'none';
|
321
|
+
this.dispatchToApp({
|
322
|
+
context: {
|
323
|
+
event: 'renderResize',
|
324
|
+
data: {
|
325
|
+
heightOfVisible: window.innerHeight,
|
326
|
+
widthOfVisible: window.innerWidth
|
327
|
+
}
|
328
|
+
}
|
329
|
+
});
|
330
|
+
}
|
360
331
|
|
361
332
|
/**
|
362
333
|
* @description Initialize subscription iframe message
|
@@ -364,14 +335,17 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
364
335
|
}, {
|
365
336
|
key: "_addEventListener",
|
366
337
|
value: function _addEventListener() {
|
367
|
-
window["_ams_sdk_component_listener_".concat(this.AMSSDK._instanceId)] = this._listener.bind(this);
|
368
338
|
this._removeEventListener();
|
369
|
-
window.
|
339
|
+
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
|
340
|
+
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
|
341
|
+
window.addEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
|
342
|
+
window.addEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
370
343
|
}
|
371
344
|
}, {
|
372
345
|
key: "_removeEventListener",
|
373
346
|
value: function _removeEventListener() {
|
374
|
-
window.removeEventListener('message', window["
|
347
|
+
window.removeEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
|
348
|
+
window.removeEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
375
349
|
}
|
376
350
|
|
377
351
|
/**
|
@@ -474,7 +448,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
474
448
|
// size变动时动画
|
475
449
|
setTimeout(function () {
|
476
450
|
cashier.style.transition = 'height 0.28s ease-in-out';
|
477
|
-
},
|
451
|
+
}, 500);
|
478
452
|
}
|
479
453
|
this.app.style.height = "".concat(data.context.data.height, "px");
|
480
454
|
this.app.style.width = '100%';
|
@@ -508,10 +482,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
508
482
|
});
|
509
483
|
};
|
510
484
|
|
511
|
-
//
|
485
|
+
// 支持 target: _blank,新开tab页打开
|
512
486
|
if (_data.target === Target.BLANK) {
|
487
|
+
if (!_data.normalUrl) return failCallback();
|
513
488
|
successCallback('normalUrl', _data.normalUrl);
|
514
|
-
if (!_data.normalUrl) return;
|
515
489
|
window.open(_data.normalUrl);
|
516
490
|
return;
|
517
491
|
}
|
@@ -537,9 +511,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
537
511
|
}
|
538
512
|
}, {
|
539
513
|
key: "handleDeclareInfo",
|
540
|
-
value: function handleDeclareInfo(
|
541
|
-
var
|
542
|
-
closeDialogData =
|
514
|
+
value: function handleDeclareInfo(_ref3) {
|
515
|
+
var _ref3$closeDialogData = _ref3.closeDialogData,
|
516
|
+
closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
|
543
517
|
try {
|
544
518
|
if (closeDialogData) {
|
545
519
|
var retentionTitle = document.getElementById('ams-component-retention-title');
|
@@ -610,7 +584,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
610
584
|
*/
|
611
585
|
}, {
|
612
586
|
key: "dispatchToApp",
|
613
|
-
value: function dispatchToApp(
|
587
|
+
value: function dispatchToApp(payload) {
|
588
|
+
var data = Object.assign({}, payload, {
|
589
|
+
name: messageName.SDK_TO_APP,
|
590
|
+
mode: this.AMSSDK.options.mode,
|
591
|
+
appId: COMPONENTPLUGINID,
|
592
|
+
instanceId: this.AMSSDK._instanceId
|
593
|
+
});
|
614
594
|
if (this.app && this.app.contentWindow) {
|
615
595
|
this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
616
596
|
}
|
@@ -638,7 +618,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
638
618
|
key: "sendRenderEvent",
|
639
619
|
value: function () {
|
640
620
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
641
|
-
var _this$
|
621
|
+
var _this$_renderParams, _this$_renderParams2, res;
|
642
622
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
643
623
|
while (1) switch (_context.prev = _context.next) {
|
644
624
|
case 0:
|
@@ -658,16 +638,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
658
638
|
value: Date.now()
|
659
639
|
});
|
660
640
|
this.dispatchToApp({
|
661
|
-
name: messageName.SDK_TO_APP,
|
662
|
-
mode: this.AMSSDK.options.mode,
|
663
|
-
appId: COMPONENTPLUGINID,
|
664
|
-
instanceId: this.AMSSDK._instanceId,
|
665
641
|
context: {
|
666
642
|
event: 'renderComponent',
|
667
643
|
data: {
|
668
644
|
queryResult: res,
|
669
|
-
sessionResult: (_this$
|
670
|
-
paymentSessionData: (_this$
|
645
|
+
sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
|
646
|
+
paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
|
671
647
|
heightOfVisible: Math.max(innerHeight, window.innerHeight),
|
672
648
|
envInfo: {
|
673
649
|
screenHeight: screen.height,
|
@@ -677,10 +653,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
677
653
|
}
|
678
654
|
});
|
679
655
|
this.dispatchToApp({
|
680
|
-
name: messageName.SDK_TO_APP,
|
681
|
-
mode: this.AMSSDK.options.mode,
|
682
|
-
appId: COMPONENTPLUGINID,
|
683
|
-
instanceId: this.AMSSDK._instanceId,
|
684
656
|
context: {
|
685
657
|
event: 'web-sdk-performance',
|
686
658
|
data: {
|
@@ -803,7 +775,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
803
775
|
var _this5 = this;
|
804
776
|
var container = document.getElementById('ams-component-container');
|
805
777
|
// close btn
|
806
|
-
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, "\"/>");
|
807
779
|
var closeBlock = document.createElement('div');
|
808
780
|
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
|
809
781
|
closeBlock.id = 'asm-component-section-close-block';
|
@@ -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>;
|
@@ -15,11 +15,11 @@ 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';
|
22
|
-
import json from "../../package.json";
|
23
23
|
import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
|
24
24
|
var _queryParse = queryParse(),
|
25
25
|
_sandbox = _queryParse._sandbox;
|
@@ -35,7 +35,7 @@ function requestInstance(options) {
|
|
35
35
|
var _headers = _objectSpread((_objectSpread2 = {
|
36
36
|
appId: lightSandboxConfig.appId || appId,
|
37
37
|
workspaceId: options.env === 'pre' ? 'pre' : 'default'
|
38
|
-
}, _defineProperty(_objectSpread2, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), _defineProperty(_objectSpread2, "version", '2.0'), _defineProperty(_objectSpread2, 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), _defineProperty(_objectSpread2, 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), _defineProperty(_objectSpread2, 'Client-Time', utcTimestamp), _defineProperty(_objectSpread2, "tntInstId", tntInstId), _defineProperty(_objectSpread2, 'sdk-version',
|
38
|
+
}, _defineProperty(_objectSpread2, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), _defineProperty(_objectSpread2, "version", '2.0'), _defineProperty(_objectSpread2, 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), _defineProperty(_objectSpread2, 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), _defineProperty(_objectSpread2, 'Client-Time', utcTimestamp), _defineProperty(_objectSpread2, "tntInstId", tntInstId), _defineProperty(_objectSpread2, 'sdk-version', sdkVersion || ''), _objectSpread2), options.headers);
|
39
39
|
// sandbox 影子链路
|
40
40
|
if (_sandbox === 'true' || env === 'sandbox') {
|
41
41
|
_headers['load-test'] = true;
|
@@ -130,11 +130,11 @@ function _request() {
|
|
130
130
|
});
|
131
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 : '';
|
132
132
|
errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
|
133
|
-
return _context.abrupt("return", {
|
133
|
+
return _context.abrupt("return", Promise.reject({
|
134
134
|
success: false,
|
135
135
|
errorCode: errorCode,
|
136
136
|
errorMessage: ''
|
137
|
-
});
|
137
|
+
}));
|
138
138
|
case 28:
|
139
139
|
case "end":
|
140
140
|
return _context.stop();
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { RequestConfig } from '../types';
|
2
|
-
export declare function queryPaymentInfo(params?:
|
1
|
+
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, RequestConfig } from '../types';
|
2
|
+
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: RequestConfig): Promise<CashierSdkActionQueryResult>;
|