@alipay/ams-checkout 0.0.1746674797-dev.2 → 0.0.1746674797-dev.4
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.js +2 -1
- package/esm/constant/easysafepay.d.ts +6 -0
- package/esm/constant/easysafepay.js +7 -0
- package/esm/foundation/utils/web_app_url_utils.d.ts +7 -4
- package/esm/foundation/utils/web_app_url_utils.js +45 -32
- package/esm/plugin/component/channel.js +4 -9
- package/package.json +1 -1
package/esm/component/channel.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { getDefaultEasySafePayPageUrl } from "../foundation/utils/web_app_url_utils";
|
2
|
+
import { ESP_PAGE_NAME } from "../constant/easysafepay";
|
2
3
|
export function getChannelBehavior(paymentSessionMetaData) {
|
3
4
|
var _paymentSessionMetaDa;
|
4
5
|
var allowSubmitPayCallAhead = false;
|
@@ -76,6 +77,6 @@ export function getDoubleFaUrl(params) {
|
|
76
77
|
sdkVersion = params.sdkVersion;
|
77
78
|
var isLandscapeOrientation = false; // Web 不含横屏
|
78
79
|
|
79
|
-
var defaultFaBaseUrl = getDefaultEasySafePayPageUrl(
|
80
|
+
var defaultFaBaseUrl = getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.DOUBLE_FA, env);
|
80
81
|
return "".concat(defaultFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(paymentSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
81
82
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export var ESP_PAGE_NAME = /*#__PURE__*/function (ESP_PAGE_NAME) {
|
2
|
+
ESP_PAGE_NAME["API_PORTAL"] = "api-portal";
|
3
|
+
ESP_PAGE_NAME["SDK_PORTAL"] = "sdk-portal";
|
4
|
+
ESP_PAGE_NAME["DOUBLE_FA"] = "double-fa";
|
5
|
+
ESP_PAGE_NAME["PRELOAD"] = "preload";
|
6
|
+
return ESP_PAGE_NAME;
|
7
|
+
}({});
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } 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.
|
@@ -21,9 +22,10 @@ export interface WebAppMatchConfig {
|
|
21
22
|
* Sent by server inside paymentSession.
|
22
23
|
*/
|
23
24
|
export interface WebAppUrlMatchConfig {
|
24
|
-
|
25
|
+
minSDKVersion: string;
|
25
26
|
url: string;
|
26
|
-
|
27
|
+
doubleFa: string;
|
28
|
+
mids?: string[];
|
27
29
|
}
|
28
30
|
export interface QueryParams {
|
29
31
|
displayType: DisplayTypeEnum;
|
@@ -89,9 +91,10 @@ export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, envir
|
|
89
91
|
* @param productScene - The product scene for which the default checkout URL should be provided.
|
90
92
|
*/
|
91
93
|
export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
|
94
|
+
export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, config: WebAppUrlMatchConfig[], environment: string) => string;
|
92
95
|
/**
|
93
96
|
* V2应用EasySafePay 热更新兜底URL构建规则
|
94
|
-
* 1.
|
97
|
+
* 1. 兜底URL版本与sdk版本保持一致
|
95
98
|
* 2. DEV环境下html新增版本前缀
|
96
99
|
**/
|
97
|
-
export declare const getDefaultEasySafePayPageUrl: (pageName:
|
100
|
+
export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
|
@@ -5,10 +5,11 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
6
|
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); }
|
7
7
|
import { ComponentSignEnum, ProductSceneEnum } from "../../types";
|
8
|
-
import { marmotMap, v2AppMarmotMap } from "../../config";
|
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
|
/**
|
13
14
|
* Tell the SDK which version of the Web App to load.
|
14
15
|
* Sent by server inside paymentSession.
|
@@ -196,40 +197,53 @@ export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
|
|
196
197
|
var environment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "prod";
|
197
198
|
switch (productScene) {
|
198
199
|
case ProductSceneEnum.EASY_PAY:
|
199
|
-
return getDefaultEasySafePayPageUrl(
|
200
|
+
return getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.API_PORTAL, environment);
|
200
201
|
default:
|
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);
|
@@ -237,19 +251,18 @@ var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
|
|
237
251
|
|
238
252
|
/**
|
239
253
|
* V2应用EasySafePay 热更新兜底URL构建规则
|
240
|
-
* 1.
|
254
|
+
* 1. 兜底URL版本与sdk版本保持一致
|
241
255
|
* 2. DEV环境下html新增版本前缀
|
242
256
|
**/
|
243
257
|
export var getDefaultEasySafePayPageUrl = function getDefaultEasySafePayPageUrl(pageName, env) {
|
244
258
|
// 生成的URL EXAMPLE:
|
245
259
|
// const DEFAULT_DOUBLE_FA_URL_MAPPING = {
|
246
|
-
// local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.0
|
247
|
-
// dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.0
|
248
|
-
// sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/1.0
|
249
|
-
// pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/1.0
|
250
|
-
// prod: 'https://checkout.antom.com/easysafepay/1.0
|
260
|
+
// local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
|
261
|
+
// dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
|
262
|
+
// sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
|
263
|
+
// pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
|
264
|
+
// prod: 'https://checkout.antom.com/easysafepay/1.36.0/pages/double-fa/index.html',
|
251
265
|
// };
|
252
|
-
var defaultEasyPayVersion = '1.0.1';
|
253
266
|
var environment = env || "prod";
|
254
|
-
if (environment === "dev") return "".concat(v2AppMarmotMap[environment], "/easysafepay/").concat(
|
267
|
+
if (environment === "dev") return "".concat(v2AppMarmotMap[environment], "/easysafepay/").concat(sdkVersion, "/pages/").concat(pageName, "/index-").concat(sdkVersion, ".html");else return "".concat(v2AppMarmotMap[environment], "/easysafepay/").concat(sdkVersion, "/pages/").concat(pageName, "/index.html");
|
255
268
|
};
|
@@ -14,6 +14,8 @@ import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
|
14
14
|
import { EnvironmentEnum } from "../../types";
|
15
15
|
import { device, isEmpty } from "../../util";
|
16
16
|
import { APPLE_PAY_RECURRING_VERSION, APPLE_PAY_VERSION } from "../applepay/interface";
|
17
|
+
import { getDefaultEasySafePayPageUrl } from "../../foundation/utils/web_app_url_utils";
|
18
|
+
import { ESP_PAGE_NAME } from "../../constant/easysafepay";
|
17
19
|
var APPLEPAYERRORENUM = /*#__PURE__*/function (APPLEPAYERRORENUM) {
|
18
20
|
APPLEPAYERRORENUM["APPLE_PAY_MISSING_DATA"] = "APPLE_PAY_MISSING_DATA";
|
19
21
|
APPLEPAYERRORENUM["APPLE_PAY_NOT_SUPPORTED"] = "APPLE_PAY_NOT_SUPPORTED";
|
@@ -70,15 +72,8 @@ export function getDoubleFaUrl(params) {
|
|
70
72
|
sdkVersion = params.sdkVersion;
|
71
73
|
var isLandscapeOrientation = false; // Web 不含横屏
|
72
74
|
|
73
|
-
var
|
74
|
-
|
75
|
-
dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index-1.0.1.html',
|
76
|
-
sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
|
77
|
-
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
|
78
|
-
prod: 'https://checkout.antom.com/easysafepay/pages/double-fa/index.html'
|
79
|
-
};
|
80
|
-
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
81
|
-
return "".concat(doubleFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(paymentSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
75
|
+
var defaultFaBaseUrl = getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.DOUBLE_FA, env);
|
76
|
+
return "".concat(defaultFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(paymentSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
82
77
|
}
|
83
78
|
export var handleGooglePay = function handleGooglePay(data) {
|
84
79
|
return new Promise(function (resolve, reject) {
|