@alipay/ams-checkout 0.0.1746674797-dev.3 → 0.0.1746674797-dev.5
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.
@@ -22,9 +22,10 @@ export interface WebAppMatchConfig {
|
|
22
22
|
* Sent by server inside paymentSession.
|
23
23
|
*/
|
24
24
|
export interface WebAppUrlMatchConfig {
|
25
|
-
|
25
|
+
minSDKVersion: string;
|
26
26
|
url: string;
|
27
|
-
|
27
|
+
doubleFa: string;
|
28
|
+
mids?: string[];
|
28
29
|
}
|
29
30
|
export interface QueryParams {
|
30
31
|
displayType: DisplayTypeEnum;
|
@@ -90,6 +91,7 @@ export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, envir
|
|
90
91
|
* @param productScene - The product scene for which the default checkout URL should be provided.
|
91
92
|
*/
|
92
93
|
export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
|
94
|
+
export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, config: WebAppUrlMatchConfig[], environment: string) => string;
|
93
95
|
/**
|
94
96
|
* V2应用EasySafePay 热更新兜底URL构建规则
|
95
97
|
* 1. 兜底URL版本与sdk版本保持一致
|
@@ -7,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
7
7
|
import { ComponentSignEnum, ProductSceneEnum } from "../../types";
|
8
8
|
import { marmotMap, v2AppMarmotMap, sdkVersion } from "../../config";
|
9
9
|
import { queryParse, serialize } from "../../util";
|
10
|
+
import { compareVersion } from "../../util/versionCompare";
|
10
11
|
import { isDebugLog } from "../../util/debug";
|
11
12
|
import { ESP_PAGE_NAME } from "../../constant/easysafepay";
|
12
13
|
/**
|
@@ -201,35 +202,48 @@ export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
|
|
201
202
|
return '';
|
202
203
|
}
|
203
204
|
};
|
204
|
-
var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
|
205
|
+
export var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
|
205
206
|
var mid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
206
207
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
207
208
|
var environment = arguments.length > 3 ? arguments[3] : undefined;
|
209
|
+
// Default checkout url
|
208
210
|
if (config.length === 0) {
|
209
|
-
// Default checkout url
|
210
211
|
return defaultCheckoutUrl(productScene, environment);
|
211
212
|
}
|
212
|
-
var
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
}
|
221
|
-
});
|
222
|
-
if (targetConfigEntry) {
|
223
|
-
// Match merchant ID
|
213
|
+
var matchURLByMid = function matchURLByMid() {
|
214
|
+
var targetConfigEntry = sortedConfig.find(function (configEntry) {
|
215
|
+
var _configEntry$mids;
|
216
|
+
var isMatchMid = !!(configEntry !== null && configEntry !== void 0 && (_configEntry$mids = configEntry.mids) !== null && _configEntry$mids !== void 0 && _configEntry$mids.includes(mid));
|
217
|
+
var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
|
218
|
+
if (isMatchMid && isMatchVersion) {
|
219
|
+
return configEntry;
|
220
|
+
}
|
221
|
+
});
|
224
222
|
return targetConfigEntry === null || targetConfigEntry === void 0 ? void 0 : targetConfigEntry.url;
|
225
|
-
}
|
226
|
-
var
|
227
|
-
|
223
|
+
};
|
224
|
+
var matchURLBySDKVersion = function matchURLBySDKVersion() {
|
225
|
+
var targetConfigEntry = sortedConfig.find(function (configEntry) {
|
226
|
+
var isCommonConfig = (configEntry === null || configEntry === void 0 ? void 0 : configEntry.mids) === undefined;
|
227
|
+
var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
|
228
|
+
if (isCommonConfig && isMatchVersion) {
|
229
|
+
return configEntry;
|
230
|
+
}
|
231
|
+
});
|
232
|
+
return targetConfigEntry === null || targetConfigEntry === void 0 ? void 0 : targetConfigEntry.url;
|
233
|
+
};
|
234
|
+
|
235
|
+
// 按SDK版本降排序
|
236
|
+
var sortedConfig = config.sort(function (a, b) {
|
237
|
+
return compareVersion(b.minSDKVersion, a.minSDKVersion);
|
228
238
|
});
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
239
|
+
|
240
|
+
// 匹配仅针对部分商户生效(mid),且符合版本号的URL
|
241
|
+
var matchedURLByMid = matchURLByMid();
|
242
|
+
if (matchedURLByMid) return matchedURLByMid;
|
243
|
+
|
244
|
+
// 匹配对所有商户生效(无mid),且符合版本号的URL
|
245
|
+
var matchedURLBySDKVersion = matchURLBySDKVersion();
|
246
|
+
if (matchedURLBySDKVersion) return matchedURLBySDKVersion;
|
233
247
|
|
234
248
|
// Default checkout url
|
235
249
|
return defaultCheckoutUrl(productScene, environment);
|