@alipay/ams-checkout 0.0.1746674797-dev.1 → 0.0.1746674797-dev.3

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.
@@ -1,3 +1,5 @@
1
+ import { getDefaultEasySafePayPageUrl } from "../foundation/utils/web_app_url_utils";
2
+ import { ESP_PAGE_NAME } from "../constant/easysafepay";
1
3
  export function getChannelBehavior(paymentSessionMetaData) {
2
4
  var _paymentSessionMetaDa;
3
5
  var allowSubmitPayCallAhead = false;
@@ -75,13 +77,6 @@ export function getDoubleFaUrl(params) {
75
77
  sdkVersion = params.sdkVersion;
76
78
  var isLandscapeOrientation = false; // Web 不含横屏
77
79
 
78
- var DOUBLE_FA_URL_MAPPING = {
79
- local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index-1.0.1.html',
80
- dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index-1.0.1.html',
81
- sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
82
- pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
83
- prod: 'https://checkout.antom.com/easysafepay/pages/double-fa/index.html'
84
- };
85
- var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
86
- 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);
80
+ var defaultFaBaseUrl = getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.DOUBLE_FA, env);
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);
87
82
  }
@@ -0,0 +1,6 @@
1
+ export declare enum ESP_PAGE_NAME {
2
+ API_PORTAL = "api-portal",
3
+ SDK_PORTAL = "sdk-portal",
4
+ DOUBLE_FA = "double-fa",
5
+ PRELOAD = "preload"
6
+ }
@@ -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.
@@ -81,11 +82,17 @@ export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url:
81
82
  *
82
83
  * @param productScene - The product scene for which the checkout URL should be retrieved.
83
84
  */
84
- export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum) => string;
85
+ export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, environment: string) => string;
85
86
  /**
86
87
  * Provide default checkout URL for the specified product scene.
87
88
  * Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
88
89
  *
89
90
  * @param productScene - The product scene for which the default checkout URL should be provided.
90
91
  */
91
- export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum) => string;
92
+ export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
93
+ /**
94
+ * V2应用EasySafePay 热更新兜底URL构建规则
95
+ * 1. 兜底URL版本与sdk版本保持一致
96
+ * 2. DEV环境下html新增版本前缀
97
+ **/
98
+ export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
@@ -5,10 +5,10 @@ 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
10
  import { isDebugLog } from "../../util/debug";
11
-
11
+ import { ESP_PAGE_NAME } from "../../constant/easysafepay";
12
12
  /**
13
13
  * Tell the SDK which version of the Web App to load.
14
14
  * Sent by server inside paymentSession.
@@ -70,9 +70,10 @@ export var getWebAppV2Url = function getWebAppV2Url(params) {
70
70
  var productScene = params.productScene,
71
71
  isPreload = params.isPreload,
72
72
  mid = params.mid,
73
- extendInfo = params.extendInfo;
73
+ extendInfo = params.extendInfo,
74
+ environment = params.environment;
74
75
  var webAppUrlMatchConfig = parseWebAppUrlMatchConfig(extendInfo);
75
- var v2Url = isPreload ? getLocalCheckoutUrl(productScene) : getMatchedWebAppV2Url(productScene, mid, webAppUrlMatchConfig);
76
+ var v2Url = isPreload ? getLocalCheckoutUrl(productScene, environment) : getMatchedWebAppV2Url(productScene, mid, webAppUrlMatchConfig, environment);
76
77
  var info = getWebAppUrlInfo(_objectSpread(_objectSpread({}, params), {}, {
77
78
  v2Url: v2Url
78
79
  }));
@@ -117,7 +118,7 @@ var getAppPath = function getAppPath() {
117
118
  var webAppVersion = sdkMetaData.webAppVersion;
118
119
  switch (productScene) {
119
120
  case ProductSceneEnum.EASY_PAY:
120
- return v2Url !== null && v2Url !== void 0 ? v2Url : defaultCheckoutUrl(productScene);
121
+ return v2Url !== null && v2Url !== void 0 ? v2Url : defaultCheckoutUrl(productScene, environment);
121
122
  default:
122
123
  return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
123
124
  }
@@ -179,10 +180,10 @@ export var saveLocalCheckoutUrl = function saveLocalCheckoutUrl(productScene, ur
179
180
  *
180
181
  * @param productScene - The product scene for which the checkout URL should be retrieved.
181
182
  */
182
- export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene) {
183
+ export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene, environment) {
183
184
  var key = KEY_CHECKOUT_URL + productScene;
184
185
  var previousCheckoutUrl = localStorage.getItem(key);
185
- return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene);
186
+ return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene, environment);
186
187
  };
187
188
 
188
189
  /**
@@ -192,11 +193,10 @@ export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene) {
192
193
  * @param productScene - The product scene for which the default checkout URL should be provided.
193
194
  */
194
195
  export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
195
- var defaultEnvironment = 'prod';
196
- var defaultEasyPayVersion = '1.0.1';
196
+ var environment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "prod";
197
197
  switch (productScene) {
198
198
  case ProductSceneEnum.EASY_PAY:
199
- return "".concat(v2AppMarmotMap[defaultEnvironment], "/easysafepay/").concat(defaultEasyPayVersion, "/pages/sdk-portal/index.html");
199
+ return getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.API_PORTAL, environment);
200
200
  default:
201
201
  return '';
202
202
  }
@@ -204,9 +204,10 @@ export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
204
204
  var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
205
205
  var mid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
206
206
  var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
207
+ var environment = arguments.length > 3 ? arguments[3] : undefined;
207
208
  if (config.length === 0) {
208
209
  // Default checkout url
209
- return defaultCheckoutUrl(productScene);
210
+ return defaultCheckoutUrl(productScene, environment);
210
211
  }
211
212
  var sortedConfig = config.sort(function (a, b) {
212
213
  return parseFloat(b.version) - parseFloat(a.version);
@@ -231,5 +232,23 @@ var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
231
232
  }
232
233
 
233
234
  // Default checkout url
234
- return defaultCheckoutUrl(productScene);
235
+ return defaultCheckoutUrl(productScene, environment);
236
+ };
237
+
238
+ /**
239
+ * V2应用EasySafePay 热更新兜底URL构建规则
240
+ * 1. 兜底URL版本与sdk版本保持一致
241
+ * 2. DEV环境下html新增版本前缀
242
+ **/
243
+ export var getDefaultEasySafePayPageUrl = function getDefaultEasySafePayPageUrl(pageName, env) {
244
+ // 生成的URL EXAMPLE:
245
+ // const DEFAULT_DOUBLE_FA_URL_MAPPING = {
246
+ // local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
247
+ // dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
248
+ // sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
249
+ // pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
250
+ // prod: 'https://checkout.antom.com/easysafepay/1.36.0/pages/double-fa/index.html',
251
+ // };
252
+ var environment = env || "prod";
253
+ 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");
235
254
  };
@@ -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 DOUBLE_FA_URL_MAPPING = {
74
- local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index-1.0.1.html',
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1746674797-dev.1",
3
+ "version": "0.0.1746674797-dev.3",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",