@alipay/ams-checkout 0.0.1755258111-dev.0 → 0.0.1755258862-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 (99) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +1 -3
  3. package/esm/component/channel.js +62 -26
  4. package/esm/component/component.inline.style.js +2 -2
  5. package/esm/component/popupWindow.style.d.ts +1 -4
  6. package/esm/component/popupWindow.style.js +2 -37
  7. package/esm/config/index.d.ts +8 -8
  8. package/esm/config/index.js +8 -8
  9. package/esm/constant/index.d.ts +2 -41
  10. package/esm/constant/index.js +5 -43
  11. package/esm/core/component/ckp/index.d.ts +0 -2
  12. package/esm/core/component/ckp/index.js +5 -41
  13. package/esm/core/component/element/index.d.ts +46 -7
  14. package/esm/core/component/element/index.js +923 -31
  15. package/esm/core/component/element/mock.d.ts +0 -4
  16. package/esm/core/component/element/mock.js +1 -365
  17. package/esm/core/component/element/type.d.ts +34 -74
  18. package/esm/core/component/element/type.js +12 -20
  19. package/esm/core/component/index.d.ts +1 -5
  20. package/esm/core/component/index.js +2 -1
  21. package/esm/core/instance/index.d.ts +1 -1
  22. package/esm/core/instance/index.js +1 -1
  23. package/esm/foundation/core/index.d.ts +1 -9
  24. package/esm/foundation/core/index.js +49 -153
  25. package/esm/foundation/index.d.ts +0 -20
  26. package/esm/foundation/index.js +2 -13
  27. package/esm/foundation/product-processor/easysafepay/deps.d.ts +1 -3
  28. package/esm/foundation/product-processor/easysafepay/deps.js +1 -3
  29. package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -5
  30. package/esm/foundation/product-processor/easysafepay/index.js +138 -266
  31. package/esm/foundation/service/container/index.d.ts +3 -14
  32. package/esm/foundation/service/container/index.js +25 -178
  33. package/esm/foundation/service/container/popup.d.ts +7 -10
  34. package/esm/foundation/service/container/popup.js +1 -3
  35. package/esm/foundation/service/event-center.js +0 -1
  36. package/esm/foundation/service/log/keys.js +1 -3
  37. package/esm/foundation/service/log/types.d.ts +0 -1
  38. package/esm/foundation/service/requester/requester.js +37 -17
  39. package/esm/foundation/utils/preload_helper.d.ts +2 -2
  40. package/esm/foundation/utils/preload_helper.js +4 -8
  41. package/esm/foundation/utils/redirect_utils.js +18 -34
  42. package/esm/foundation/utils/web_app_url_utils.d.ts +1 -71
  43. package/esm/foundation/utils/web_app_url_utils.js +8 -219
  44. package/esm/index.d.ts +4 -7
  45. package/esm/index.js +48 -98
  46. package/esm/plugin/component/cashierApp.d.ts +1 -1
  47. package/esm/plugin/component/cashierApp.js +5 -5
  48. package/esm/plugin/component/channel.d.ts +1 -3
  49. package/esm/plugin/component/channel.js +12 -10
  50. package/esm/plugin/component/index.js +44 -47
  51. package/esm/plugin/type.d.ts +1 -1
  52. package/esm/request/index.js +2 -2
  53. package/esm/types/index.d.ts +3 -37
  54. package/esm/types/index.js +2 -10
  55. package/esm/util/index.d.ts +1 -8
  56. package/esm/util/index.js +3 -31
  57. package/esm/util/spm-map.d.ts +4 -18
  58. package/esm/util/spm-map.js +6 -20
  59. package/package.json +4 -27
  60. package/esm/constant/easysafepay.d.ts +0 -16
  61. package/esm/constant/easysafepay.js +0 -19
  62. package/esm/core/component/element/elementContainerService/containerService.d.ts +0 -33
  63. package/esm/core/component/element/elementContainerService/containerService.js +0 -123
  64. package/esm/core/component/element/elementContainerService/index.d.ts +0 -20
  65. package/esm/core/component/element/elementContainerService/index.js +0 -63
  66. package/esm/core/component/element/elementController/index.d.ts +0 -27
  67. package/esm/core/component/element/elementController/index.js +0 -493
  68. package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +0 -20
  69. package/esm/core/component/element/elementProcessor/addressProcessor.js +0 -160
  70. package/esm/core/component/element/elementProcessor/authProcessor.d.ts +0 -20
  71. package/esm/core/component/element/elementProcessor/authProcessor.js +0 -125
  72. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +0 -41
  73. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +0 -96
  74. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +0 -20
  75. package/esm/core/component/element/elementProcessor/paymentProcessor.js +0 -380
  76. package/esm/core/component/element/util.d.ts +0 -69
  77. package/esm/core/component/element/util.js +0 -477
  78. package/esm/core/component/oldElement/index.d.ts +0 -59
  79. package/esm/core/component/oldElement/index.js +0 -956
  80. package/esm/core/component/oldElement/mock.d.ts +0 -6
  81. package/esm/core/component/oldElement/mock.js +0 -567
  82. package/esm/core/component/oldElement/type.d.ts +0 -354
  83. package/esm/core/component/oldElement/type.js +0 -81
  84. package/esm/foundation/product-processor/autoDebit/deps.d.ts +0 -14
  85. package/esm/foundation/product-processor/autoDebit/deps.js +0 -12
  86. package/esm/foundation/product-processor/autoDebit/index.d.ts +0 -48
  87. package/esm/foundation/product-processor/autoDebit/index.js +0 -466
  88. package/esm/foundation/product-processor/element/index.d.ts +0 -7
  89. package/esm/foundation/product-processor/element/index.js +0 -24
  90. package/esm/util/redirect.d.ts +0 -6
  91. package/esm/util/redirect.js +0 -54
  92. /package/esm/core/component/{oldElement → element}/components/address.d.ts +0 -0
  93. /package/esm/core/component/{oldElement → element}/components/address.js +0 -0
  94. /package/esm/core/component/{oldElement → element}/components/auth.d.ts +0 -0
  95. /package/esm/core/component/{oldElement → element}/components/auth.js +0 -0
  96. /package/esm/core/component/{oldElement → element}/components/payment.d.ts +0 -0
  97. /package/esm/core/component/{oldElement → element}/components/payment.js +0 -0
  98. /package/esm/core/component/{oldElement → element}/utils.d.ts +0 -0
  99. /package/esm/core/component/{oldElement → element}/utils.js +0 -0
@@ -69,42 +69,26 @@ export var redirect = function redirect(payload, instanceId) {
69
69
  successCallback(payload, type, evokeAppBy.url, serviceProvider);
70
70
  }
71
71
  });
72
- var callApplinkUrl = function callApplinkUrl() {
73
- try {
74
- callAppLib.open({
75
- link: payload.applinkUrl,
76
- fallback: function fallback() {
77
- failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
78
- // Applink evoke failed, try to use scheme url
79
- callSchemeUrl();
80
- }
81
- });
82
- } catch (error) {
83
- failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
84
- // Applink evoke failed, try to use scheme url
85
- callSchemeUrl();
86
- }
87
- };
88
72
  var callSchemeUrl = function callSchemeUrl() {
89
- try {
90
- callAppLib.open({
91
- scheme: payload.schemeUrl,
92
- fallback: function fallback() {
93
- failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
94
- if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
95
- successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
96
- window.location.href = payload.url;
97
- }
98
- });
99
- } catch (error) {
100
- failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
101
- if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
102
- successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
103
- window.location.href = payload.url;
104
- }
73
+ callAppLib.open({
74
+ scheme: payload.schemeUrl,
75
+ fallback: function fallback() {
76
+ failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
77
+ if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
78
+ successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
79
+ window.location.href = payload.url;
80
+ }
81
+ });
105
82
  };
106
83
  if (payload.applinkUrl) {
107
- callApplinkUrl();
84
+ callAppLib.open({
85
+ link: payload.applinkUrl,
86
+ fallback: function fallback() {
87
+ failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
88
+ // Applink evoke failed, try to use scheme url
89
+ callSchemeUrl();
90
+ }
91
+ });
108
92
  } else if (payload.schemeUrl) {
109
93
  callSchemeUrl();
110
94
  }
@@ -132,7 +116,7 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
132
116
  };
133
117
  var failCallback = function failCallback(payload, type, url, serviceProvider) {
134
118
  serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
135
- code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
119
+ code: eventCodeEnum.SDK_CALL_URL_ERROR,
136
120
  message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
137
121
  });
138
122
  serviceProvider.getService('Log').logInfo({
@@ -1,5 +1,4 @@
1
- import { ESP_PAGE_NAME } from '../../constant/easysafepay';
2
- import { DisplayTypeEnum, IPaymentSessionMetaData, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
1
+ import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from '../../types';
3
2
  import { SDKMetaData } from '../index';
4
3
  /**
5
4
  * Tell the SDK which version of the Web App to load.
@@ -17,16 +16,6 @@ export interface WebAppMatchConfig {
17
16
  mid?: string;
18
17
  greyscale?: string;
19
18
  }
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
- }
30
19
  export interface QueryParams {
31
20
  displayType: DisplayTypeEnum;
32
21
  locale: string;
@@ -38,79 +27,20 @@ export interface QueryParams {
38
27
  export declare const getWebAppUrlInfo: (params: {
39
28
  environment: string;
40
29
  sdkMetaData: SDKMetaData;
41
- productScene: ProductSceneEnum;
42
30
  productSceneVersion: string;
43
31
  paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
44
32
  isPreload?: boolean;
45
33
  query: QueryParams;
46
- v2Url?: string;
47
34
  }) => {
48
35
  path: string;
49
36
  locationSearch: string;
50
37
  };
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;
62
38
  export declare const getWebAppUrl: (params: {
63
39
  environment: string;
64
40
  sdkMetaData: SDKMetaData;
65
- productScene: ProductSceneEnum;
66
41
  productSceneVersion: string;
67
42
  paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
68
43
  isPreload?: boolean;
69
44
  query: QueryParams;
70
- v2Url?: string;
71
45
  }) => string;
72
46
  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,36 +1,25 @@
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; }
4
2
  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; }
5
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
4
  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
- import { marmotMap, sdkVersion, v2AppMarmotMap } from "../../config";
8
- import { ESP_PAGE_NAME } from "../../constant/easysafepay";
9
- import { ComponentSignEnum, ProductSceneEnum } from "../../types";
5
+ import { ComponentSignEnum } from "../../types";
6
+ import { marmotMap } from "../../config";
10
7
  import { queryParse, serialize } from "../../util";
11
8
  import { isDebugLog } from "../../util/debug";
12
- import { compareVersion } from "../../util/versionCompare";
13
9
 
14
10
  /**
15
11
  * Tell the SDK which version of the Web App to load.
16
12
  * Sent by server inside paymentSession.
17
13
  */
18
14
 
19
- /**
20
- * Tell the SDK which Web App URL to load.
21
- * Sent by server inside paymentSession.
22
- */
23
-
24
15
  export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
25
16
  var environment = params.environment,
26
17
  sdkMetaData = params.sdkMetaData,
27
- productScene = params.productScene,
28
18
  productSceneVersion = params.productSceneVersion,
29
19
  paymentMethodCategoryType = params.paymentMethodCategoryType,
30
20
  query = params.query,
31
- isPreload = params.isPreload,
32
- v2Url = params.v2Url;
33
- var path = getAppPath(environment, sdkMetaData, productScene, productSceneVersion, paymentMethodCategoryType, v2Url);
21
+ isPreload = params.isPreload;
22
+ var path = getAppPath(environment, sdkMetaData, productSceneVersion, paymentMethodCategoryType);
34
23
  var _queryParse = queryParse(),
35
24
  _sandbox = _queryParse._sandbox,
36
25
  _light_sandbox = _queryParse._light_sandbox,
@@ -68,30 +57,6 @@ export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
68
57
  locationSearch: locationSearch
69
58
  };
70
59
  };
71
- export var getWebAppV2Url = function getWebAppV2Url(params) {
72
- var productScene = params.productScene,
73
- isPreload = params.isPreload,
74
- mid = params.mid,
75
- extendInfo = params.extendInfo,
76
- environment = params.environment;
77
- var webAppUrlMatchConfig = parseWebAppUrlMatchConfig(extendInfo);
78
- var v2Url = isPreload ? getLocalCheckoutUrl(productScene, environment) : getMatchedWebAppV2Url(productScene, mid, webAppUrlMatchConfig, environment);
79
- var info = getWebAppUrlInfo(_objectSpread(_objectSpread({}, params), {}, {
80
- v2Url: v2Url
81
- }));
82
- if (!isPreload && v2Url && info.path) {
83
- console.log('[web-sdk] save web app, url: ', info.path);
84
- saveLocalCheckoutUrl(productScene, info.path);
85
- }
86
- var webAppUrl;
87
- if (info.path.indexOf('?') !== -1) {
88
- webAppUrl = "".concat(info.path, "&").concat(info.locationSearch);
89
- } else {
90
- webAppUrl = "".concat(info.path, "?").concat(info.locationSearch);
91
- }
92
- console.log('[web-sdk] web app, url: ', webAppUrl);
93
- return webAppUrl;
94
- };
95
60
  export var getWebAppUrl = function getWebAppUrl(params) {
96
61
  var info = getWebAppUrlInfo(params);
97
62
  var webAppUrl;
@@ -105,10 +70,8 @@ export var getWebAppUrl = function getWebAppUrl(params) {
105
70
  var getAppPath = function getAppPath() {
106
71
  var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
107
72
  var sdkMetaData = arguments.length > 1 ? arguments[1] : undefined;
108
- var productScene = arguments.length > 2 ? arguments[2] : undefined;
109
- var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
110
- var paymentMethodCategoryType = arguments.length > 4 ? arguments[4] : undefined;
111
- var v2Url = arguments.length > 5 ? arguments[5] : undefined;
73
+ var productSceneVersion = arguments.length > 2 ? arguments[2] : undefined;
74
+ var paymentMethodCategoryType = arguments.length > 3 ? arguments[3] : undefined;
112
75
  var _ref = queryParse() || {},
113
76
  urlTestHost = _ref.host;
114
77
  // only for test while testurl?host=https://xxxxx.test.html
@@ -118,15 +81,7 @@ var getAppPath = function getAppPath() {
118
81
  var validProductSceneVersion = getValidProductSceneVersion(sdkMetaData.productScene, productSceneVersion, paymentMethodCategoryType);
119
82
  var productSceneWithPaymentMethodCategoryType = "".concat(sdkMetaData.productScene, "_").concat(paymentMethodCategoryType);
120
83
  var webAppVersion = sdkMetaData.webAppVersion;
121
- if (productSceneWithPaymentMethodCategoryType === ComponentSignEnum.AUTO_DEBIT_APM) {
122
- return "".concat(v2AppMarmotMap[environment], "/auto-debit/").concat(webAppVersion, "/pages/trustly/index.html");
123
- }
124
- switch (productScene) {
125
- case ProductSceneEnum.EASY_PAY:
126
- return v2Url !== null && v2Url !== void 0 ? v2Url : defaultCheckoutUrl(productScene, environment);
127
- default:
128
- return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
129
- }
84
+ return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
130
85
  };
131
86
  export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo) {
132
87
  if (!extendInfo) {
@@ -141,21 +96,9 @@ export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo)
141
96
  return [];
142
97
  }
143
98
  };
144
- export var parseWebAppUrlMatchConfig = function parseWebAppUrlMatchConfig(extendInfo) {
145
- if (!extendInfo) {
146
- return [];
147
- }
148
- try {
149
- var extendInfoJson = JSON.parse(extendInfo);
150
- return extendInfoJson === null || extendInfoJson === void 0 ? void 0 : extendInfoJson.checkoutInfo;
151
- } catch (error) {
152
- console.error('Parse the url config for Web app failed#', error);
153
- return [];
154
- }
155
- };
156
99
  var getValidProductSceneVersion = function getValidProductSceneVersion(productScene, productSceneVer, paymentMethodCategoryType) {
157
100
  var _supportMapping;
158
- 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(_defineProperty(_supportMapping, ComponentSignEnum.ELEMENT_ADDRESS, ['1.0']), ComponentSignEnum.CHECKOUT_PAYMENT, ['1.0']), ComponentSignEnum.AUTO_DEBIT_APM, ['1.0']));
101
+ 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']));
159
102
  var targetVersions = supportMapping[productScene + '_' + paymentMethodCategoryType];
160
103
  if (!targetVersions) {
161
104
  return '';
@@ -166,158 +109,4 @@ var getValidProductSceneVersion = function getValidProductSceneVersion(productSc
166
109
  });
167
110
  var latestVersion = targetVersions[targetVersions.length - 1];
168
111
  return isSupport ? productSceneVer : latestVersion;
169
- };
170
- var KEY_CHECKOUT_URL = "web_url_";
171
-
172
- /**
173
- * Save the current checkout URL to localStorage for the specified product scene.
174
- *
175
- * @param productScene - The product scene for which the checkout URL should be saved.
176
- */
177
- export var saveLocalCheckoutUrl = function saveLocalCheckoutUrl(productScene, url) {
178
- var key = KEY_CHECKOUT_URL + productScene;
179
- localStorage.setItem(key, url);
180
- };
181
-
182
- /**
183
- * 获取从外部动态下发的V2AppUrl.
184
- *
185
- * @param config - sessionData解析来的checkoutInfo列表.
186
- */
187
- export var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
188
- var mid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
189
- var configs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
190
- var env = arguments.length > 3 ? arguments[3] : undefined;
191
- switch (productScene) {
192
- case ProductSceneEnum.EASY_PAY:
193
- return matchEasySafePayV2Url({
194
- configs: configs,
195
- mid: mid,
196
- env: env,
197
- pageName: ESP_PAGE_NAME.SDK_PORTAL
198
- });
199
- default:
200
- return defaultCheckoutUrl(productScene, env);
201
- }
202
- };
203
-
204
- /**
205
- * 获取ESP从sessionData.checkoutInfo内动态下发的Url.
206
- */
207
- export var matchEasySafePayV2Url = function matchEasySafePayV2Url(params) {
208
- var _params$configs = params.configs,
209
- configs = _params$configs === void 0 ? [] : _params$configs,
210
- _params$mid = params.mid,
211
- mid = _params$mid === void 0 ? '' : _params$mid,
212
- env = params.env,
213
- pageName = params.pageName;
214
- var matchURLByMid = function matchURLByMid() {
215
- var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
216
- var targetConfigEntry = sortedConfigs.find(function (configEntry) {
217
- var _configEntry$mids;
218
- var isMatchMid = !!(configEntry !== null && configEntry !== void 0 && (_configEntry$mids = configEntry.mids) !== null && _configEntry$mids !== void 0 && _configEntry$mids.includes(mid));
219
- var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
220
- if (isMatchMid && isMatchVersion) {
221
- return configEntry;
222
- }
223
- });
224
- return targetConfigEntry;
225
- };
226
- var matchURLBySDKVersion = function matchURLBySDKVersion() {
227
- var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
228
- var targetConfigEntry = sortedConfigs.find(function (configEntry) {
229
- var isCommonConfig = (configEntry === null || configEntry === void 0 ? void 0 : configEntry.mids) === undefined;
230
- var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
231
- if (isCommonConfig && isMatchVersion) {
232
- return configEntry;
233
- }
234
- });
235
- return targetConfigEntry;
236
- };
237
- var matchConfig = function matchConfig() {
238
- // 按SDK版本降排序
239
- var sortedConfig = configs.sort(function (a, b) {
240
- return compareVersion(b.minSDKVersion, a.minSDKVersion);
241
- });
242
-
243
- // 匹配仅针对部分商户生效(mid),且符合版本号的URL
244
- var matchedURLByMid = matchURLByMid(sortedConfig);
245
- if (matchedURLByMid) return matchedURLByMid;
246
-
247
- // 匹配对所有商户生效(无mid),且符合版本号的URL
248
- var matchedURLBySDKVersion = matchURLBySDKVersion(sortedConfig);
249
- if (matchedURLBySDKVersion) return matchedURLBySDKVersion;
250
- };
251
- var defaultEspUrl = getDefaultEasySafePayPageUrl(pageName, env);
252
-
253
- // 匹配config
254
- var config = matchConfig();
255
- if (!config) return defaultEspUrl;
256
-
257
- // 根据pageName匹配URL
258
- if (pageName === ESP_PAGE_NAME.SDK_PORTAL) return (config === null || config === void 0 ? void 0 : config.url) || defaultEspUrl;
259
- if (pageName === ESP_PAGE_NAME.DOUBLE_FA) return (config === null || config === void 0 ? void 0 : config.doubleFa) || defaultEspUrl;
260
- return defaultEspUrl;
261
- };
262
-
263
- /**
264
- * Retrieve the saved checkout URL from localStorage for the specified product scene.
265
- * If no url is found, a default checkout url string is returned.
266
- *
267
- * @param productScene - The product scene for which the checkout URL should be retrieved.
268
- */
269
- export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene, environment) {
270
- var key = KEY_CHECKOUT_URL + productScene;
271
- var previousCheckoutUrl = localStorage.getItem(key);
272
- return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene, environment);
273
- };
274
-
275
- /**
276
- * Provide default checkout URL for the specified product scene.
277
- * Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
278
- *
279
- * @param productScene - The product scene for which the default checkout URL should be provided.
280
- */
281
- export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
282
- var environment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'prod';
283
- switch (productScene) {
284
- case ProductSceneEnum.EASY_PAY:
285
- return getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.SDK_PORTAL, environment);
286
- default:
287
- return '';
288
- }
289
- };
290
-
291
- /**
292
- * V2应用EasySafePay 热更新兜底URL构建规则
293
- * 1. 兜底URL版本与sdk版本保持一致
294
- * 2. DEV环境下html新增版本前缀
295
- **/
296
- export var getDefaultEasySafePayPageUrl = function getDefaultEasySafePayPageUrl(pageName, env) {
297
- // 生成的URL EXAMPLE:
298
- // const DEFAULT_DOUBLE_FA_URL_MAPPING = {
299
- // local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
300
- // dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
301
- // sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
302
- // pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
303
- // prod: 'https://checkout.antom.com/easysafepay/1.36.0/pages/double-fa/index.html',
304
- // };
305
- var environment = env || 'prod';
306
- 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");
307
- };
308
-
309
- /**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
310
- //TODO 后续需要构造一个类,专门用于构造&存储web应用url
311
- export var getDoubleFaUrlFromSession = function getDoubleFaUrlFromSession(paymentSessionObj) {
312
- var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'prod';
313
- var mid = paymentSessionObj.clientId;
314
- var extendInfo = paymentSessionObj.extendInfo;
315
- var configs = parseWebAppUrlMatchConfig(extendInfo);
316
- var url = matchEasySafePayV2Url({
317
- configs: configs,
318
- mid: mid,
319
- env: env,
320
- pageName: ESP_PAGE_NAME.DOUBLE_FA
321
- });
322
- return url;
323
112
  };
package/esm/index.d.ts CHANGED
@@ -7,6 +7,10 @@ export * from './types';
7
7
  export declare class AMSCheckout extends AMSComponent {
8
8
  constructor(_options: IoptionsParams, channelType?: ComponentSignEnum[], productSceneVersion?: string);
9
9
  }
10
+ export declare class AMSAutoDebit extends AMSCheckout {
11
+ constructor(options: IoptionsParams);
12
+ static preload(options?: IPreloadOptions): void;
13
+ }
10
14
  export declare class AMSAutoDebitPay extends AMSCheckout {
11
15
  constructor(options: IoptionsParams);
12
16
  static preload(options?: IPreloadOptions): void;
@@ -35,11 +39,4 @@ export declare class AMSEasyPay {
35
39
  createComponent(params: IcreateComponent): void;
36
40
  unmount(): void;
37
41
  }
38
- export declare class AMSAutoDebit {
39
- private core;
40
- constructor(options: IoptionsParams);
41
- createComponent(params: IcreateComponent): Promise<void>;
42
- unmount(): void;
43
- static preload(options?: IPreloadOptions): void;
44
- }
45
42
  export default AMSCheckout;