@alipay/ams-checkout 0.0.1745808793-dev.7 → 0.0.1745808793-dev.9

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.
@@ -9,12 +9,13 @@ export type IChannelBehavior = {
9
9
  type GetDoubleFaParams = {
10
10
  instanceId: string;
11
11
  paymentSessionData: string;
12
+ paymentSessionObj: IPaymentSessionMetaData;
12
13
  locale: string;
13
14
  paymentMethodType: string;
14
15
  env: string;
15
16
  sdkVersion: string;
16
17
  notRedirectAfterComplete: boolean;
17
18
  };
18
- export declare function getChannelBehavior(paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
19
+ export declare function getChannelBehavior(notRedirectAfterComplete: boolean, paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
19
20
  export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
20
21
  export {};
@@ -1,8 +1,7 @@
1
- import { getDefaultEasySafePayPageUrl } from "../foundation/utils/web_app_url_utils";
2
- import { ESP_PAGE_NAME, MODE } from "../constant/easysafepay";
3
- export function getChannelBehavior(paymentSessionMetaData) {
4
- var _paymentSessionMetaDa,
5
- _this = this;
1
+ import { getDoubleFaUrlFromSession } from "../foundation/utils/web_app_url_utils";
2
+ import { MODE } from "../constant/easysafepay";
3
+ export function getChannelBehavior(notRedirectAfterComplete, paymentSessionMetaData) {
4
+ var _paymentSessionMetaDa;
6
5
  var allowSubmitPayCallAhead = false;
7
6
  var allowClickOutsideClose = false;
8
7
  var buildSubmitPayExtParams = undefined;
@@ -21,11 +20,10 @@ export function getChannelBehavior(paymentSessionMetaData) {
21
20
  if (isTossPayment) {
22
21
  allowClickOutsideClose = false;
23
22
  buildSubmitPayExtParams = function buildSubmitPayExtParams(params) {
24
- var _this$paymentContext$;
25
23
  var callBackUrl = getDoubleFaUrl(params);
26
24
  return {
27
25
  callBackUrl: callBackUrl,
28
- notRedirectAfterComplete: ((_this$paymentContext$ = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.notRedirectAfterComplete) === true
26
+ notRedirectAfterComplete: notRedirectAfterComplete
29
27
  };
30
28
  };
31
29
  }
@@ -41,12 +39,13 @@ export function getDoubleFaUrl(params) {
41
39
  var instanceId = params.instanceId,
42
40
  paymentMethodType = params.paymentMethodType,
43
41
  paymentSessionData = params.paymentSessionData,
42
+ paymentSessionObj = params.paymentSessionObj,
44
43
  locale = params.locale,
45
44
  env = params.env,
46
45
  sdkVersion = params.sdkVersion,
47
46
  notRedirectAfterComplete = params.notRedirectAfterComplete;
48
47
  var isLandscapeOrientation = false; // Web 不含横屏
49
48
 
50
- var defaultFaBaseUrl = getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.DOUBLE_FA, env);
51
- 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) + '&' + "mode=".concat(MODE.SDK) + '&' + "&notRedirectAfterComplete=".concat(notRedirectAfterComplete);
49
+ var baseDoubleFaUrl = getDoubleFaUrlFromSession(paymentSessionObj, env);
50
+ return "".concat(baseDoubleFaUrl) + '?' + "scene=cashierResultPage" + '&' + "instanceId=".concat(instanceId) + '&' + "paymentSessionData=".concat(encodeURIComponent(paymentSessionData)) + '&' + "isLandscape=".concat(isLandscapeOrientation ? 'true' : '') + '&' + "pmt=".concat(paymentMethodType) + '&' + "locale=".concat(locale) + '&' + "sdkVersion=".concat(sdkVersion) + '&' + "mode=".concat(MODE.SDK) + '&' + "&notRedirectAfterComplete=".concat(notRedirectAfterComplete);
52
51
  }
@@ -19,8 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
19
19
  import PreloadHelper from "../../../foundation/utils/preload_helper";
20
20
  import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil, EVENT, eventCodeEnum } from "./deps";
21
21
  import { isEmpty } from "../../../util";
22
- import { getDefaultEasySafePayPageUrl } from "../../utils/web_app_url_utils";
23
- import { ESP_PAGE_NAME } from "../../../constant/easysafepay";
22
+ import { getDoubleFaUrlFromSession } from "../../utils/web_app_url_utils";
24
23
  export var EasySafePayProcessor = /*#__PURE__*/function () {
25
24
  function EasySafePayProcessor() {
26
25
  _classCallCheck(this, EasySafePayProcessor);
@@ -56,7 +55,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
56
55
  key: "startBizFlow",
57
56
  value: function () {
58
57
  var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentContext) {
59
- var _paymentContext$payme2, _this$channelBehavior;
58
+ var _paymentContext$payme2, _paymentContext$start, _this$channelBehavior;
60
59
  var _paymentContext$payme, productSceneVersion, paymentMethodCategoryType, autoDebitWithToken, requireFastSdk, authUrlInfo, isFirstTimeToPay, webAppUrl, resultPayload;
61
60
  return _regeneratorRuntime().wrap(function _callee$(_context) {
62
61
  while (1) switch (_context.prev = _context.next) {
@@ -64,9 +63,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
64
63
  // 放在最前面的逻辑
65
64
  // 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
66
65
  if (isPC()) {
67
- // 非TOSS渠道,在PC场景需要改成1.0
66
+ // 非TOSS渠道,在PC场景需要改成1.0/needAccountConfirmPage=false
68
67
  if ('BANKTRANSFER_QUICKPAY' !== ((_paymentContext$payme = paymentContext.paymentSessionObj) === null || _paymentContext$payme === void 0 || (_paymentContext$payme = _paymentContext$payme.paymentMethodInfoView) === null || _paymentContext$payme === void 0 ? void 0 : _paymentContext$payme.paymentMethodType)) {
69
68
  paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion = '1.0';
69
+ paymentContext.paymentSessionObj.needAccountConfirmPage = false;
70
70
  }
71
71
  }
72
72
  this.paymentContext = paymentContext;
@@ -76,7 +76,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
76
76
  autoDebitWithToken = paymentContext.paymentSessionObj.action.autoDebitWithToken;
77
77
  requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
78
78
  authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
79
- this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
79
+ this.channelBehavior = ChannelCustomize.getChannelBehavior(((_paymentContext$start = paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _paymentContext$start === void 0 ? void 0 : _paymentContext$start.notRedirectAfterComplete) === true, paymentContext.paymentSessionObj);
80
80
 
81
81
  // 首次支付
82
82
  isFirstTimeToPay = !autoDebitWithToken; // 处理ESP极速外跳支付场景
@@ -189,7 +189,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
189
189
 
190
190
  // 等请求和 Web启动都Ready之后,发送renderComponent
191
191
  Promise.all([this.initSecuritySDK(), this.processQuery(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
192
- var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
192
+ var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext3, _this$paymentContext$4;
193
193
  var _ref2 = _slicedToArray(_ref, 4),
194
194
  _initSecurityRes = _ref2[0],
195
195
  queryRes = _ref2[1],
@@ -207,7 +207,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
207
207
  isAppWebview: _this.paymentContext.startBizFlowOptions.isAppWebview,
208
208
  merchantAppointParam: (_this$paymentContext$3 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.merchantAppointParam,
209
209
  allowSubmitPayCallAhead: _this.allowSubmitPayCallAhead,
210
- doubleFaUrl: getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.DOUBLE_FA, _this.initConfig.environment),
210
+ doubleFaUrl: getDoubleFaUrlFromSession((_this$paymentContext3 = _this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionObj, _this.initConfig.environment),
211
211
  envInfo: {
212
212
  screenHeight: screen.height,
213
213
  screenWidth: screen.width
@@ -245,18 +245,18 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
245
245
  key: "processQuery",
246
246
  value: function () {
247
247
  var _processQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
248
- var _this$paymentContext3, _this$paymentContext4, _this$paymentContext5, _this$paymentContext$5, _this$paymentContext6, _this$paymentContext7;
248
+ var _this$paymentContext4, _this$paymentContext5, _this$paymentContext6, _this$paymentContext$5, _this$paymentContext7, _this$paymentContext8;
249
249
  var queryParams, extendInfo, needAccountConfirmPage, isFirstTimeToPay, needQueryRender, extendInfoData, requestBizId, requester, _this$paymentContext$6, res;
250
250
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
251
251
  while (1) switch (_context2.prev = _context2.next) {
252
252
  case 0:
253
253
  queryParams = {
254
- paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionId) || '',
255
- paymentSessionConfig: (_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.paymentSessionObj) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionConfig
254
+ paymentSessionData: ((_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionId) || '',
255
+ paymentSessionConfig: (_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 || (_this$paymentContext5 = _this$paymentContext5.paymentSessionObj) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.paymentSessionConfig
256
256
  };
257
- extendInfo = (_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.paymentSessionObj.extendInfo;
258
- needAccountConfirmPage = (_this$paymentContext$5 = (_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.paymentSessionObj.needAccountConfirmPage) !== null && _this$paymentContext$5 !== void 0 ? _this$paymentContext$5 : true;
259
- isFirstTimeToPay = !((_this$paymentContext7 = this.paymentContext) !== null && _this$paymentContext7 !== void 0 && (_this$paymentContext7 = _this$paymentContext7.paymentSessionObj.action) !== null && _this$paymentContext7 !== void 0 && _this$paymentContext7.autoDebitWithToken);
257
+ extendInfo = (_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.paymentSessionObj.extendInfo;
258
+ needAccountConfirmPage = (_this$paymentContext$5 = (_this$paymentContext7 = this.paymentContext) === null || _this$paymentContext7 === void 0 ? void 0 : _this$paymentContext7.paymentSessionObj.needAccountConfirmPage) !== null && _this$paymentContext$5 !== void 0 ? _this$paymentContext$5 : true;
259
+ isFirstTimeToPay = !((_this$paymentContext8 = this.paymentContext) !== null && _this$paymentContext8 !== void 0 && (_this$paymentContext8 = _this$paymentContext8.paymentSessionObj.action) !== null && _this$paymentContext8 !== void 0 && _this$paymentContext8.autoDebitWithToken);
260
260
  needQueryRender = true;
261
261
  try {
262
262
  extendInfoData = JSON.parse(extendInfo);
@@ -329,17 +329,17 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
329
329
  key: "processSubmitPay",
330
330
  value: function () {
331
331
  var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
332
- var _this$paymentContext8, _this$paymentContext9, _this$paymentContext10, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$8, _this$paymentContext11;
332
+ var _this$paymentContext9, _this$paymentContext10, _this$paymentContext11, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$8, _this$paymentContext12;
333
333
  var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$7, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, _this$paymentContext$9, res;
334
334
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
335
335
  while (1) switch (_context3.prev = _context3.next) {
336
336
  case 0:
337
337
  submitParams = {
338
- paymentSessionData: ((_this$paymentContext8 = this.paymentContext) === null || _this$paymentContext8 === void 0 ? void 0 : _this$paymentContext8.paymentSessionId) || '',
339
- paymentSessionConfig: (_this$paymentContext9 = this.paymentContext) === null || _this$paymentContext9 === void 0 || (_this$paymentContext9 = _this$paymentContext9.paymentSessionObj) === null || _this$paymentContext9 === void 0 ? void 0 : _this$paymentContext9.paymentSessionConfig
338
+ paymentSessionData: ((_this$paymentContext9 = this.paymentContext) === null || _this$paymentContext9 === void 0 ? void 0 : _this$paymentContext9.paymentSessionId) || '',
339
+ paymentSessionConfig: (_this$paymentContext10 = this.paymentContext) === null || _this$paymentContext10 === void 0 || (_this$paymentContext10 = _this$paymentContext10.paymentSessionObj) === null || _this$paymentContext10 === void 0 ? void 0 : _this$paymentContext10.paymentSessionConfig
340
340
  };
341
341
  _ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
342
- _ref4 = ((_this$paymentContext10 = this.paymentContext) === null || _this$paymentContext10 === void 0 ? void 0 : _this$paymentContext10.paymentSessionObj) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$enableS = _ref4$action2.enableSignAgreement, enableSignAgreement = _ref4$action2$enableS === void 0 ? false : _ref4$action2$enableS, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
342
+ _ref4 = ((_this$paymentContext11 = this.paymentContext) === null || _this$paymentContext11 === void 0 ? void 0 : _this$paymentContext11.paymentSessionObj) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$enableS = _ref4$action2.enableSignAgreement, enableSignAgreement = _ref4$action2$enableS === void 0 ? false : _ref4$action2$enableS, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
343
343
  if (productSceneVersion === '2.0' && !autoDebitWithToken) {
344
344
  ///EasyPay 2.0 首次传signAgreement字段
345
345
  submitParams['signAgreement'] = enableSignAgreement;
@@ -376,9 +376,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
376
376
  locale: this.initConfig.locale,
377
377
  paymentMethodType: (_this$paymentContext$8 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$8 === void 0 || (_this$paymentContext$8 = _this$paymentContext$8.paymentMethodInfoView) === null || _this$paymentContext$8 === void 0 ? void 0 : _this$paymentContext$8.paymentMethodType,
378
378
  paymentSessionData: this.paymentContext.paymentSessionId,
379
+ paymentSessionObj: this.paymentContext.paymentSessionObj,
379
380
  env: this.initConfig.environment,
380
381
  sdkVersion: this.paymentContext.sdkMetaData.sdkVersion,
381
- notRedirectAfterComplete: ((_this$paymentContext11 = this.paymentContext) === null || _this$paymentContext11 === void 0 || (_this$paymentContext11 = _this$paymentContext11.startBizFlowOptions) === null || _this$paymentContext11 === void 0 || (_this$paymentContext11 = _this$paymentContext11.submitPayRequestExtra) === null || _this$paymentContext11 === void 0 ? void 0 : _this$paymentContext11.notRedirectAfterComplete) === true
382
+ notRedirectAfterComplete: ((_this$paymentContext12 = this.paymentContext) === null || _this$paymentContext12 === void 0 || (_this$paymentContext12 = _this$paymentContext12.startBizFlowOptions) === null || _this$paymentContext12 === void 0 || (_this$paymentContext12 = _this$paymentContext12.submitPayRequestExtra) === null || _this$paymentContext12 === void 0 ? void 0 : _this$paymentContext12.notRedirectAfterComplete) === true
382
383
  })) || {}; // 二次支付不再需要该参数
383
384
  if (!autoDebitWithToken) {
384
385
  extParams.complianceSDK = true;
@@ -1,4 +1,4 @@
1
- import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
1
+ import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum, IPaymentSessionMetaData } from '../../types';
2
2
  import { SDKMetaData } from '../index';
3
3
  import { ESP_PAGE_NAME } from "../../constant/easysafepay";
4
4
  /**
@@ -77,6 +77,21 @@ export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUr
77
77
  * @param productScene - The product scene for which the checkout URL should be saved.
78
78
  */
79
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;
80
95
  /**
81
96
  * Retrieve the saved checkout URL from localStorage for the specified product scene.
82
97
  * If no url is found, a default checkout url string is returned.
@@ -91,10 +106,11 @@ export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, envir
91
106
  * @param productScene - The product scene for which the default checkout URL should be provided.
92
107
  */
93
108
  export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
94
- export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, config: WebAppUrlMatchConfig[], environment: string) => string;
95
109
  /**
96
110
  * V2应用EasySafePay 热更新兜底URL构建规则
97
111
  * 1. 兜底URL版本与sdk版本保持一致
98
112
  * 2. DEV环境下html新增版本前缀
99
113
  **/
100
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;
@@ -176,42 +176,40 @@ export var saveLocalCheckoutUrl = function saveLocalCheckoutUrl(productScene, ur
176
176
  };
177
177
 
178
178
  /**
179
- * Retrieve the saved checkout URL from localStorage for the specified product scene.
180
- * If no url is found, a default checkout url string is returned.
181
- *
182
- * @param productScene - The product scene for which the checkout URL should be retrieved.
183
- */
184
- export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene, environment) {
185
- var key = KEY_CHECKOUT_URL + productScene;
186
- var previousCheckoutUrl = localStorage.getItem(key);
187
- return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene, environment);
188
- };
189
-
190
- /**
191
- * Provide default checkout URL for the specified product scene.
192
- * Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
179
+ * 获取从外部动态下发的V2AppUrl.
193
180
  *
194
- * @param productScene - The product scene for which the default checkout URL should be provided.
181
+ * @param config - sessionData解析来的checkoutInfo列表.
195
182
  */
196
- export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
197
- var environment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "prod";
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;
198
187
  switch (productScene) {
199
188
  case ProductSceneEnum.EASY_PAY:
200
- return getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.SDK_PORTAL, environment);
189
+ return matchEasySafePayV2Url({
190
+ configs: configs,
191
+ mid: mid,
192
+ env: env,
193
+ pageName: ESP_PAGE_NAME.SDK_PORTAL
194
+ });
201
195
  default:
202
- return '';
196
+ return defaultCheckoutUrl(productScene, env);
203
197
  }
204
198
  };
205
- export var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
206
- var mid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
207
- var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
208
- var environment = arguments.length > 3 ? arguments[3] : undefined;
209
- // Default checkout url
210
- if (config.length === 0) {
211
- return defaultCheckoutUrl(productScene, environment);
212
- }
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;
213
210
  var matchURLByMid = function matchURLByMid() {
214
- var targetConfigEntry = sortedConfig.find(function (configEntry) {
211
+ var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
212
+ var targetConfigEntry = sortedConfigs.find(function (configEntry) {
215
213
  var _configEntry$mids;
216
214
  var isMatchMid = !!(configEntry !== null && configEntry !== void 0 && (_configEntry$mids = configEntry.mids) !== null && _configEntry$mids !== void 0 && _configEntry$mids.includes(mid));
217
215
  var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
@@ -219,34 +217,71 @@ export var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene)
219
217
  return configEntry;
220
218
  }
221
219
  });
222
- return targetConfigEntry === null || targetConfigEntry === void 0 ? void 0 : targetConfigEntry.url;
220
+ return targetConfigEntry;
223
221
  };
224
222
  var matchURLBySDKVersion = function matchURLBySDKVersion() {
225
- var targetConfigEntry = sortedConfig.find(function (configEntry) {
223
+ var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
224
+ var targetConfigEntry = sortedConfigs.find(function (configEntry) {
226
225
  var isCommonConfig = (configEntry === null || configEntry === void 0 ? void 0 : configEntry.mids) === undefined;
227
226
  var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
228
227
  if (isCommonConfig && isMatchVersion) {
229
228
  return configEntry;
230
229
  }
231
230
  });
232
- return targetConfigEntry === null || targetConfigEntry === void 0 ? void 0 : targetConfigEntry.url;
231
+ return targetConfigEntry;
233
232
  };
233
+ var matchConfig = function matchConfig() {
234
+ // 按SDK版本降排序
235
+ var sortedConfig = configs.sort(function (a, b) {
236
+ return compareVersion(b.minSDKVersion, a.minSDKVersion);
237
+ });
234
238
 
235
- // 按SDK版本降排序
236
- var sortedConfig = config.sort(function (a, b) {
237
- return compareVersion(b.minSDKVersion, a.minSDKVersion);
238
- });
239
+ // 匹配仅针对部分商户生效(mid),且符合版本号的URL
240
+ var matchedURLByMid = matchURLByMid(sortedConfig);
241
+ if (matchedURLByMid) return matchedURLByMid;
239
242
 
240
- // 匹配仅针对部分商户生效(mid),且符合版本号的URL
241
- var matchedURLByMid = matchURLByMid();
242
- if (matchedURLByMid) return matchedURLByMid;
243
+ // 匹配对所有商户生效(mid),且符合版本号的URL
244
+ var matchedURLBySDKVersion = matchURLBySDKVersion(sortedConfig);
245
+ if (matchedURLBySDKVersion) return matchedURLBySDKVersion;
246
+ };
247
+ var defaultEspUrl = getDefaultEasySafePayPageUrl(pageName, env);
243
248
 
244
- // 匹配对所有商户生效(无mid),且符合版本号的URL
245
- var matchedURLBySDKVersion = matchURLBySDKVersion();
246
- if (matchedURLBySDKVersion) return matchedURLBySDKVersion;
249
+ // 匹配config
250
+ var config = matchConfig();
251
+ if (!config) return defaultEspUrl;
247
252
 
248
- // Default checkout url
249
- return defaultCheckoutUrl(productScene, environment);
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
+ }
250
285
  };
251
286
 
252
287
  /**
@@ -265,4 +300,20 @@ export var getDefaultEasySafePayPageUrl = function getDefaultEasySafePayPageUrl(
265
300
  // };
266
301
  var environment = env || "prod";
267
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;
268
319
  };
@@ -11,6 +11,7 @@ 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;
@@ -14,8 +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, MODE } from "../../constant/easysafepay";
17
+ import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
18
+ import { MODE } from "../../constant/easysafepay";
19
19
  var APPLEPAYERRORENUM = /*#__PURE__*/function (APPLEPAYERRORENUM) {
20
20
  APPLEPAYERRORENUM["APPLE_PAY_MISSING_DATA"] = "APPLE_PAY_MISSING_DATA";
21
21
  APPLEPAYERRORENUM["APPLE_PAY_NOT_SUPPORTED"] = "APPLE_PAY_NOT_SUPPORTED";
@@ -68,14 +68,15 @@ export function getDoubleFaUrl(params) {
68
68
  var instanceId = params.instanceId,
69
69
  paymentMethodType = params.paymentMethodType,
70
70
  paymentSessionData = params.paymentSessionData,
71
+ paymentSessionObj = params.paymentSessionObj,
71
72
  locale = params.locale,
72
73
  env = params.env,
73
74
  sdkVersion = params.sdkVersion,
74
75
  notRedirectAfterComplete = params.notRedirectAfterComplete;
75
76
  var isLandscapeOrientation = false; // Web 不含横屏
76
77
 
77
- var defaultFaBaseUrl = getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.DOUBLE_FA, env);
78
- return "".concat(defaultFaBaseUrl) + '?' + "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);
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);
79
80
  }
80
81
  export var handleGooglePay = function handleGooglePay(data) {
81
82
  return new Promise(function (resolve, reject) {
@@ -772,6 +772,7 @@ var ComponentApp = /*#__PURE__*/function () {
772
772
  locale: _this6.AMSSDK.options.locale,
773
773
  paymentMethodType: (_this6$_renderParams$ = _this6._renderParams.paymentSessionMetaData) === null || _this6$_renderParams$ === void 0 || (_this6$_renderParams$ = _this6$_renderParams$.paymentMethodInfoView) === null || _this6$_renderParams$ === void 0 ? void 0 : _this6$_renderParams$.paymentMethodType,
774
774
  paymentSessionData: _this6._renderParams.sessionData,
775
+ paymentSessionObj: _this6._renderParams.paymentSessionMetaData,
775
776
  env: _this6.AMSSDK.options.env.environment,
776
777
  sdkVersion: _this6._appVersion,
777
778
  notRedirectAfterComplete: ((_this6$_renderParams4 = _this6._renderParams) === null || _this6$_renderParams4 === void 0 ? void 0 : _this6$_renderParams4.notRedirectAfterComplete) === true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1745808793-dev.7",
3
+ "version": "0.0.1745808793-dev.9",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",