@alipay/ams-checkout 1.36.0 → 1.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +18 -2
- package/esm/constant/index.js +20 -5
- package/esm/core/component/element/elementController/index.d.ts +1 -1
- package/esm/core/component/element/elementController/index.js +7 -6
- package/esm/core/component/element/index.d.ts +0 -1
- package/esm/core/component/element/index.js +3 -6
- package/esm/core/component/element/type.d.ts +3 -18
- package/esm/core/component/element/util.d.ts +9 -6
- package/esm/core/component/element/util.js +28 -29
- package/esm/core/component/oldElement/type.d.ts +3 -0
- package/esm/core/instance/index.js +1 -1
- package/esm/foundation/service/container/index.d.ts +5 -0
- package/esm/foundation/service/container/index.js +85 -4
- package/esm/foundation/utils/redirect_utils.js +34 -18
- package/esm/plugin/component/index.js +1 -1
- package/esm/types/index.d.ts +11 -1
- package/esm/types/index.js +2 -1
- package/esm/util/redirect.js +1 -1
- package/package.json +25 -3
package/esm/config/index.d.ts
CHANGED
@@ -5,10 +5,10 @@ export declare const sdkVersion: string;
|
|
5
5
|
/**
|
6
6
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
7
7
|
*/
|
8
|
-
export declare const AMSCheckoutAppVersion = "1.
|
9
|
-
export declare const AMSAutoDebitAppVersion = "1.
|
10
|
-
export declare const AMSEasyPayAppVersion = "1.
|
11
|
-
export declare const AMSCashierPaymentAppVersion = "1.
|
12
|
-
export declare const AMSVaultingAppVersion = "1.
|
13
|
-
export declare const AMSPaymentElementAppVersion = "1.
|
14
|
-
export declare const ADDRESSElementAppVersion = "1.
|
8
|
+
export declare const AMSCheckoutAppVersion = "1.38.0";
|
9
|
+
export declare const AMSAutoDebitAppVersion = "1.38.0";
|
10
|
+
export declare const AMSEasyPayAppVersion = "1.38.0";
|
11
|
+
export declare const AMSCashierPaymentAppVersion = "1.38.0";
|
12
|
+
export declare const AMSVaultingAppVersion = "1.38.0";
|
13
|
+
export declare const AMSPaymentElementAppVersion = "1.38.0";
|
14
|
+
export declare const ADDRESSElementAppVersion = "1.38.0";
|
package/esm/config/index.js
CHANGED
@@ -35,10 +35,10 @@ export var sdkVersion = json.version;
|
|
35
35
|
/**
|
36
36
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
37
37
|
*/
|
38
|
-
export var AMSCheckoutAppVersion = '1.
|
39
|
-
export var AMSAutoDebitAppVersion = '1.
|
40
|
-
export var AMSEasyPayAppVersion = '1.
|
41
|
-
export var AMSCashierPaymentAppVersion = '1.
|
42
|
-
export var AMSVaultingAppVersion = '1.
|
43
|
-
export var AMSPaymentElementAppVersion = '1.
|
44
|
-
export var ADDRESSElementAppVersion = '1.
|
38
|
+
export var AMSCheckoutAppVersion = '1.38.0'; // 兜底版本号
|
39
|
+
export var AMSAutoDebitAppVersion = '1.38.0'; // 代扣
|
40
|
+
export var AMSEasyPayAppVersion = '1.38.0'; // easypay
|
41
|
+
export var AMSCashierPaymentAppVersion = '1.38.0'; // 收银台(卡、apm)
|
42
|
+
export var AMSVaultingAppVersion = '1.38.0'; // 绑卡
|
43
|
+
export var AMSPaymentElementAppVersion = '1.38.0'; // payment element
|
44
|
+
export var ADDRESSElementAppVersion = '1.38.0'; // address element
|
package/esm/constant/index.d.ts
CHANGED
@@ -67,9 +67,9 @@ export declare const ERRORMESSAGE: {
|
|
67
67
|
message: string;
|
68
68
|
};
|
69
69
|
};
|
70
|
-
|
70
|
+
SDK_LAUNCH_PAYMENT_APP_ERROR: {
|
71
71
|
code: eventCodeEnum;
|
72
|
-
|
72
|
+
CALL_APP_URL_ERROR: {
|
73
73
|
code: eventCodeEnum;
|
74
74
|
message: string;
|
75
75
|
};
|
@@ -78,6 +78,16 @@ export declare const ERRORMESSAGE: {
|
|
78
78
|
code: eventCodeEnum;
|
79
79
|
message: string;
|
80
80
|
};
|
81
|
+
/**
|
82
|
+
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
83
|
+
*/
|
84
|
+
SDK_CALL_URL_ERROR: {
|
85
|
+
code: eventCodeEnum;
|
86
|
+
REDIRECT_ERROR: {
|
87
|
+
code: eventCodeEnum;
|
88
|
+
message: string;
|
89
|
+
};
|
90
|
+
};
|
81
91
|
};
|
82
92
|
export declare const BASEPLUGINID = "CHECKOUT";
|
83
93
|
export declare const COMPONENTPLUGINID = "COMPONENT";
|
@@ -165,6 +175,9 @@ export declare const EVENT: {
|
|
165
175
|
getGlobalData: {
|
166
176
|
name: string;
|
167
177
|
};
|
178
|
+
/**
|
179
|
+
* @deprecated 已废弃 请使用eventCallback
|
180
|
+
*/
|
168
181
|
sendMuitiAppEventToSdk: {
|
169
182
|
name: string;
|
170
183
|
};
|
@@ -222,6 +235,9 @@ export declare const EVENT: {
|
|
222
235
|
getSdkVersion: {
|
223
236
|
name: string;
|
224
237
|
};
|
238
|
+
inputFocus: {
|
239
|
+
name: string;
|
240
|
+
};
|
225
241
|
};
|
226
242
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
227
243
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -67,16 +67,26 @@ export var ERRORMESSAGE = {
|
|
67
67
|
message: 'Load resource timeout'
|
68
68
|
}
|
69
69
|
},
|
70
|
+
SDK_LAUNCH_PAYMENT_APP_ERROR: {
|
71
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
72
|
+
CALL_APP_URL_ERROR: {
|
73
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
74
|
+
message: 'Failed to launch app'
|
75
|
+
}
|
76
|
+
},
|
77
|
+
SDK_SUBMIT_ERROR: {
|
78
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
79
|
+
message: 'Component not created or current browser compatibility issue, not supported'
|
80
|
+
},
|
81
|
+
/**
|
82
|
+
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
83
|
+
*/
|
70
84
|
SDK_CALL_URL_ERROR: {
|
71
85
|
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
72
86
|
REDIRECT_ERROR: {
|
73
87
|
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
74
88
|
message: 'Redirect data exception'
|
75
89
|
}
|
76
|
-
},
|
77
|
-
SDK_SUBMIT_ERROR: {
|
78
|
-
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
79
|
-
message: 'Component not created or current browser compatibility issue, not supported'
|
80
90
|
}
|
81
91
|
};
|
82
92
|
export var BASEPLUGINID = 'CHECKOUT';
|
@@ -166,7 +176,9 @@ export var EVENT = {
|
|
166
176
|
getGlobalData: {
|
167
177
|
name: 'getGlobalData'
|
168
178
|
},
|
169
|
-
|
179
|
+
/**
|
180
|
+
* @deprecated 已废弃 请使用eventCallback
|
181
|
+
*/
|
170
182
|
sendMuitiAppEventToSdk: {
|
171
183
|
name: 'sendMuitiAppEventToSdk'
|
172
184
|
},
|
@@ -224,6 +236,9 @@ export var EVENT = {
|
|
224
236
|
},
|
225
237
|
getSdkVersion: {
|
226
238
|
name: 'getSdkVersion'
|
239
|
+
},
|
240
|
+
inputFocus: {
|
241
|
+
name: 'onInputFocus'
|
227
242
|
}
|
228
243
|
};
|
229
244
|
export var COMPONENT_CONTAINER_ID = 'ams-component-container';
|
@@ -12,7 +12,7 @@ declare class ElementController {
|
|
12
12
|
private initService;
|
13
13
|
private initElementProcessors;
|
14
14
|
private onEventCallback;
|
15
|
-
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string
|
15
|
+
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string): any;
|
16
16
|
private onValidateFunc;
|
17
17
|
submitPayment(): void;
|
18
18
|
private changeLoading;
|
@@ -20,7 +20,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
20
20
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
21
21
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
22
22
|
import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
|
23
|
-
import { EVENT } from "../../../../constant";
|
23
|
+
import { ERRORMESSAGE, EVENT } from "../../../../constant";
|
24
24
|
import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
|
25
25
|
import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
|
26
26
|
import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
|
@@ -108,7 +108,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
108
108
|
}
|
109
109
|
}, {
|
110
110
|
key: "mount",
|
111
|
-
value: function mount(renderOptions, sdkSelector
|
111
|
+
value: function mount(renderOptions, sdkSelector) {
|
112
112
|
var _this = this;
|
113
113
|
return new Promise(function (resolve) {
|
114
114
|
var _checkCanMount = checkCanMount({
|
@@ -135,6 +135,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
135
135
|
_this.initTimeout = null;
|
136
136
|
_this.changeLoading(false);
|
137
137
|
_this.setControllerStatusOrView(IElementStatus.READY);
|
138
|
+
_this.onEventCallback(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
138
139
|
_this.elementContainerService.getContainerServices().forEach(function (value) {
|
139
140
|
value.getContainerElement().remove();
|
140
141
|
});
|
@@ -147,15 +148,14 @@ var ElementController = /*#__PURE__*/function () {
|
|
147
148
|
appendAliasContainerId: true
|
148
149
|
})
|
149
150
|
};
|
150
|
-
if (cashier && renderOptions.sessionData) {
|
151
|
-
startBizFlowData.paymentSession = renderOptions.sessionData;
|
152
|
-
}
|
153
151
|
_this.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
|
154
152
|
_this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
|
155
153
|
_this.onEventCallback({
|
156
154
|
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
157
155
|
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
158
156
|
});
|
157
|
+
clearTimeout(_this.initTimeout);
|
158
|
+
_this.initTimeout = null;
|
159
159
|
_this.changeLoading(false);
|
160
160
|
return;
|
161
161
|
});
|
@@ -303,7 +303,8 @@ var ElementController = /*#__PURE__*/function () {
|
|
303
303
|
// }
|
304
304
|
});
|
305
305
|
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
306
|
-
|
306
|
+
var onEventCallback = _this4.onEventCallback.bind(_this4);
|
307
|
+
handleRedirect(data, false, onEventCallback);
|
307
308
|
});
|
308
309
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
309
310
|
_this4.setControllerStatusOrView(IElementStatus.READY);
|
@@ -7,7 +7,6 @@ export declare class ElementComponent {
|
|
7
7
|
mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
8
8
|
mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
9
9
|
mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
|
10
|
-
mountCashier(renderOptions: any, sdkSelector: any): any;
|
11
10
|
submitPayment(): void;
|
12
11
|
destroy(): void;
|
13
12
|
}
|
@@ -11,12 +11,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
11
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
12
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
13
13
|
import ElementController from "./elementController";
|
14
|
-
import { formatElementOption } from "./util";
|
14
|
+
import { formatElementOption, validateElementOption } from "./util";
|
15
15
|
export var ElementComponent = /*#__PURE__*/function () {
|
16
16
|
function ElementComponent(options) {
|
17
17
|
_classCallCheck(this, ElementComponent);
|
18
18
|
_defineProperty(this, "options", void 0);
|
19
19
|
_defineProperty(this, "controller", void 0);
|
20
|
+
var validate = validateElementOption(options);
|
21
|
+
if (!validate) return;
|
20
22
|
this.options = formatElementOption(options);
|
21
23
|
this.controller = new ElementController(options);
|
22
24
|
}
|
@@ -47,11 +49,6 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
47
49
|
appearance: this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.appearance
|
48
50
|
}, renderOptions), sdkSelector);
|
49
51
|
}
|
50
|
-
}, {
|
51
|
-
key: "mountCashier",
|
52
|
-
value: function mountCashier(renderOptions, sdkSelector) {
|
53
|
-
return this.controller.mount(renderOptions, sdkSelector, true);
|
54
|
-
}
|
55
52
|
}, {
|
56
53
|
key: "submitPayment",
|
57
54
|
value: function submitPayment() {
|
@@ -13,6 +13,9 @@ export declare enum ElementPaymentEvent {
|
|
13
13
|
SIZE_CHANGE = "onSizeChange",
|
14
14
|
LAUNCH = "onLaunch",
|
15
15
|
CALLBACK = "callback",
|
16
|
+
/**
|
17
|
+
* @deprecated 已废弃 请使用eventCallback
|
18
|
+
*/
|
16
19
|
SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
|
17
20
|
LOG = "log",
|
18
21
|
HANDLE_PAYMENT = "handlePayment"
|
@@ -62,23 +65,6 @@ export declare enum ELEMENT_ENVIRONMENT {
|
|
62
65
|
SANDBOX = "SANDBOX"
|
63
66
|
}
|
64
67
|
export type ELEMENT_ENVIRONMENT_TYPE = keyof typeof ELEMENT_ENVIRONMENT | (typeof ELEMENT_ENVIRONMENT)[keyof typeof ELEMENT_ENVIRONMENT];
|
65
|
-
export interface IElementOptions {
|
66
|
-
environment?: ELEMENT_ENVIRONMENT_TYPE;
|
67
|
-
locale?: string;
|
68
|
-
version?: string;
|
69
|
-
appearance?: {
|
70
|
-
theme: ThemeType.Default | ThemeType.Night;
|
71
|
-
};
|
72
|
-
onEventCallback?: ({ code, message, result }: {
|
73
|
-
code: EventCallbackCode;
|
74
|
-
message: string;
|
75
|
-
result?: any;
|
76
|
-
}) => void;
|
77
|
-
loading?: {
|
78
|
-
onStartLoading: () => void;
|
79
|
-
onEndLoading: () => void;
|
80
|
-
};
|
81
|
-
}
|
82
68
|
export interface AddressMountComponentsParams {
|
83
69
|
configParams?: AddressMountConfig;
|
84
70
|
prefillValue: Array<AddressSubmitData>;
|
@@ -95,7 +81,6 @@ export interface AddressMountComponentsParams {
|
|
95
81
|
}
|
96
82
|
interface BaseMountOptions<T = void> {
|
97
83
|
configParams?: T;
|
98
|
-
sessionData: string;
|
99
84
|
debugProps?: {
|
100
85
|
localLink: string;
|
101
86
|
};
|
@@ -1,16 +1,17 @@
|
|
1
1
|
import { IElementStatus } from '../../../foundation';
|
2
2
|
import { Ianalytics, IPaymentSessionMetaData } from '../../../types';
|
3
3
|
import { ContainerController } from './elementContainerService/containerService';
|
4
|
-
import { ELEMENT_ENVIRONMENT_TYPE, IElementOptions, IToastOptions } from './type';
|
5
|
-
declare const formatElementOption: (options: IElementOptions) => {
|
4
|
+
import { ELEMENT_ENVIRONMENT_TYPE, IElementOptions, IToastOptions, EventCallbackCode } from './type';
|
5
|
+
export declare const formatElementOption: (options: IElementOptions) => {
|
6
6
|
environment: ELEMENT_ENVIRONMENT_TYPE;
|
7
|
+
sessionData: string;
|
7
8
|
locale?: string;
|
8
9
|
version?: string;
|
9
10
|
appearance?: {
|
10
11
|
theme: import("./type").ThemeType.Default | import("./type").ThemeType.Night;
|
11
12
|
};
|
12
13
|
onEventCallback?: ({ code, message, result }: {
|
13
|
-
code:
|
14
|
+
code: EventCallbackCode;
|
14
15
|
message: string;
|
15
16
|
result?: any;
|
16
17
|
}) => void;
|
@@ -18,8 +19,8 @@ declare const formatElementOption: (options: IElementOptions) => {
|
|
18
19
|
onStartLoading: () => void;
|
19
20
|
onEndLoading: () => void;
|
20
21
|
};
|
21
|
-
sessionData: string;
|
22
22
|
};
|
23
|
+
export declare const validateElementOption: (options: IElementOptions) => boolean;
|
23
24
|
/**
|
24
25
|
* 校验渲染条件
|
25
26
|
* 校验当前sdkSelector结点是否存在
|
@@ -49,7 +50,10 @@ export declare function generateIframeSrc({ paymentSessionObj, paymentSession, i
|
|
49
50
|
appVersion: string;
|
50
51
|
link?: string;
|
51
52
|
}): string;
|
52
|
-
export declare function handleRedirect(data: any, fromFastSdk
|
53
|
+
export declare function handleRedirect(data: any, fromFastSdk: boolean, eventCallback: ({ code, message }: {
|
54
|
+
code: any;
|
55
|
+
message: any;
|
56
|
+
}) => void): void;
|
53
57
|
export declare function redirect(data: {
|
54
58
|
normalUrl?: string;
|
55
59
|
schemeUrl?: string;
|
@@ -63,4 +67,3 @@ export declare const isElementMobile: () => boolean;
|
|
63
67
|
*/
|
64
68
|
export declare const isElementPad: () => boolean;
|
65
69
|
export declare const isElementPC: () => boolean;
|
66
|
-
export { formatElementOption };
|
@@ -13,17 +13,28 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
13
13
|
import { ERRORMESSAGE } from "../../../constant";
|
14
14
|
import { IElementStatus } from "../../../foundation";
|
15
15
|
import { getIframeUrl } from "../../../plugin/component/cashierApp";
|
16
|
-
import { DisplayTypeEnum, RedirectType, TargetEnum, terminalTypeEnum } from "../../../types";
|
16
|
+
import { DisplayTypeEnum, eventCodeEnum, RedirectType, TargetEnum, terminalTypeEnum } from "../../../types";
|
17
17
|
import { device } from "../../../util/index";
|
18
18
|
import CallApp from "../../../util/intl-callapp/es/main";
|
19
19
|
import { getComponentSign, parseSessionData } from "../index";
|
20
|
-
import { ELEMENT_ENVIRONMENT } from "./type";
|
21
|
-
var formatElementOption = function formatElementOption(options) {
|
20
|
+
import { ELEMENT_ENVIRONMENT, EventCallbackCode } from "./type";
|
21
|
+
export var formatElementOption = function formatElementOption(options) {
|
22
22
|
var environment = options.environment;
|
23
23
|
return _objectSpread(_objectSpread({}, options), {}, {
|
24
24
|
environment: (environment || ELEMENT_ENVIRONMENT.PROD).toLocaleLowerCase()
|
25
25
|
});
|
26
26
|
};
|
27
|
+
export var validateElementOption = function validateElementOption(options) {
|
28
|
+
if (!options.sessionData) {
|
29
|
+
var _options$onEventCallb;
|
30
|
+
options === null || options === void 0 || (_options$onEventCallb = options.onEventCallback) === null || _options$onEventCallb === void 0 || _options$onEventCallb.call(options, {
|
31
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
32
|
+
message: 'sessionData is empty'
|
33
|
+
});
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
return true;
|
37
|
+
};
|
27
38
|
|
28
39
|
/**
|
29
40
|
* 校验渲染条件
|
@@ -138,6 +149,7 @@ export function generateIframeSrc(_ref3) {
|
|
138
149
|
export function handleRedirect(data) {
|
139
150
|
var _data$isDestroy, _data$isCallApp, _data$callAppDetectSu;
|
140
151
|
var fromFastSdk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
152
|
+
var eventCallback = arguments.length > 2 ? arguments[2] : undefined;
|
141
153
|
console.log('local payment sdk new element redirect arg ----', this);
|
142
154
|
var _data = typeof data === 'string' ? {
|
143
155
|
normalUrl: data
|
@@ -171,10 +183,10 @@ export function handleRedirect(data) {
|
|
171
183
|
// .send();
|
172
184
|
var successCallback = function successCallback(type, url, durationInSeconds) {
|
173
185
|
// TODO
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
186
|
+
eventCallback({
|
187
|
+
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
188
|
+
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
189
|
+
});
|
178
190
|
var extra = {
|
179
191
|
redirectInfo: JSON.stringify(_data),
|
180
192
|
openType: type,
|
@@ -194,10 +206,10 @@ export function handleRedirect(data) {
|
|
194
206
|
// .send();
|
195
207
|
};
|
196
208
|
var failCallback = function failCallback(type, url, durationInSeconds) {
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
209
|
+
eventCallback({
|
210
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
211
|
+
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
212
|
+
});
|
201
213
|
var extra = {
|
202
214
|
redirectInfo: JSON.stringify(_data),
|
203
215
|
openType: type,
|
@@ -253,21 +265,9 @@ export function handleRedirect(data) {
|
|
253
265
|
return;
|
254
266
|
}
|
255
267
|
redirect({
|
256
|
-
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
|
257
|
-
|
258
|
-
|
259
|
-
}).catch(function () {
|
260
|
-
if (_data !== null && _data !== void 0 && _data.applinkUrl) failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
261
|
-
return redirect({
|
262
|
-
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
263
|
-
});
|
264
|
-
}).then(function () {
|
265
|
-
successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
266
|
-
}).catch(function () {
|
267
|
-
if (_data !== null && _data !== void 0 && _data.schemeUrl) failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
268
|
-
return redirect({
|
269
|
-
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
270
|
-
});
|
268
|
+
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl,
|
269
|
+
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl,
|
270
|
+
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
271
271
|
}).then(function () {
|
272
272
|
successCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
|
273
273
|
}).catch(function () {
|
@@ -288,7 +288,7 @@ export function redirect(data) {
|
|
288
288
|
window.location.href = normalUrl;
|
289
289
|
return;
|
290
290
|
}
|
291
|
-
reject(ERRORMESSAGE.
|
291
|
+
reject(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
292
292
|
};
|
293
293
|
var callAppFunc = function callAppFunc() {
|
294
294
|
if (!schemeUrl && !applinkUrl) {
|
@@ -474,5 +474,4 @@ export var isElementPad = function isElementPad() {
|
|
474
474
|
};
|
475
475
|
export var isElementPC = function isElementPC() {
|
476
476
|
return !isElementMobile();
|
477
|
-
};
|
478
|
-
export { formatElementOption };
|
477
|
+
};
|
@@ -10,6 +10,9 @@ export declare enum ElementPaymentEvent {
|
|
10
10
|
SIZE_CHANGE = "onSizeChange",
|
11
11
|
LAUNCH = "onLaunch",
|
12
12
|
CALLBACK = "callback",
|
13
|
+
/**
|
14
|
+
* @deprecated 已废弃 请使用eventCallback
|
15
|
+
*/
|
13
16
|
SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
|
14
17
|
LOG = "log",
|
15
18
|
HANDLE_PAYMENT = "handlePayment"
|
@@ -435,7 +435,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
435
435
|
window.location.href = normalUrl;
|
436
436
|
return;
|
437
437
|
}
|
438
|
-
reject(ERRORMESSAGE.
|
438
|
+
reject(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
439
439
|
};
|
440
440
|
var callAppFunc = function callAppFunc() {
|
441
441
|
if (!schemeUrl && !applinkUrl) {
|
@@ -12,6 +12,8 @@ export declare class ContainerService implements Service {
|
|
12
12
|
private displayInfo;
|
13
13
|
private webApp;
|
14
14
|
private _webAppHeartBeatTimeoutFn;
|
15
|
+
private clientHeight;
|
16
|
+
private boundFocusResizeChange;
|
15
17
|
private customizedLoadingListener;
|
16
18
|
destroy(): void;
|
17
19
|
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
@@ -22,10 +24,13 @@ export declare class ContainerService implements Service {
|
|
22
24
|
dismissLoading(isKeepMockup?: boolean): void;
|
23
25
|
customizeLoading(listener: (event: 'SDK_START_OF_LOADING' | 'SDK_END_OF_LOADING') => void): void;
|
24
26
|
startHideAnim(): void;
|
27
|
+
private handleAccountFocus;
|
25
28
|
private addCapabilityToEventCenter;
|
26
29
|
private addCapabilityToApiBusManager;
|
27
30
|
private updateMaskCloseBtn;
|
28
31
|
private handleSizeChanged;
|
32
|
+
private focusResizeChange;
|
33
|
+
private focusScrollFixed;
|
29
34
|
private handleAppHeartBeat;
|
30
35
|
private changeCloseBtnVisibility;
|
31
36
|
private handleMaskCloseBtnShow;
|
@@ -35,6 +35,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
35
35
|
_defineProperty(this, "displayInfo", void 0);
|
36
36
|
_defineProperty(this, "webApp", void 0);
|
37
37
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
38
|
+
_defineProperty(this, "clientHeight", void 0);
|
39
|
+
_defineProperty(this, "boundFocusResizeChange", void 0);
|
38
40
|
// if this variable is true, SDK will invoke listener instead of showing loading
|
39
41
|
_defineProperty(this, "customizedLoadingListener", void 0);
|
40
42
|
}
|
@@ -46,6 +48,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
46
48
|
value: function init(initOptions, instanceId, sdkMetaData) {
|
47
49
|
this.instanceId = instanceId;
|
48
50
|
this.sdkMetaData = sdkMetaData;
|
51
|
+
this.clientHeight = Math.max(window.innerHeight, window.visualViewport.height);
|
49
52
|
this.eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
|
50
53
|
this.logService = ServiceProvider.getInstance(instanceId).getService('Log');
|
51
54
|
this.popupManager = new PopupManager();
|
@@ -55,6 +58,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
55
58
|
this.addCapabilityToEventCenter();
|
56
59
|
}
|
57
60
|
this.addCapabilityToApiBusManager();
|
61
|
+
// bind会返回一个新的方法,init时记录上这个focus,不然window.addEventListener时this指向会变成window
|
62
|
+
this.boundFocusResizeChange = this.focusResizeChange.bind(this);
|
58
63
|
}
|
59
64
|
}, {
|
60
65
|
key: "update",
|
@@ -156,6 +161,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
156
161
|
container === null || container === void 0 || container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.displayInfo.platform));
|
157
162
|
}
|
158
163
|
}
|
164
|
+
}, {
|
165
|
+
key: "handleAccountFocus",
|
166
|
+
value: function handleAccountFocus(focus) {
|
167
|
+
var _window$visualViewpor, _window;
|
168
|
+
// 失焦时v2会走默认的sizeChange还原高度,这里仅移除监听
|
169
|
+
(_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.removeEventListener('resize', this.boundFocusResizeChange);
|
170
|
+
(_window = window) === null || _window === void 0 || _window.removeEventListener('resize', this.boundFocusResizeChange);
|
171
|
+
// 只有聚焦才监听,失焦后移除,避免影响别的场景
|
172
|
+
if (focus) {
|
173
|
+
var _window$visualViewpor2;
|
174
|
+
// 监听页面visualViewport的高度变化,适用于主流机型更精准获取当前页面高度
|
175
|
+
(_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 || _window$visualViewpor2.addEventListener('resize', this.boundFocusResizeChange);
|
176
|
+
// 兼容visualViewport处理不到的场景,一般存在于老版本浏览器
|
177
|
+
window.addEventListener('resize', this.boundFocusResizeChange);
|
178
|
+
}
|
179
|
+
}
|
159
180
|
}, {
|
160
181
|
key: "addCapabilityToEventCenter",
|
161
182
|
value: function addCapabilityToEventCenter() {
|
@@ -195,7 +216,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
195
216
|
_this.handleSizeChanged(_objectSpread({}, data));
|
196
217
|
});
|
197
218
|
this.eventCenter.listen(EVENT.showCloseButton.name, function (data) {
|
198
|
-
_this.handleCloseButtonTheme(data.
|
219
|
+
_this.handleCloseButtonTheme(data.style);
|
199
220
|
_this.changeCloseBtnVisibility(true);
|
200
221
|
});
|
201
222
|
this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
|
@@ -207,6 +228,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
207
228
|
this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
|
208
229
|
_this.handleAppHeartBeat();
|
209
230
|
});
|
231
|
+
/**
|
232
|
+
* 目前仅用于ESP V2的 web sdk
|
233
|
+
* 原因: 在账户输入页和OTP页面的h5场景下键盘弹起页面会有问题,iframe有固定高度,键盘弹起时应用层不会触发大小变化
|
234
|
+
* account账号输入页需要在sdk监听键盘弹起后高度变化并修改iframe及iframe外层容器,account需要按钮置底的放在键盘上面,必须修改高度而不是让容器定位
|
235
|
+
* otp页面需要在聚焦时给iframe及外层容器设置fixed定位,让页面不被弹起
|
236
|
+
* 目的: esp页面输入框聚焦/失焦后给sdk发送消息
|
237
|
+
*/
|
238
|
+
this.eventCenter.listen(EVENT.inputFocus.name, function (data) {
|
239
|
+
// 账号输入页需要修改iframe高度
|
240
|
+
if (data.source === 'ESP_V2' && data.type === 'account') {
|
241
|
+
_this.handleAccountFocus(data.focus);
|
242
|
+
// otp页面需要定位元素
|
243
|
+
} else if (data.source === 'ESP_V2' && data.type === 'otp') {
|
244
|
+
_this.focusScrollFixed(data.focus);
|
245
|
+
}
|
246
|
+
});
|
210
247
|
}
|
211
248
|
}, {
|
212
249
|
key: "addCapabilityToApiBusManager",
|
@@ -267,6 +304,50 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
267
304
|
this.webApp.style.height = "".concat(data.height, "px");
|
268
305
|
}
|
269
306
|
}
|
307
|
+
|
308
|
+
// 目前仅用于esp账号输入页聚焦
|
309
|
+
}, {
|
310
|
+
key: "focusResizeChange",
|
311
|
+
value: function focusResizeChange() {
|
312
|
+
var _window2;
|
313
|
+
// 计算出当前iframe应有的高度,需要和顶部留有距离
|
314
|
+
var webPageHeightRatio = 0.9;
|
315
|
+
var browserPageHeightFocusRatio = 0.9;
|
316
|
+
// sdk层才能拿到当前键盘弹起后页面的高度
|
317
|
+
var height = ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.visualViewport) === null || _window2 === void 0 ? void 0 : _window2.height) || window.innerHeight;
|
318
|
+
height = height * webPageHeightRatio;
|
319
|
+
height = height * browserPageHeightFocusRatio;
|
320
|
+
// 调用handleSizeChanged修改iframe高度
|
321
|
+
this.handleSizeChanged({
|
322
|
+
width: 0,
|
323
|
+
height: height
|
324
|
+
});
|
325
|
+
}
|
326
|
+
|
327
|
+
// 目前仅用于esp otp页面账号聚焦
|
328
|
+
}, {
|
329
|
+
key: "focusScrollFixed",
|
330
|
+
value: function focusScrollFixed(focus) {
|
331
|
+
// 获取iframe dom元素
|
332
|
+
var _this$displayInfo4 = this.displayInfo,
|
333
|
+
appendAliasContainerId = _this$displayInfo4.appendAliasContainerId,
|
334
|
+
selector = _this$displayInfo4.selector;
|
335
|
+
var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
|
336
|
+
if (!this.webApp || !this.displayInfo) {
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
var cashier = document.getElementById(cashierId);
|
340
|
+
if (!cashier) return;
|
341
|
+
// 输入框聚焦时修改定位信息和top距离
|
342
|
+
if (focus) {
|
343
|
+
cashier.style.setProperty('position', 'fixed', 'important');
|
344
|
+
cashier.style.setProperty('top', "".concat(this.clientHeight - cashier.clientHeight, "px"), 'important');
|
345
|
+
} else {
|
346
|
+
// 失焦时移除定位信息
|
347
|
+
cashier.style.removeProperty('position');
|
348
|
+
cashier.style.removeProperty('top');
|
349
|
+
}
|
350
|
+
}
|
270
351
|
}, {
|
271
352
|
key: "handleAppHeartBeat",
|
272
353
|
value: function handleAppHeartBeat() {
|
@@ -326,12 +407,12 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
326
407
|
}
|
327
408
|
}, {
|
328
409
|
key: "handleCloseButtonTheme",
|
329
|
-
value: function handleCloseButtonTheme(
|
330
|
-
if (!
|
410
|
+
value: function handleCloseButtonTheme(style) {
|
411
|
+
if (!style) return;
|
331
412
|
var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
|
332
413
|
var closeButtonImg = closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.querySelector('img');
|
333
414
|
var maskCloseBlock = document.getElementById(COMPONENT_CLOSE_MASK_BLOCK_ID);
|
334
|
-
if (
|
415
|
+
if (style === 'light') {
|
335
416
|
closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImgLight);
|
336
417
|
closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
|
337
418
|
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|