@alipay/ams-checkout 0.0.1748327361-dev.0 → 0.0.1748918972-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.
Files changed (34) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +3 -1
  3. package/esm/component/channel.js +26 -62
  4. package/esm/config/index.d.ts +8 -8
  5. package/esm/config/index.js +8 -8
  6. package/esm/constant/easysafepay.d.ts +16 -0
  7. package/esm/constant/easysafepay.js +19 -0
  8. package/esm/constant/index.d.ts +4 -0
  9. package/esm/constant/index.js +4 -0
  10. package/esm/core/component/ckp/index.d.ts +2 -0
  11. package/esm/core/component/ckp/index.js +39 -5
  12. package/esm/core/component/element/util.js +1 -1
  13. package/esm/foundation/core/index.d.ts +3 -0
  14. package/esm/foundation/core/index.js +103 -37
  15. package/esm/foundation/index.d.ts +6 -0
  16. package/esm/foundation/product-processor/easysafepay/deps.d.ts +1 -1
  17. package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -0
  18. package/esm/foundation/product-processor/easysafepay/index.js +244 -121
  19. package/esm/foundation/service/container/index.d.ts +1 -0
  20. package/esm/foundation/service/container/index.js +20 -2
  21. package/esm/foundation/utils/preload_helper.d.ts +2 -2
  22. package/esm/foundation/utils/preload_helper.js +8 -4
  23. package/esm/foundation/utils/web_app_url_utils.d.ts +71 -1
  24. package/esm/foundation/utils/web_app_url_utils.js +215 -8
  25. package/esm/index.js +1 -1
  26. package/esm/plugin/component/cashierApp.js +4 -4
  27. package/esm/plugin/component/channel.d.ts +3 -1
  28. package/esm/plugin/component/channel.js +10 -12
  29. package/esm/plugin/component/index.js +45 -42
  30. package/esm/types/index.d.ts +17 -0
  31. package/esm/types/index.js +6 -0
  32. package/esm/util/redirect.d.ts +6 -0
  33. package/esm/util/redirect.js +54 -0
  34. package/package.json +3 -2
@@ -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 preloadUrl = getWebAppUrl({
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
@@ -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;
@@ -1,25 +1,35 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
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); }
5
- import { ComponentSignEnum } from "../../types";
6
- import { marmotMap } from "../../config";
7
+ import { ComponentSignEnum, ProductSceneEnum } from "../../types";
8
+ import { marmotMap, v2AppMarmotMap, sdkVersion } from "../../config";
7
9
  import { queryParse, serialize } from "../../util";
10
+ import { compareVersion } from "../../util/versionCompare";
8
11
  import { isDebugLog } from "../../util/debug";
9
-
12
+ import { ESP_PAGE_NAME } from "../../constant/easysafepay";
10
13
  /**
11
14
  * Tell the SDK which version of the Web App to load.
12
15
  * Sent by server inside paymentSession.
13
16
  */
14
17
 
18
+ /**
19
+ * Tell the SDK which Web App URL to load.
20
+ * Sent by server inside paymentSession.
21
+ */
22
+
15
23
  export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
16
24
  var environment = params.environment,
17
25
  sdkMetaData = params.sdkMetaData,
26
+ productScene = params.productScene,
18
27
  productSceneVersion = params.productSceneVersion,
19
28
  paymentMethodCategoryType = params.paymentMethodCategoryType,
20
29
  query = params.query,
21
- isPreload = params.isPreload;
22
- var path = getAppPath(environment, sdkMetaData, productSceneVersion, paymentMethodCategoryType);
30
+ isPreload = params.isPreload,
31
+ v2Url = params.v2Url;
32
+ var path = getAppPath(environment, sdkMetaData, productScene, productSceneVersion, paymentMethodCategoryType, v2Url);
23
33
  var _queryParse = queryParse(),
24
34
  _sandbox = _queryParse._sandbox,
25
35
  _light_sandbox = _queryParse._light_sandbox,
@@ -57,6 +67,30 @@ export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
57
67
  locationSearch: locationSearch
58
68
  };
59
69
  };
70
+ export var getWebAppV2Url = function getWebAppV2Url(params) {
71
+ var productScene = params.productScene,
72
+ isPreload = params.isPreload,
73
+ mid = params.mid,
74
+ extendInfo = params.extendInfo,
75
+ environment = params.environment;
76
+ var webAppUrlMatchConfig = parseWebAppUrlMatchConfig(extendInfo);
77
+ var v2Url = isPreload ? getLocalCheckoutUrl(productScene, environment) : getMatchedWebAppV2Url(productScene, mid, webAppUrlMatchConfig, environment);
78
+ var info = getWebAppUrlInfo(_objectSpread(_objectSpread({}, params), {}, {
79
+ v2Url: v2Url
80
+ }));
81
+ if (!isPreload && v2Url && info.path) {
82
+ console.log('[web-sdk] save web app, url: ', info.path);
83
+ saveLocalCheckoutUrl(productScene, info.path);
84
+ }
85
+ var webAppUrl;
86
+ if (info.path.indexOf('?') !== -1) {
87
+ webAppUrl = "".concat(info.path, "&").concat(info.locationSearch);
88
+ } else {
89
+ webAppUrl = "".concat(info.path, "?").concat(info.locationSearch);
90
+ }
91
+ console.log('[web-sdk] web app, url: ', webAppUrl);
92
+ return webAppUrl;
93
+ };
60
94
  export var getWebAppUrl = function getWebAppUrl(params) {
61
95
  var info = getWebAppUrlInfo(params);
62
96
  var webAppUrl;
@@ -70,8 +104,10 @@ export var getWebAppUrl = function getWebAppUrl(params) {
70
104
  var getAppPath = function getAppPath() {
71
105
  var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
72
106
  var sdkMetaData = arguments.length > 1 ? arguments[1] : undefined;
73
- var productSceneVersion = arguments.length > 2 ? arguments[2] : undefined;
74
- var paymentMethodCategoryType = arguments.length > 3 ? arguments[3] : undefined;
107
+ var productScene = arguments.length > 2 ? arguments[2] : undefined;
108
+ var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
109
+ var paymentMethodCategoryType = arguments.length > 4 ? arguments[4] : undefined;
110
+ var v2Url = arguments.length > 5 ? arguments[5] : undefined;
75
111
  var _ref = queryParse() || {},
76
112
  urlTestHost = _ref.host;
77
113
  // only for test while testurl?host=https://xxxxx.test.html
@@ -81,7 +117,12 @@ var getAppPath = function getAppPath() {
81
117
  var validProductSceneVersion = getValidProductSceneVersion(sdkMetaData.productScene, productSceneVersion, paymentMethodCategoryType);
82
118
  var productSceneWithPaymentMethodCategoryType = "".concat(sdkMetaData.productScene, "_").concat(paymentMethodCategoryType);
83
119
  var webAppVersion = sdkMetaData.webAppVersion;
84
- return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
120
+ switch (productScene) {
121
+ case ProductSceneEnum.EASY_PAY:
122
+ return v2Url !== null && v2Url !== void 0 ? v2Url : defaultCheckoutUrl(productScene, environment);
123
+ default:
124
+ return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
125
+ }
85
126
  };
86
127
  export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo) {
87
128
  if (!extendInfo) {
@@ -96,6 +137,18 @@ export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo)
96
137
  return [];
97
138
  }
98
139
  };
140
+ export var parseWebAppUrlMatchConfig = function parseWebAppUrlMatchConfig(extendInfo) {
141
+ if (!extendInfo) {
142
+ return [];
143
+ }
144
+ try {
145
+ var extendInfoJson = JSON.parse(extendInfo);
146
+ return extendInfoJson === null || extendInfoJson === void 0 ? void 0 : extendInfoJson.checkoutInfo;
147
+ } catch (error) {
148
+ console.error('Parse the url config for Web app failed#', error);
149
+ return [];
150
+ }
151
+ };
99
152
  var getValidProductSceneVersion = function getValidProductSceneVersion(productScene, productSceneVer, paymentMethodCategoryType) {
100
153
  var _supportMapping;
101
154
  var supportMapping = (_supportMapping = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.NONE, ['']), ComponentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), ComponentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), ComponentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), ComponentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), ComponentSignEnum.EASY_PAY_APM, ['2.0']), ComponentSignEnum.VAULTING_CARD, ['1.0']), ComponentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.ELEMENT_ADDRESS, ['1.0']), ComponentSignEnum.CHECKOUT_PAYMENT, ['1.0']));
@@ -109,4 +162,158 @@ var getValidProductSceneVersion = function getValidProductSceneVersion(productSc
109
162
  });
110
163
  var latestVersion = targetVersions[targetVersions.length - 1];
111
164
  return isSupport ? productSceneVer : latestVersion;
165
+ };
166
+ var KEY_CHECKOUT_URL = "web_url_";
167
+
168
+ /**
169
+ * Save the current checkout URL to localStorage for the specified product scene.
170
+ *
171
+ * @param productScene - The product scene for which the checkout URL should be saved.
172
+ */
173
+ export var saveLocalCheckoutUrl = function saveLocalCheckoutUrl(productScene, url) {
174
+ var key = KEY_CHECKOUT_URL + productScene;
175
+ localStorage.setItem(key, url);
176
+ };
177
+
178
+ /**
179
+ * 获取从外部动态下发的V2AppUrl.
180
+ *
181
+ * @param config - sessionData解析来的checkoutInfo列表.
182
+ */
183
+ export var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
184
+ var mid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
185
+ var configs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
186
+ var env = arguments.length > 3 ? arguments[3] : undefined;
187
+ switch (productScene) {
188
+ case ProductSceneEnum.EASY_PAY:
189
+ return matchEasySafePayV2Url({
190
+ configs: configs,
191
+ mid: mid,
192
+ env: env,
193
+ pageName: ESP_PAGE_NAME.SDK_PORTAL
194
+ });
195
+ default:
196
+ return defaultCheckoutUrl(productScene, env);
197
+ }
198
+ };
199
+
200
+ /**
201
+ * 获取ESP从sessionData.checkoutInfo内动态下发的Url.
202
+ */
203
+ export var matchEasySafePayV2Url = function matchEasySafePayV2Url(params) {
204
+ var _params$configs = params.configs,
205
+ configs = _params$configs === void 0 ? [] : _params$configs,
206
+ _params$mid = params.mid,
207
+ mid = _params$mid === void 0 ? '' : _params$mid,
208
+ env = params.env,
209
+ pageName = params.pageName;
210
+ var matchURLByMid = function matchURLByMid() {
211
+ var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
212
+ var targetConfigEntry = sortedConfigs.find(function (configEntry) {
213
+ var _configEntry$mids;
214
+ var isMatchMid = !!(configEntry !== null && configEntry !== void 0 && (_configEntry$mids = configEntry.mids) !== null && _configEntry$mids !== void 0 && _configEntry$mids.includes(mid));
215
+ var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
216
+ if (isMatchMid && isMatchVersion) {
217
+ return configEntry;
218
+ }
219
+ });
220
+ return targetConfigEntry;
221
+ };
222
+ var matchURLBySDKVersion = function matchURLBySDKVersion() {
223
+ var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
224
+ var targetConfigEntry = sortedConfigs.find(function (configEntry) {
225
+ var isCommonConfig = (configEntry === null || configEntry === void 0 ? void 0 : configEntry.mids) === undefined;
226
+ var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
227
+ if (isCommonConfig && isMatchVersion) {
228
+ return configEntry;
229
+ }
230
+ });
231
+ return targetConfigEntry;
232
+ };
233
+ var matchConfig = function matchConfig() {
234
+ // 按SDK版本降排序
235
+ var sortedConfig = configs.sort(function (a, b) {
236
+ return compareVersion(b.minSDKVersion, a.minSDKVersion);
237
+ });
238
+
239
+ // 匹配仅针对部分商户生效(mid),且符合版本号的URL
240
+ var matchedURLByMid = matchURLByMid(sortedConfig);
241
+ if (matchedURLByMid) return matchedURLByMid;
242
+
243
+ // 匹配对所有商户生效(无mid),且符合版本号的URL
244
+ var matchedURLBySDKVersion = matchURLBySDKVersion(sortedConfig);
245
+ if (matchedURLBySDKVersion) return matchedURLBySDKVersion;
246
+ };
247
+ var defaultEspUrl = getDefaultEasySafePayPageUrl(pageName, env);
248
+
249
+ // 匹配config
250
+ var config = matchConfig();
251
+ if (!config) return defaultEspUrl;
252
+
253
+ // 根据pageName匹配URL
254
+ if (pageName == ESP_PAGE_NAME.SDK_PORTAL) return (config === null || config === void 0 ? void 0 : config.url) || defaultEspUrl;
255
+ if (pageName == ESP_PAGE_NAME.DOUBLE_FA) return (config === null || config === void 0 ? void 0 : config.doubleFa) || defaultEspUrl;
256
+ return defaultEspUrl;
257
+ };
258
+
259
+ /**
260
+ * Retrieve the saved checkout URL from localStorage for the specified product scene.
261
+ * If no url is found, a default checkout url string is returned.
262
+ *
263
+ * @param productScene - The product scene for which the checkout URL should be retrieved.
264
+ */
265
+ export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene, environment) {
266
+ var key = KEY_CHECKOUT_URL + productScene;
267
+ var previousCheckoutUrl = localStorage.getItem(key);
268
+ return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene, environment);
269
+ };
270
+
271
+ /**
272
+ * Provide default checkout URL for the specified product scene.
273
+ * Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
274
+ *
275
+ * @param productScene - The product scene for which the default checkout URL should be provided.
276
+ */
277
+ export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
278
+ var environment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "prod";
279
+ switch (productScene) {
280
+ case ProductSceneEnum.EASY_PAY:
281
+ return getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.SDK_PORTAL, environment);
282
+ default:
283
+ return '';
284
+ }
285
+ };
286
+
287
+ /**
288
+ * V2应用EasySafePay 热更新兜底URL构建规则
289
+ * 1. 兜底URL版本与sdk版本保持一致
290
+ * 2. DEV环境下html新增版本前缀
291
+ **/
292
+ export var getDefaultEasySafePayPageUrl = function getDefaultEasySafePayPageUrl(pageName, env) {
293
+ // 生成的URL EXAMPLE:
294
+ // const DEFAULT_DOUBLE_FA_URL_MAPPING = {
295
+ // local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
296
+ // dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
297
+ // sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
298
+ // pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
299
+ // prod: 'https://checkout.antom.com/easysafepay/1.36.0/pages/double-fa/index.html',
300
+ // };
301
+ var environment = env || "prod";
302
+ 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");
303
+ };
304
+
305
+ /**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
306
+ //TODO 后续需要构造一个类,专门用于构造&存储web应用url
307
+ export var getDoubleFaUrlFromSession = function getDoubleFaUrlFromSession(paymentSessionObj) {
308
+ var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "prod";
309
+ var mid = paymentSessionObj.clientId;
310
+ var extendInfo = paymentSessionObj.extendInfo;
311
+ var configs = parseWebAppUrlMatchConfig(extendInfo);
312
+ var url = matchEasySafePayV2Url({
313
+ configs: configs,
314
+ mid: mid,
315
+ env: env,
316
+ pageName: ESP_PAGE_NAME.DOUBLE_FA
317
+ });
318
+ return url;
112
319
  };
package/esm/index.js CHANGED
@@ -271,7 +271,7 @@ export var AMSEasyPay = /*#__PURE__*/function () {
271
271
  securityRegion: 'SG',
272
272
  environment: 'prod'
273
273
  };
274
- PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
274
+ PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment, true);
275
275
  }
276
276
  }]);
277
277
  return AMSEasyPay;
@@ -15,7 +15,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
15
15
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
16
16
  * 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.
17
17
  */
18
- import { elementAppMarmotMap, marmotMap, sdkVersion } from "../../config/index";
18
+ import { v2AppMarmotMap, marmotMap, sdkVersion } from "../../config/index";
19
19
  import { ComponentSignEnum, ComponentSignEnumV2 } from "../../types";
20
20
  import { isDebugLog } from "../../util/debug";
21
21
  import { queryParse, serialize } from "../../util/index";
@@ -103,7 +103,7 @@ export var getAppPath = function getAppPath() {
103
103
  }
104
104
  // 地址应用特殊处理
105
105
  if (componentSign === ComponentSignEnum.ELEMENT_ADDRESS) {
106
- return "".concat(elementAppMarmotMap[environment], "/element-address/").concat(finalAppVersion, "/pages/address/index.html");
106
+ return "".concat(v2AppMarmotMap[environment], "/element-address/").concat(finalAppVersion, "/pages/address/index.html");
107
107
  }
108
108
  // element应用特殊处理
109
109
  if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign)) {
@@ -117,9 +117,9 @@ export var getAppPath = function getAppPath() {
117
117
  }
118
118
  if (isExpressCheckout) {
119
119
  // express_checkout模式走单独映射
120
- return "".concat(elementAppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/express_checkout/index.html");
120
+ return "".concat(v2AppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/express_checkout/index.html");
121
121
  } else {
122
- return "".concat(elementAppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/").concat(productScene.toLowerCase(), "/index.html");
122
+ return "".concat(v2AppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/").concat(productScene.toLowerCase(), "/index.html");
123
123
  }
124
124
  }
125
125
  return "".concat(marmotMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
@@ -11,12 +11,14 @@ export type IChannelBehavior = {
11
11
  type GetDoubleFaParams = {
12
12
  instanceId: string;
13
13
  paymentSessionData: string;
14
+ paymentSessionObj: IPaymentSessionMetaData;
14
15
  locale: string;
15
16
  paymentMethodType: string;
16
17
  env: string;
17
18
  sdkVersion: string;
19
+ notRedirectAfterComplete: boolean;
18
20
  };
19
- export declare function getChannelBehavior(paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
21
+ export declare function getChannelBehavior(paymentSessionMetaData?: IPaymentSessionMetaData, notRedirectAfterComplete?: boolean): IChannelBehavior | undefined;
20
22
  export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
21
23
  export declare const handleGooglePay: (data: EventPayload) => Promise<unknown>;
22
24
  export declare class ApplePaySdk {
@@ -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 { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
18
+ import { MODE } 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";
@@ -27,7 +29,7 @@ var PAYMENT_STATUS = /*#__PURE__*/function (PAYMENT_STATUS) {
27
29
  PAYMENT_STATUS["NORMAL"] = "NORMAL";
28
30
  return PAYMENT_STATUS;
29
31
  }(PAYMENT_STATUS || {});
30
- export function getChannelBehavior(paymentSessionMetaData) {
32
+ export function getChannelBehavior(paymentSessionMetaData, notRedirectAfterComplete) {
31
33
  var _paymentSessionMetaDa, _paymentSessionMetaDa2, _paymentSessionMetaDa3, _paymentSessionMetaDa4, _paymentSessionMetaDa5, _paymentSessionMetaDa6, _paymentSessionMetaDa7, _paymentSessionMetaDa8;
32
34
  // TOSS EASYPAY 2.0
33
35
  if ('BANKTRANSFER_QUICKPAY' === (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType) && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa2 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa2 === void 0 ? void 0 : _paymentSessionMetaDa2.productScene) === 'EASY_PAY' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa3 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa3 === void 0 ? void 0 : _paymentSessionMetaDa3.paymentMethodCategoryType) === 'APM' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa4 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa4 === void 0 ? void 0 : _paymentSessionMetaDa4.productSceneVersion) === '2.0') {
@@ -40,7 +42,8 @@ export function getChannelBehavior(paymentSessionMetaData) {
40
42
  buildSubmitPayExtParams: function buildSubmitPayExtParams(params) {
41
43
  var callBackUrl = getDoubleFaUrl(params);
42
44
  return {
43
- callBackUrl: callBackUrl
45
+ callBackUrl: callBackUrl,
46
+ notRedirectAfterComplete: notRedirectAfterComplete === true
44
47
  };
45
48
  }
46
49
  };
@@ -65,20 +68,15 @@ export function getDoubleFaUrl(params) {
65
68
  var instanceId = params.instanceId,
66
69
  paymentMethodType = params.paymentMethodType,
67
70
  paymentSessionData = params.paymentSessionData,
71
+ paymentSessionObj = params.paymentSessionObj,
68
72
  locale = params.locale,
69
73
  env = params.env,
70
- sdkVersion = params.sdkVersion;
74
+ sdkVersion = params.sdkVersion,
75
+ notRedirectAfterComplete = params.notRedirectAfterComplete;
71
76
  var isLandscapeOrientation = false; // Web 不含横屏
72
77
 
73
- var DOUBLE_FA_URL_MAPPING = {
74
- local: "http://page.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
75
- dev: "http://page.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
76
- sit: "http://page.test.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
77
- pre: "https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
78
- prod: "https://ac.alipay.com/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".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);
78
+ var baseDoubleFaUrl = getDoubleFaUrlFromSession(paymentSessionObj, env);
79
+ return "".concat(baseDoubleFaUrl) + '?' + "scene=cashierResultPage" + '&' + "instanceId=".concat(instanceId) + '&' + "paymentSessionData=".concat(encodeURIComponent(paymentSessionData)) + '&' + "isLandscape=".concat(isLandscapeOrientation ? 'true' : '') + '&' + "pmt=".concat(paymentMethodType) + '&' + "locale=".concat(locale) + '&' + "mode=".concat(MODE.SDK) + '&' + "sdkVersion=".concat(sdkVersion) + '&' + "&notRedirectAfterComplete=".concat(notRedirectAfterComplete);
82
80
  }
83
81
  export var handleGooglePay = function handleGooglePay(data) {
84
82
  return new Promise(function (resolve, reject) {