@alipay/ams-checkout 0.0.1748327361-dev.0 → 0.0.1748918972-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.d.ts +3 -1
- package/esm/component/channel.js +26 -62
- package/esm/component/popupWindow.style.d.ts +4 -1
- package/esm/component/popupWindow.style.js +33 -1
- package/esm/config/index.d.ts +8 -8
- package/esm/config/index.js +8 -8
- package/esm/constant/easysafepay.d.ts +16 -0
- package/esm/constant/easysafepay.js +19 -0
- package/esm/constant/index.d.ts +29 -2
- package/esm/constant/index.js +31 -5
- package/esm/core/component/ckp/index.d.ts +2 -0
- package/esm/core/component/ckp/index.js +39 -5
- package/esm/core/component/element/elementController/index.d.ts +1 -1
- package/esm/core/component/element/elementController/index.js +29 -20
- 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 +32 -33
- package/esm/core/component/element/type.js +20 -12
- package/esm/core/component/element/util.d.ts +9 -6
- package/esm/core/component/element/util.js +29 -30
- package/esm/core/component/oldElement/type.d.ts +3 -0
- package/esm/core/instance/index.js +1 -1
- package/esm/foundation/core/index.d.ts +3 -0
- package/esm/foundation/core/index.js +103 -37
- package/esm/foundation/index.d.ts +6 -0
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +1 -1
- package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -0
- package/esm/foundation/product-processor/easysafepay/index.js +244 -121
- package/esm/foundation/service/container/index.d.ts +8 -0
- package/esm/foundation/service/container/index.js +140 -18
- package/esm/foundation/service/container/popup.d.ts +9 -6
- package/esm/foundation/service/container/popup.js +3 -1
- package/esm/foundation/utils/preload_helper.d.ts +2 -2
- package/esm/foundation/utils/preload_helper.js +8 -4
- package/esm/foundation/utils/redirect_utils.js +34 -18
- package/esm/foundation/utils/web_app_url_utils.d.ts +71 -1
- package/esm/foundation/utils/web_app_url_utils.js +215 -8
- package/esm/index.js +1 -1
- package/esm/plugin/component/cashierApp.js +4 -4
- package/esm/plugin/component/channel.d.ts +3 -1
- package/esm/plugin/component/channel.js +10 -12
- package/esm/plugin/component/index.js +46 -43
- package/esm/types/index.d.ts +28 -1
- package/esm/types/index.js +8 -1
- package/esm/util/redirect.d.ts +6 -0
- package/esm/util/redirect.js +54 -0
- package/package.json +27 -4
@@ -11,7 +11,7 @@ import { isEmpty } from "../../../util";
|
|
11
11
|
import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
|
12
12
|
import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
|
13
13
|
import { insertStyleSheet } from "../../../component/popupWindow.style";
|
14
|
-
import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, EVENT, LOADING_ID, MOCKUP_ID, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../../constant";
|
14
|
+
import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, EVENT, LOADING_ID, MOCKUP_ID, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT, closeImg, closeImgLight } from "../../../constant";
|
15
15
|
import { DisplayTypeEnum, ProductSceneEnum } from "../../../types";
|
16
16
|
import { ServiceProvider } from "../index";
|
17
17
|
import { PopupManager } from "./popup";
|
@@ -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() {
|
@@ -174,19 +195,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
174
195
|
});
|
175
196
|
});
|
176
197
|
this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
|
177
|
-
|
178
|
-
if (data.paymentElementOldModel) return;
|
179
|
-
insertStyleSheet();
|
180
|
-
_this.popupManager.popup(_objectSpread({
|
181
|
-
platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
|
182
|
-
}, data)).then(function () {
|
183
|
-
_this.eventCenter.addIFrame(_this.popupManager.popupApp);
|
184
|
-
}).catch(function (error) {
|
185
|
-
_this.logService.logError({
|
186
|
-
title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
|
187
|
-
}, error);
|
188
|
-
_this.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
189
|
-
});
|
198
|
+
_this.handlePopupWindow(data);
|
190
199
|
});
|
191
200
|
this.eventCenter.listen(EVENT.popWindow.name, function () {
|
192
201
|
_this.popupManager.pop();
|
@@ -194,7 +203,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
194
203
|
this.eventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
195
204
|
_this.handleSizeChanged(_objectSpread({}, data));
|
196
205
|
});
|
197
|
-
this.eventCenter.listen(EVENT.showCloseButton.name, function () {
|
206
|
+
this.eventCenter.listen(EVENT.showCloseButton.name, function (data) {
|
207
|
+
_this.handleCloseButtonTheme(data.style);
|
198
208
|
_this.changeCloseBtnVisibility(true);
|
199
209
|
});
|
200
210
|
this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
|
@@ -206,6 +216,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
206
216
|
this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
|
207
217
|
_this.handleAppHeartBeat();
|
208
218
|
});
|
219
|
+
/**
|
220
|
+
* 目前仅用于ESP V2的 web sdk
|
221
|
+
* 原因: 在账户输入页和OTP页面的h5场景下键盘弹起页面会有问题,iframe有固定高度,键盘弹起时应用层不会触发大小变化
|
222
|
+
* account账号输入页需要在sdk监听键盘弹起后高度变化并修改iframe及iframe外层容器,account需要按钮置底的放在键盘上面,必须修改高度而不是让容器定位
|
223
|
+
* otp页面需要在聚焦时给iframe及外层容器设置fixed定位,让页面不被弹起
|
224
|
+
* 目的: esp页面输入框聚焦/失焦后给sdk发送消息
|
225
|
+
*/
|
226
|
+
this.eventCenter.listen(EVENT.inputFocus.name, function (data) {
|
227
|
+
// 账号输入页需要修改iframe高度
|
228
|
+
if (data.source === 'ESP_V2' && data.type === 'account') {
|
229
|
+
_this.handleAccountFocus(data.focus);
|
230
|
+
// otp页面需要定位元素
|
231
|
+
} else if (data.source === 'ESP_V2' && data.type === 'otp') {
|
232
|
+
_this.focusScrollFixed(data.focus);
|
233
|
+
}
|
234
|
+
});
|
209
235
|
}
|
210
236
|
}, {
|
211
237
|
key: "addCapabilityToApiBusManager",
|
@@ -228,9 +254,9 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
228
254
|
}, {
|
229
255
|
key: "handleSizeChanged",
|
230
256
|
value: function handleSizeChanged(data) {
|
231
|
-
var _this$
|
232
|
-
appendAliasContainerId = _this$
|
233
|
-
selector = _this$
|
257
|
+
var _this$displayInfo2 = this.displayInfo,
|
258
|
+
appendAliasContainerId = _this$displayInfo2.appendAliasContainerId,
|
259
|
+
selector = _this$displayInfo2.selector;
|
234
260
|
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;
|
235
261
|
if (!this.webApp || !this.displayInfo) {
|
236
262
|
return;
|
@@ -266,6 +292,50 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
266
292
|
this.webApp.style.height = "".concat(data.height, "px");
|
267
293
|
}
|
268
294
|
}
|
295
|
+
|
296
|
+
// 目前仅用于esp账号输入页聚焦
|
297
|
+
}, {
|
298
|
+
key: "focusResizeChange",
|
299
|
+
value: function focusResizeChange() {
|
300
|
+
var _window2;
|
301
|
+
// 计算出当前iframe应有的高度,需要和顶部留有距离
|
302
|
+
var webPageHeightRatio = 0.9;
|
303
|
+
var browserPageHeightFocusRatio = 0.9;
|
304
|
+
// sdk层才能拿到当前键盘弹起后页面的高度
|
305
|
+
var height = ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.visualViewport) === null || _window2 === void 0 ? void 0 : _window2.height) || window.innerHeight;
|
306
|
+
height = height * webPageHeightRatio;
|
307
|
+
height = height * browserPageHeightFocusRatio;
|
308
|
+
// 调用handleSizeChanged修改iframe高度
|
309
|
+
this.handleSizeChanged({
|
310
|
+
width: 0,
|
311
|
+
height: height
|
312
|
+
});
|
313
|
+
}
|
314
|
+
|
315
|
+
// 目前仅用于esp otp页面账号聚焦
|
316
|
+
}, {
|
317
|
+
key: "focusScrollFixed",
|
318
|
+
value: function focusScrollFixed(focus) {
|
319
|
+
// 获取iframe dom元素
|
320
|
+
var _this$displayInfo3 = this.displayInfo,
|
321
|
+
appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
|
322
|
+
selector = _this$displayInfo3.selector;
|
323
|
+
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;
|
324
|
+
if (!this.webApp || !this.displayInfo) {
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
var cashier = document.getElementById(cashierId);
|
328
|
+
if (!cashier) return;
|
329
|
+
// 输入框聚焦时修改定位信息和top距离
|
330
|
+
if (focus) {
|
331
|
+
cashier.style.setProperty('position', 'fixed', 'important');
|
332
|
+
cashier.style.setProperty('top', "".concat(this.clientHeight - cashier.clientHeight, "px"), 'important');
|
333
|
+
} else {
|
334
|
+
// 失焦时移除定位信息
|
335
|
+
cashier.style.removeProperty('position');
|
336
|
+
cashier.style.removeProperty('top');
|
337
|
+
}
|
338
|
+
}
|
269
339
|
}, {
|
270
340
|
key: "handleAppHeartBeat",
|
271
341
|
value: function handleAppHeartBeat() {
|
@@ -323,6 +393,58 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
323
393
|
closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-hidden"));
|
324
394
|
}
|
325
395
|
}
|
396
|
+
}, {
|
397
|
+
key: "handleCloseButtonTheme",
|
398
|
+
value: function handleCloseButtonTheme(style) {
|
399
|
+
if (!style) return;
|
400
|
+
var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
|
401
|
+
var closeButtonImg = closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.querySelector('img');
|
402
|
+
var maskCloseBlock = document.getElementById(COMPONENT_CLOSE_MASK_BLOCK_ID);
|
403
|
+
if (style === 'light') {
|
404
|
+
closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImgLight);
|
405
|
+
closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
|
406
|
+
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|
407
|
+
} else {
|
408
|
+
closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImg);
|
409
|
+
closeBlock === null || closeBlock === void 0 || closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
|
410
|
+
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.remove("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|
411
|
+
}
|
412
|
+
}
|
413
|
+
|
414
|
+
// SDK主动打开弹框
|
415
|
+
}, {
|
416
|
+
key: "handlePopupWindow",
|
417
|
+
value: function handlePopupWindow(data) {
|
418
|
+
var _this$displayInfo4,
|
419
|
+
_this3 = this;
|
420
|
+
if (data.paymentElementOldModel) return;
|
421
|
+
insertStyleSheet();
|
422
|
+
this.popupManager.popup(_objectSpread({
|
423
|
+
platform: (_this$displayInfo4 = this.displayInfo) === null || _this$displayInfo4 === void 0 ? void 0 : _this$displayInfo4.platform,
|
424
|
+
showCloseOnLoading: data.showCloseOnLoading,
|
425
|
+
onCloseOnLoading: function onCloseOnLoading() {
|
426
|
+
return _this3.handlePopWindow(data);
|
427
|
+
}
|
428
|
+
}, data)).then(function () {
|
429
|
+
_this3.eventCenter.addIFrame(_this3.popupManager.popupApp);
|
430
|
+
}).catch(function (error) {
|
431
|
+
_this3.logService.logError({
|
432
|
+
title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
|
433
|
+
}, error);
|
434
|
+
_this3.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
435
|
+
});
|
436
|
+
}
|
437
|
+
|
438
|
+
// SDK主动关闭弹框
|
439
|
+
}, {
|
440
|
+
key: "handlePopWindow",
|
441
|
+
value: function handlePopWindow(data) {
|
442
|
+
this.popupManager.pop();
|
443
|
+
this.eventCenter.dispatchToApp({
|
444
|
+
event: EVENT.popWindow.name,
|
445
|
+
data: data
|
446
|
+
});
|
447
|
+
}
|
326
448
|
}, {
|
327
449
|
key: "getWebApp",
|
328
450
|
value: function getWebApp() {
|
@@ -1,4 +1,12 @@
|
|
1
1
|
import { PlatformEnum } from '../../../types';
|
2
|
+
export type IPopUpParams = {
|
3
|
+
url: string;
|
4
|
+
widthPadding: number;
|
5
|
+
heightPadding: number;
|
6
|
+
platform: PlatformEnum;
|
7
|
+
showCloseOnLoading: boolean;
|
8
|
+
onCloseOnLoading: () => void;
|
9
|
+
};
|
2
10
|
/**
|
3
11
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
4
12
|
* @date 2024/9/22
|
@@ -7,11 +15,6 @@ export declare class PopupManager {
|
|
7
15
|
private popupUrlQuery;
|
8
16
|
popupApp: HTMLIFrameElement;
|
9
17
|
setPopupUrlQuery(queryParams: string): void;
|
10
|
-
popup(data:
|
11
|
-
url: string;
|
12
|
-
widthPadding: number;
|
13
|
-
heightPadding: number;
|
14
|
-
platform: PlatformEnum;
|
15
|
-
}): Promise<void>;
|
18
|
+
popup(data: IPopUpParams): Promise<void>;
|
16
19
|
pop(): void;
|
17
20
|
}
|
@@ -53,7 +53,9 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
53
53
|
widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
|
54
54
|
device: data === null || data === void 0 ? void 0 : data.platform,
|
55
55
|
url: pageUrl,
|
56
|
-
loadingConfig: undefined
|
56
|
+
loadingConfig: undefined,
|
57
|
+
showCloseOnLoading: data.showCloseOnLoading,
|
58
|
+
onCloseOnLoading: data.onCloseOnLoading
|
57
59
|
});
|
58
60
|
case 11:
|
59
61
|
this.popupApp = _context.sent;
|
@@ -4,10 +4,10 @@ export default class PreloadHelper {
|
|
4
4
|
static isWebAppPreloaded: boolean;
|
5
5
|
static isSecuritySDKPreloaded: boolean;
|
6
6
|
private static securitySdkMap;
|
7
|
-
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
|
7
|
+
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): void;
|
8
8
|
static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
|
9
9
|
static getSecuritySdk(scene: any): Security;
|
10
|
-
static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
|
10
|
+
static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string, useV2?: boolean): {
|
11
11
|
preloadUrl: string;
|
12
12
|
containerId: string;
|
13
13
|
};
|
@@ -8,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
8
8
|
import { sdkVersion } from "../../config";
|
9
9
|
import { createPreloadIframe } from "../service/container/utils";
|
10
10
|
import { ProductSceneEnum } from "../../types";
|
11
|
-
import { getWebAppUrl } from "../utils/web_app_url_utils";
|
11
|
+
import { getWebAppUrl, getWebAppV2Url } from "../utils/web_app_url_utils";
|
12
12
|
import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
|
13
13
|
import { getWebAppVersion } from "./payment_context_utils";
|
14
14
|
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
|
@@ -22,12 +22,13 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
22
22
|
key: "preloadWebApp",
|
23
23
|
value: function preloadWebApp(productScene, paymentMethodCategoryType) {
|
24
24
|
var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
|
25
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
25
26
|
try {
|
26
27
|
if (this.isWebAppPreloaded) {
|
27
28
|
console.log('[web-sdk] web app already preloaded');
|
28
29
|
return;
|
29
30
|
}
|
30
|
-
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
|
31
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment, useV2),
|
31
32
|
preloadUrl = _this$buildWebAppPrel.preloadUrl,
|
32
33
|
containerId = _this$buildWebAppPrel.containerId;
|
33
34
|
var preloadIframe = createPreloadIframe(containerId);
|
@@ -89,6 +90,7 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
89
90
|
}, {
|
90
91
|
key: "buildWebAppPreloadUrl",
|
91
92
|
value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
|
93
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
92
94
|
var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
|
93
95
|
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
|
94
96
|
if (previousProductInfo) {
|
@@ -101,14 +103,16 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
101
103
|
webAppVersion: ''
|
102
104
|
};
|
103
105
|
sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
|
104
|
-
var
|
106
|
+
var preloadUrlParams = {
|
105
107
|
environment: environment,
|
106
108
|
sdkMetaData: sdkMetaData,
|
107
109
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
108
110
|
isPreload: true,
|
111
|
+
productScene: productScene,
|
109
112
|
productSceneVersion: productSceneVersion,
|
110
113
|
query: undefined
|
111
|
-
}
|
114
|
+
};
|
115
|
+
var preloadUrl = useV2 ? getWebAppV2Url(preloadUrlParams) : getWebAppUrl(preloadUrlParams);
|
112
116
|
return {
|
113
117
|
preloadUrl: preloadUrl,
|
114
118
|
containerId: containerId
|
@@ -69,26 +69,42 @@ export var redirect = function redirect(payload, instanceId) {
|
|
69
69
|
successCallback(payload, type, evokeAppBy.url, serviceProvider);
|
70
70
|
}
|
71
71
|
});
|
72
|
+
var callApplinkUrl = function callApplinkUrl() {
|
73
|
+
try {
|
74
|
+
callAppLib.open({
|
75
|
+
link: payload.applinkUrl,
|
76
|
+
fallback: function fallback() {
|
77
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
78
|
+
// Applink evoke failed, try to use scheme url
|
79
|
+
callSchemeUrl();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
} catch (error) {
|
83
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
84
|
+
// Applink evoke failed, try to use scheme url
|
85
|
+
callSchemeUrl();
|
86
|
+
}
|
87
|
+
};
|
72
88
|
var callSchemeUrl = function callSchemeUrl() {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
try {
|
90
|
+
callAppLib.open({
|
91
|
+
scheme: payload.schemeUrl,
|
92
|
+
fallback: function fallback() {
|
93
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
94
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
95
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
96
|
+
window.location.href = payload.url;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
} catch (error) {
|
100
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
101
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
102
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
103
|
+
window.location.href = payload.url;
|
104
|
+
}
|
82
105
|
};
|
83
106
|
if (payload.applinkUrl) {
|
84
|
-
|
85
|
-
link: payload.applinkUrl,
|
86
|
-
fallback: function fallback() {
|
87
|
-
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
88
|
-
// Applink evoke failed, try to use scheme url
|
89
|
-
callSchemeUrl();
|
90
|
-
}
|
91
|
-
});
|
107
|
+
callApplinkUrl();
|
92
108
|
} else if (payload.schemeUrl) {
|
93
109
|
callSchemeUrl();
|
94
110
|
}
|
@@ -116,7 +132,7 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
|
|
116
132
|
};
|
117
133
|
var failCallback = function failCallback(payload, type, url, serviceProvider) {
|
118
134
|
serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
|
119
|
-
code: eventCodeEnum.
|
135
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
120
136
|
message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
|
121
137
|
});
|
122
138
|
serviceProvider.getService('Log').logInfo({
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from '../../types';
|
1
|
+
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum, IPaymentSessionMetaData } from '../../types';
|
2
2
|
import { SDKMetaData } from '../index';
|
3
|
+
import { ESP_PAGE_NAME } from "../../constant/easysafepay";
|
3
4
|
/**
|
4
5
|
* Tell the SDK which version of the Web App to load.
|
5
6
|
* Sent by server inside paymentSession.
|
@@ -16,6 +17,16 @@ export interface WebAppMatchConfig {
|
|
16
17
|
mid?: string;
|
17
18
|
greyscale?: string;
|
18
19
|
}
|
20
|
+
/**
|
21
|
+
* Tell the SDK which Web App URL to load.
|
22
|
+
* Sent by server inside paymentSession.
|
23
|
+
*/
|
24
|
+
export interface WebAppUrlMatchConfig {
|
25
|
+
minSDKVersion: string;
|
26
|
+
url: string;
|
27
|
+
doubleFa: string;
|
28
|
+
mids?: string[];
|
29
|
+
}
|
19
30
|
export interface QueryParams {
|
20
31
|
displayType: DisplayTypeEnum;
|
21
32
|
locale: string;
|
@@ -27,20 +38,79 @@ export interface QueryParams {
|
|
27
38
|
export declare const getWebAppUrlInfo: (params: {
|
28
39
|
environment: string;
|
29
40
|
sdkMetaData: SDKMetaData;
|
41
|
+
productScene: ProductSceneEnum;
|
30
42
|
productSceneVersion: string;
|
31
43
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
32
44
|
isPreload?: boolean;
|
33
45
|
query: QueryParams;
|
46
|
+
v2Url?: string;
|
34
47
|
}) => {
|
35
48
|
path: string;
|
36
49
|
locationSearch: string;
|
37
50
|
};
|
51
|
+
export declare const getWebAppV2Url: (params: {
|
52
|
+
environment: string;
|
53
|
+
sdkMetaData: SDKMetaData;
|
54
|
+
productScene: ProductSceneEnum;
|
55
|
+
productSceneVersion: string;
|
56
|
+
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
57
|
+
isPreload?: boolean;
|
58
|
+
query: QueryParams;
|
59
|
+
mid?: string;
|
60
|
+
extendInfo?: string;
|
61
|
+
}) => string;
|
38
62
|
export declare const getWebAppUrl: (params: {
|
39
63
|
environment: string;
|
40
64
|
sdkMetaData: SDKMetaData;
|
65
|
+
productScene: ProductSceneEnum;
|
41
66
|
productSceneVersion: string;
|
42
67
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
43
68
|
isPreload?: boolean;
|
44
69
|
query: QueryParams;
|
70
|
+
v2Url?: string;
|
45
71
|
}) => string;
|
46
72
|
export declare const parseWebAppMatchConfig: (extendInfo: string) => WebAppMatchConfig[];
|
73
|
+
export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUrlMatchConfig[];
|
74
|
+
/**
|
75
|
+
* Save the current checkout URL to localStorage for the specified product scene.
|
76
|
+
*
|
77
|
+
* @param productScene - The product scene for which the checkout URL should be saved.
|
78
|
+
*/
|
79
|
+
export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url: string) => void;
|
80
|
+
/**
|
81
|
+
* 获取从外部动态下发的V2AppUrl.
|
82
|
+
*
|
83
|
+
* @param config - sessionData解析来的checkoutInfo列表.
|
84
|
+
*/
|
85
|
+
export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, configs: WebAppUrlMatchConfig[], env: string) => string;
|
86
|
+
/**
|
87
|
+
* 获取ESP从sessionData.checkoutInfo内动态下发的Url.
|
88
|
+
*/
|
89
|
+
export declare const matchEasySafePayV2Url: (params: {
|
90
|
+
configs: WebAppUrlMatchConfig[];
|
91
|
+
mid: string;
|
92
|
+
env: string;
|
93
|
+
pageName: ESP_PAGE_NAME;
|
94
|
+
}) => string;
|
95
|
+
/**
|
96
|
+
* Retrieve the saved checkout URL from localStorage for the specified product scene.
|
97
|
+
* If no url is found, a default checkout url string is returned.
|
98
|
+
*
|
99
|
+
* @param productScene - The product scene for which the checkout URL should be retrieved.
|
100
|
+
*/
|
101
|
+
export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, environment: string) => string;
|
102
|
+
/**
|
103
|
+
* Provide default checkout URL for the specified product scene.
|
104
|
+
* Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
|
105
|
+
*
|
106
|
+
* @param productScene - The product scene for which the default checkout URL should be provided.
|
107
|
+
*/
|
108
|
+
export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
|
109
|
+
/**
|
110
|
+
* V2应用EasySafePay 热更新兜底URL构建规则
|
111
|
+
* 1. 兜底URL版本与sdk版本保持一致
|
112
|
+
* 2. DEV环境下html新增版本前缀
|
113
|
+
**/
|
114
|
+
export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
|
115
|
+
/**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
|
116
|
+
export declare const getDoubleFaUrlFromSession: (paymentSessionObj: IPaymentSessionMetaData, env?: string) => string;
|