@alipay/ams-checkout 0.0.1746674797-dev.0 → 0.0.1746701898-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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.js +5 -5
- package/esm/config/index.d.ts +1 -1
- package/esm/config/index.js +1 -1
- package/esm/constant/index.d.ts +0 -3
- package/esm/constant/index.js +0 -3
- package/esm/foundation/core/index.js +25 -48
- package/esm/foundation/product-processor/easysafepay/index.js +5 -11
- package/esm/foundation/utils/preload_helper.d.ts +2 -2
- package/esm/foundation/utils/preload_helper.js +4 -8
- package/esm/foundation/utils/web_app_url_utils.d.ts +1 -46
- package/esm/foundation/utils/web_app_url_utils.js +7 -129
- package/esm/index.js +1 -1
- package/esm/plugin/component/cashierApp.js +4 -4
- package/esm/plugin/component/channel.js +5 -5
- package/package.json +1 -1
package/esm/component/channel.js
CHANGED
@@ -76,11 +76,11 @@ export function getDoubleFaUrl(params) {
|
|
76
76
|
var isLandscapeOrientation = false; // Web 不含横屏
|
77
77
|
|
78
78
|
var DOUBLE_FA_URL_MAPPING = {
|
79
|
-
local:
|
80
|
-
dev:
|
81
|
-
sit:
|
82
|
-
pre:
|
83
|
-
prod:
|
79
|
+
local: "http://page.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
80
|
+
dev: "http://page.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
81
|
+
sit: "http://page.test.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
82
|
+
pre: "https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
83
|
+
prod: "https://ac.alipay.com/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html")
|
84
84
|
};
|
85
85
|
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
86
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);
|
package/esm/config/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export declare const marmotMap: Record<string, string>;
|
2
2
|
export declare const marmotConfigMap: Record<string, string>;
|
3
|
-
export declare const
|
3
|
+
export declare const elementAppMarmotMap: Record<string, string>;
|
4
4
|
export declare const sdkVersion: string;
|
5
5
|
/**
|
6
6
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
package/esm/config/index.js
CHANGED
@@ -22,7 +22,7 @@ export var marmotConfigMap = {
|
|
22
22
|
light_sandbox: 'https://config.marmot-cloud.com/config/data/antom-sdk-config/en_US.json',
|
23
23
|
prod: 'https://config.marmot-cloud.com/config/data/antom-sdk-config/en_US.json'
|
24
24
|
};
|
25
|
-
export var
|
25
|
+
export var elementAppMarmotMap = {
|
26
26
|
dev: 'http://page.alipay.net/page/antom-web-checkout-v2',
|
27
27
|
sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2',
|
28
28
|
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2',
|
package/esm/constant/index.d.ts
CHANGED
@@ -219,9 +219,6 @@ export declare const EVENT: {
|
|
219
219
|
showToast: {
|
220
220
|
name: string;
|
221
221
|
};
|
222
|
-
getSdkVersion: {
|
223
|
-
name: string;
|
224
|
-
};
|
225
222
|
};
|
226
223
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
227
224
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -178,29 +178,6 @@ export var AntomSDKCore = /*#__PURE__*/function () {
|
|
178
178
|
return _ref2.apply(this, arguments);
|
179
179
|
};
|
180
180
|
}());
|
181
|
-
eventCenter.listen(EVENT.getSdkVersion.name, /*#__PURE__*/function () {
|
182
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data, payload) {
|
183
|
-
var _payload$context3;
|
184
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
185
|
-
while (1) switch (_context3.prev = _context3.next) {
|
186
|
-
case 0:
|
187
|
-
eventCenter.dispatchToApp({
|
188
|
-
event: 'appEventCallback',
|
189
|
-
eventCallbackId: (_payload$context3 = payload.context) === null || _payload$context3 === void 0 ? void 0 : _payload$context3.eventCallbackId,
|
190
|
-
data: {
|
191
|
-
version: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.sdkVersion
|
192
|
-
}
|
193
|
-
});
|
194
|
-
case 1:
|
195
|
-
case "end":
|
196
|
-
return _context3.stop();
|
197
|
-
}
|
198
|
-
}, _callee3);
|
199
|
-
}));
|
200
|
-
return function (_x5, _x6) {
|
201
|
-
return _ref3.apply(this, arguments);
|
202
|
-
};
|
203
|
-
}());
|
204
181
|
eventCenter.listen(EVENT.destroy.name, function (data) {
|
205
182
|
_this.setStatus(IElementStatus.READY);
|
206
183
|
_this.destroy();
|
@@ -231,14 +208,14 @@ export var AntomSDKCore = /*#__PURE__*/function () {
|
|
231
208
|
}, {
|
232
209
|
key: "startBizFlow",
|
233
210
|
value: function () {
|
234
|
-
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
211
|
+
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options) {
|
235
212
|
var _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3;
|
236
213
|
var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
|
237
|
-
return _regeneratorRuntime().wrap(function
|
238
|
-
while (1) switch (
|
214
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
215
|
+
while (1) switch (_context3.prev = _context3.next) {
|
239
216
|
case 0:
|
240
217
|
if (!(!options || !options.paymentSession)) {
|
241
|
-
|
218
|
+
_context3.next = 2;
|
242
219
|
break;
|
243
220
|
}
|
244
221
|
throw new Error('paymentSession is empty');
|
@@ -268,61 +245,61 @@ export var AntomSDKCore = /*#__PURE__*/function () {
|
|
268
245
|
// Invoke processor
|
269
246
|
productScene = (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentSessionConfig) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.productScene;
|
270
247
|
paymentMethod = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentMethodInfoView) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.paymentMethodType;
|
271
|
-
|
248
|
+
_context3.prev = 14;
|
272
249
|
if (!this.productProcessors["".concat(productScene, "|").concat(paymentMethod)]) {
|
273
|
-
|
250
|
+
_context3.next = 21;
|
274
251
|
break;
|
275
252
|
}
|
276
|
-
|
253
|
+
_context3.next = 18;
|
277
254
|
return this.productProcessors["".concat(productScene, "|").concat(paymentMethod)].startBizFlow(this.paymentContext);
|
278
255
|
case 18:
|
279
|
-
this.bizFlowStartBehavior =
|
280
|
-
|
256
|
+
this.bizFlowStartBehavior = _context3.sent;
|
257
|
+
_context3.next = 25;
|
281
258
|
break;
|
282
259
|
case 21:
|
283
260
|
if (!this.productProcessors["".concat(productScene)]) {
|
284
|
-
|
261
|
+
_context3.next = 25;
|
285
262
|
break;
|
286
263
|
}
|
287
|
-
|
264
|
+
_context3.next = 24;
|
288
265
|
return this.productProcessors["".concat(productScene)].startBizFlow(this.paymentContext);
|
289
266
|
case 24:
|
290
|
-
this.bizFlowStartBehavior =
|
267
|
+
this.bizFlowStartBehavior = _context3.sent;
|
291
268
|
case 25:
|
292
|
-
|
269
|
+
_context3.next = 30;
|
293
270
|
break;
|
294
271
|
case 27:
|
295
|
-
|
296
|
-
|
297
|
-
console.error('Invoke processor failed',
|
272
|
+
_context3.prev = 27;
|
273
|
+
_context3.t0 = _context3["catch"](14);
|
274
|
+
console.error('Invoke processor failed', _context3.t0);
|
298
275
|
case 30:
|
299
276
|
if (!(!this.bizFlowStartBehavior || this.bizFlowStartBehavior.behaviorType === 'NONE' || !this.bizFlowStartBehavior.payload)) {
|
300
|
-
|
277
|
+
_context3.next = 32;
|
301
278
|
break;
|
302
279
|
}
|
303
|
-
return
|
280
|
+
return _context3.abrupt("return");
|
304
281
|
case 32:
|
305
282
|
if (!(this.bizFlowStartBehavior.behaviorType === 'RENDER')) {
|
306
|
-
|
283
|
+
_context3.next = 35;
|
307
284
|
break;
|
308
285
|
}
|
309
286
|
this.handleBehaviorRender();
|
310
|
-
return
|
287
|
+
return _context3.abrupt("return");
|
311
288
|
case 35:
|
312
289
|
if (!(this.bizFlowStartBehavior.behaviorType === 'REDIRECT')) {
|
313
|
-
|
290
|
+
_context3.next = 39;
|
314
291
|
break;
|
315
292
|
}
|
316
293
|
payload = (_this$bizFlowStartBeh = this.bizFlowStartBehavior) === null || _this$bizFlowStartBeh === void 0 ? void 0 : _this$bizFlowStartBeh.payload;
|
317
294
|
redirect(payload, this.instanceId);
|
318
|
-
return
|
295
|
+
return _context3.abrupt("return");
|
319
296
|
case 39:
|
320
297
|
case "end":
|
321
|
-
return
|
298
|
+
return _context3.stop();
|
322
299
|
}
|
323
|
-
},
|
300
|
+
}, _callee3, this, [[14, 27]]);
|
324
301
|
}));
|
325
|
-
function startBizFlow(
|
302
|
+
function startBizFlow(_x5) {
|
326
303
|
return _startBizFlow.apply(this, arguments);
|
327
304
|
}
|
328
305
|
return startBizFlow;
|
@@ -46,7 +46,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
46
46
|
this.eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
47
47
|
|
48
48
|
// preload web app
|
49
|
-
PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, this.initConfig.environment
|
49
|
+
PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, this.initConfig.environment);
|
50
50
|
}
|
51
51
|
}, {
|
52
52
|
key: "startBizFlow",
|
@@ -113,19 +113,15 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
113
113
|
}, {
|
114
114
|
key: "buildWebAppUrl",
|
115
115
|
value: function buildWebAppUrl() {
|
116
|
-
var _paymentContext$payme3, _paymentContext$payme4,
|
116
|
+
var _paymentContext$payme3, _paymentContext$payme4, _this$initConfig$anal;
|
117
117
|
var paymentContext = this.paymentContext;
|
118
118
|
var paymentMethodCategoryType = (_paymentContext$payme3 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme3 === void 0 ? void 0 : _paymentContext$payme3.paymentMethodCategoryType;
|
119
|
-
var
|
120
|
-
var productSceneVersion = (_paymentContext$payme5 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme5 === void 0 ? void 0 : _paymentContext$payme5.productSceneVersion;
|
119
|
+
var productSceneVersion = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productSceneVersion;
|
121
120
|
var hostSign = this.hostSign;
|
122
|
-
var
|
123
|
-
var extendInfo = paymentContext.paymentSessionObj.extendInfo;
|
124
|
-
var webAppUrl = WebAppUrlUtil.getWebAppV2Url({
|
121
|
+
var webAppUrl = WebAppUrlUtil.getWebAppUrl({
|
125
122
|
environment: this.initConfig.environment,
|
126
123
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
127
124
|
sdkMetaData: paymentContext.sdkMetaData,
|
128
|
-
productScene: productScene,
|
129
125
|
productSceneVersion: productSceneVersion,
|
130
126
|
isPreload: false,
|
131
127
|
query: {
|
@@ -134,9 +130,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
134
130
|
instanceId: this.instanceId,
|
135
131
|
locale: this.initConfig.locale,
|
136
132
|
hostSign: hostSign
|
137
|
-
}
|
138
|
-
mid: mid,
|
139
|
-
extendInfo: extendInfo
|
133
|
+
}
|
140
134
|
});
|
141
135
|
return webAppUrl;
|
142
136
|
}
|
@@ -4,10 +4,10 @@ export default class PreloadHelper {
|
|
4
4
|
static isWebAppPreloaded: boolean;
|
5
5
|
static isSecuritySDKPreloaded: boolean;
|
6
6
|
private static securitySdkMap;
|
7
|
-
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string
|
7
|
+
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
|
8
8
|
static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
|
9
9
|
static getSecuritySdk(scene: any): Security;
|
10
|
-
static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string
|
10
|
+
static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
|
11
11
|
preloadUrl: string;
|
12
12
|
containerId: string;
|
13
13
|
};
|
@@ -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
|
11
|
+
import { getWebAppUrl } 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,13 +22,12 @@ 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;
|
26
25
|
try {
|
27
26
|
if (this.isWebAppPreloaded) {
|
28
27
|
console.log('[web-sdk] web app already preloaded');
|
29
28
|
return;
|
30
29
|
}
|
31
|
-
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment
|
30
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
|
32
31
|
preloadUrl = _this$buildWebAppPrel.preloadUrl,
|
33
32
|
containerId = _this$buildWebAppPrel.containerId;
|
34
33
|
var preloadIframe = createPreloadIframe(containerId);
|
@@ -90,7 +89,6 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
90
89
|
}, {
|
91
90
|
key: "buildWebAppPreloadUrl",
|
92
91
|
value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
|
93
|
-
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
94
92
|
var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
|
95
93
|
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
|
96
94
|
if (previousProductInfo) {
|
@@ -103,16 +101,14 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
103
101
|
webAppVersion: ''
|
104
102
|
};
|
105
103
|
sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
|
106
|
-
var
|
104
|
+
var preloadUrl = getWebAppUrl({
|
107
105
|
environment: environment,
|
108
106
|
sdkMetaData: sdkMetaData,
|
109
107
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
110
108
|
isPreload: true,
|
111
|
-
productScene: productScene,
|
112
109
|
productSceneVersion: productSceneVersion,
|
113
110
|
query: undefined
|
114
|
-
};
|
115
|
-
var preloadUrl = useV2 ? getWebAppV2Url(preloadUrlParams) : getWebAppUrl(preloadUrlParams);
|
111
|
+
});
|
116
112
|
return {
|
117
113
|
preloadUrl: preloadUrl,
|
118
114
|
containerId: containerId
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum
|
1
|
+
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from '../../types';
|
2
2
|
import { SDKMetaData } from '../index';
|
3
3
|
/**
|
4
4
|
* Tell the SDK which version of the Web App to load.
|
@@ -16,15 +16,6 @@ export interface WebAppMatchConfig {
|
|
16
16
|
mid?: string;
|
17
17
|
greyscale?: string;
|
18
18
|
}
|
19
|
-
/**
|
20
|
-
* Tell the SDK which Web App URL to load.
|
21
|
-
* Sent by server inside paymentSession.
|
22
|
-
*/
|
23
|
-
export interface WebAppUrlMatchConfig {
|
24
|
-
version: string;
|
25
|
-
url: string;
|
26
|
-
mid?: string;
|
27
|
-
}
|
28
19
|
export interface QueryParams {
|
29
20
|
displayType: DisplayTypeEnum;
|
30
21
|
locale: string;
|
@@ -36,56 +27,20 @@ export interface QueryParams {
|
|
36
27
|
export declare const getWebAppUrlInfo: (params: {
|
37
28
|
environment: string;
|
38
29
|
sdkMetaData: SDKMetaData;
|
39
|
-
productScene: ProductSceneEnum;
|
40
30
|
productSceneVersion: string;
|
41
31
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
42
32
|
isPreload?: boolean;
|
43
33
|
query: QueryParams;
|
44
|
-
v2Url?: string;
|
45
34
|
}) => {
|
46
35
|
path: string;
|
47
36
|
locationSearch: string;
|
48
37
|
};
|
49
|
-
export declare const getWebAppV2Url: (params: {
|
50
|
-
environment: string;
|
51
|
-
sdkMetaData: SDKMetaData;
|
52
|
-
productScene: ProductSceneEnum;
|
53
|
-
productSceneVersion: string;
|
54
|
-
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
55
|
-
isPreload?: boolean;
|
56
|
-
query: QueryParams;
|
57
|
-
mid?: string;
|
58
|
-
extendInfo?: string;
|
59
|
-
}) => string;
|
60
38
|
export declare const getWebAppUrl: (params: {
|
61
39
|
environment: string;
|
62
40
|
sdkMetaData: SDKMetaData;
|
63
|
-
productScene: ProductSceneEnum;
|
64
41
|
productSceneVersion: string;
|
65
42
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
66
43
|
isPreload?: boolean;
|
67
44
|
query: QueryParams;
|
68
|
-
v2Url?: string;
|
69
45
|
}) => string;
|
70
46
|
export declare const parseWebAppMatchConfig: (extendInfo: string) => WebAppMatchConfig[];
|
71
|
-
export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUrlMatchConfig[];
|
72
|
-
/**
|
73
|
-
* Save the current checkout URL to localStorage for the specified product scene.
|
74
|
-
*
|
75
|
-
* @param productScene - The product scene for which the checkout URL should be saved.
|
76
|
-
*/
|
77
|
-
export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url: string) => void;
|
78
|
-
/**
|
79
|
-
* Retrieve the saved checkout URL from localStorage for the specified product scene.
|
80
|
-
* If no url is found, a default checkout url string is returned.
|
81
|
-
*
|
82
|
-
* @param productScene - The product scene for which the checkout URL should be retrieved.
|
83
|
-
*/
|
84
|
-
export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum) => string;
|
85
|
-
/**
|
86
|
-
* Provide default checkout URL for the specified product scene.
|
87
|
-
* 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
|
-
* @param productScene - The product scene for which the default checkout URL should be provided.
|
90
|
-
*/
|
91
|
-
export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum) => string;
|
@@ -1,11 +1,9 @@
|
|
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 { ComponentSignEnum
|
8
|
-
import { marmotMap
|
5
|
+
import { ComponentSignEnum } from "../../types";
|
6
|
+
import { marmotMap } from "../../config";
|
9
7
|
import { queryParse, serialize } from "../../util";
|
10
8
|
import { isDebugLog } from "../../util/debug";
|
11
9
|
|
@@ -14,21 +12,14 @@ import { isDebugLog } from "../../util/debug";
|
|
14
12
|
* Sent by server inside paymentSession.
|
15
13
|
*/
|
16
14
|
|
17
|
-
/**
|
18
|
-
* Tell the SDK which Web App URL to load.
|
19
|
-
* Sent by server inside paymentSession.
|
20
|
-
*/
|
21
|
-
|
22
15
|
export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
|
23
16
|
var environment = params.environment,
|
24
17
|
sdkMetaData = params.sdkMetaData,
|
25
|
-
productScene = params.productScene,
|
26
18
|
productSceneVersion = params.productSceneVersion,
|
27
19
|
paymentMethodCategoryType = params.paymentMethodCategoryType,
|
28
20
|
query = params.query,
|
29
|
-
isPreload = params.isPreload
|
30
|
-
|
31
|
-
var path = getAppPath(environment, sdkMetaData, productScene, productSceneVersion, paymentMethodCategoryType, v2Url);
|
21
|
+
isPreload = params.isPreload;
|
22
|
+
var path = getAppPath(environment, sdkMetaData, productSceneVersion, paymentMethodCategoryType);
|
32
23
|
var _queryParse = queryParse(),
|
33
24
|
_sandbox = _queryParse._sandbox,
|
34
25
|
_light_sandbox = _queryParse._light_sandbox,
|
@@ -66,29 +57,6 @@ export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
|
|
66
57
|
locationSearch: locationSearch
|
67
58
|
};
|
68
59
|
};
|
69
|
-
export var getWebAppV2Url = function getWebAppV2Url(params) {
|
70
|
-
var productScene = params.productScene,
|
71
|
-
isPreload = params.isPreload,
|
72
|
-
mid = params.mid,
|
73
|
-
extendInfo = params.extendInfo;
|
74
|
-
var webAppUrlMatchConfig = parseWebAppUrlMatchConfig(extendInfo);
|
75
|
-
var v2Url = isPreload ? getLocalCheckoutUrl(productScene) : getMatchedWebAppV2Url(productScene, mid, webAppUrlMatchConfig);
|
76
|
-
var info = getWebAppUrlInfo(_objectSpread(_objectSpread({}, params), {}, {
|
77
|
-
v2Url: v2Url
|
78
|
-
}));
|
79
|
-
if (!isPreload && v2Url && info.path) {
|
80
|
-
console.log('[web-sdk] save web app, url: ', info.path);
|
81
|
-
saveLocalCheckoutUrl(productScene, info.path);
|
82
|
-
}
|
83
|
-
var webAppUrl;
|
84
|
-
if (info.path.indexOf('?') !== -1) {
|
85
|
-
webAppUrl = "".concat(info.path, "&").concat(info.locationSearch);
|
86
|
-
} else {
|
87
|
-
webAppUrl = "".concat(info.path, "?").concat(info.locationSearch);
|
88
|
-
}
|
89
|
-
console.log('[web-sdk] web app, url: ', webAppUrl);
|
90
|
-
return webAppUrl;
|
91
|
-
};
|
92
60
|
export var getWebAppUrl = function getWebAppUrl(params) {
|
93
61
|
var info = getWebAppUrlInfo(params);
|
94
62
|
var webAppUrl;
|
@@ -102,10 +70,8 @@ export var getWebAppUrl = function getWebAppUrl(params) {
|
|
102
70
|
var getAppPath = function getAppPath() {
|
103
71
|
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
104
72
|
var sdkMetaData = arguments.length > 1 ? arguments[1] : undefined;
|
105
|
-
var
|
106
|
-
var
|
107
|
-
var paymentMethodCategoryType = arguments.length > 4 ? arguments[4] : undefined;
|
108
|
-
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;
|
109
75
|
var _ref = queryParse() || {},
|
110
76
|
urlTestHost = _ref.host;
|
111
77
|
// only for test while testurl?host=https://xxxxx.test.html
|
@@ -115,12 +81,7 @@ var getAppPath = function getAppPath() {
|
|
115
81
|
var validProductSceneVersion = getValidProductSceneVersion(sdkMetaData.productScene, productSceneVersion, paymentMethodCategoryType);
|
116
82
|
var productSceneWithPaymentMethodCategoryType = "".concat(sdkMetaData.productScene, "_").concat(paymentMethodCategoryType);
|
117
83
|
var webAppVersion = sdkMetaData.webAppVersion;
|
118
|
-
|
119
|
-
case ProductSceneEnum.EASY_PAY:
|
120
|
-
return v2Url !== null && v2Url !== void 0 ? v2Url : defaultCheckoutUrl(productScene);
|
121
|
-
default:
|
122
|
-
return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
|
123
|
-
}
|
84
|
+
return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
|
124
85
|
};
|
125
86
|
export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo) {
|
126
87
|
if (!extendInfo) {
|
@@ -135,18 +96,6 @@ export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo)
|
|
135
96
|
return [];
|
136
97
|
}
|
137
98
|
};
|
138
|
-
export var parseWebAppUrlMatchConfig = function parseWebAppUrlMatchConfig(extendInfo) {
|
139
|
-
if (!extendInfo) {
|
140
|
-
return [];
|
141
|
-
}
|
142
|
-
try {
|
143
|
-
var extendInfoJson = JSON.parse(extendInfo);
|
144
|
-
return extendInfoJson === null || extendInfoJson === void 0 ? void 0 : extendInfoJson.checkoutInfo;
|
145
|
-
} catch (error) {
|
146
|
-
console.error('Parse the url config for Web app failed#', error);
|
147
|
-
return [];
|
148
|
-
}
|
149
|
-
};
|
150
99
|
var getValidProductSceneVersion = function getValidProductSceneVersion(productScene, productSceneVer, paymentMethodCategoryType) {
|
151
100
|
var _supportMapping;
|
152
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']));
|
@@ -160,75 +109,4 @@ var getValidProductSceneVersion = function getValidProductSceneVersion(productSc
|
|
160
109
|
});
|
161
110
|
var latestVersion = targetVersions[targetVersions.length - 1];
|
162
111
|
return isSupport ? productSceneVer : latestVersion;
|
163
|
-
};
|
164
|
-
var KEY_CHECKOUT_URL = "web_url_";
|
165
|
-
|
166
|
-
/**
|
167
|
-
* Save the current checkout URL to localStorage for the specified product scene.
|
168
|
-
*
|
169
|
-
* @param productScene - The product scene for which the checkout URL should be saved.
|
170
|
-
*/
|
171
|
-
export var saveLocalCheckoutUrl = function saveLocalCheckoutUrl(productScene, url) {
|
172
|
-
var key = KEY_CHECKOUT_URL + productScene;
|
173
|
-
localStorage.setItem(key, url);
|
174
|
-
};
|
175
|
-
|
176
|
-
/**
|
177
|
-
* Retrieve the saved checkout URL from localStorage for the specified product scene.
|
178
|
-
* If no url is found, a default checkout url string is returned.
|
179
|
-
*
|
180
|
-
* @param productScene - The product scene for which the checkout URL should be retrieved.
|
181
|
-
*/
|
182
|
-
export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene) {
|
183
|
-
var key = KEY_CHECKOUT_URL + productScene;
|
184
|
-
var previousCheckoutUrl = localStorage.getItem(key);
|
185
|
-
return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene);
|
186
|
-
};
|
187
|
-
|
188
|
-
/**
|
189
|
-
* Provide default checkout URL for the specified product scene.
|
190
|
-
* Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
|
191
|
-
*
|
192
|
-
* @param productScene - The product scene for which the default checkout URL should be provided.
|
193
|
-
*/
|
194
|
-
export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
|
195
|
-
var defaultEnvironment = 'prod';
|
196
|
-
switch (productScene) {
|
197
|
-
case ProductSceneEnum.EASY_PAY:
|
198
|
-
return "".concat(v2AppMarmotMap[defaultEnvironment], "/easysafepay/pages/sdk-portal/index.html");
|
199
|
-
default:
|
200
|
-
return '';
|
201
|
-
}
|
202
|
-
};
|
203
|
-
var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
|
204
|
-
var mid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
205
|
-
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
206
|
-
if (config.length === 0) {
|
207
|
-
// Default checkout url
|
208
|
-
return defaultCheckoutUrl(productScene);
|
209
|
-
}
|
210
|
-
var sortedConfig = config.sort(function (a, b) {
|
211
|
-
return parseFloat(b.version) - parseFloat(a.version);
|
212
|
-
});
|
213
|
-
var targetConfigEntry = sortedConfig.find(function (configEntry) {
|
214
|
-
var _configEntry$mid;
|
215
|
-
var isMatchMid = (_configEntry$mid = configEntry.mid) !== null && _configEntry$mid !== void 0 && _configEntry$mid.trim() ? configEntry.mid.toUpperCase().includes(mid === null || mid === void 0 ? void 0 : mid.toUpperCase()) : true;
|
216
|
-
if (isMatchMid) {
|
217
|
-
return configEntry;
|
218
|
-
}
|
219
|
-
});
|
220
|
-
if (targetConfigEntry) {
|
221
|
-
// Match merchant ID
|
222
|
-
return targetConfigEntry === null || targetConfigEntry === void 0 ? void 0 : targetConfigEntry.url;
|
223
|
-
}
|
224
|
-
var sortedAllMerchantsConfig = sortedConfig.find(function (configEntry) {
|
225
|
-
return configEntry.mid === undefined || configEntry.mid === '';
|
226
|
-
});
|
227
|
-
if (sortedAllMerchantsConfig) {
|
228
|
-
// Match highest version without merchant ID
|
229
|
-
return sortedAllMerchantsConfig === null || sortedAllMerchantsConfig === void 0 ? void 0 : sortedAllMerchantsConfig.url;
|
230
|
-
}
|
231
|
-
|
232
|
-
// Default checkout url
|
233
|
-
return defaultCheckoutUrl(productScene);
|
234
112
|
};
|
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);
|
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 {
|
18
|
+
import { elementAppMarmotMap, 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(
|
106
|
+
return "".concat(elementAppMarmotMap[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(
|
120
|
+
return "".concat(elementAppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/express_checkout/index.html");
|
121
121
|
} else {
|
122
|
-
return "".concat(
|
122
|
+
return "".concat(elementAppMarmotMap[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");
|
@@ -71,11 +71,11 @@ export function getDoubleFaUrl(params) {
|
|
71
71
|
var isLandscapeOrientation = false; // Web 不含横屏
|
72
72
|
|
73
73
|
var DOUBLE_FA_URL_MAPPING = {
|
74
|
-
local:
|
75
|
-
dev:
|
76
|
-
sit:
|
77
|
-
pre:
|
78
|
-
prod:
|
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
79
|
};
|
80
80
|
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
81
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);
|