@alipay/ams-checkout 0.0.1745808793-dev.0 → 0.0.1745808793-dev.1
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 +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/foundation/core/index.js +48 -25
- package/esm/foundation/product-processor/easysafepay/index.js +15 -7
- package/esm/foundation/utils/preload_helper.d.ts +2 -2
- package/esm/foundation/utils/preload_helper.js +8 -4
- package/esm/foundation/utils/web_app_url_utils.d.ts +46 -1
- package/esm/foundation/utils/web_app_url_utils.js +129 -7
- 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
@@ -58,11 +58,11 @@ export function getDoubleFaUrl(params) {
|
|
58
58
|
var isLandscapeOrientation = false; // Web 不含横屏
|
59
59
|
|
60
60
|
var DOUBLE_FA_URL_MAPPING = {
|
61
|
-
local:
|
62
|
-
dev:
|
63
|
-
sit:
|
64
|
-
pre:
|
65
|
-
prod:
|
61
|
+
local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index-1.0.1.html',
|
62
|
+
dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index-1.0.1.html',
|
63
|
+
sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
|
64
|
+
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
|
65
|
+
prod: 'https://checkout.antom.com/easysafepay/pages/double-fa/index.html'
|
66
66
|
};
|
67
67
|
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
68
68
|
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 v2AppMarmotMap: 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 v2AppMarmotMap = {
|
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,6 +219,9 @@ export declare const EVENT: {
|
|
219
219
|
showToast: {
|
220
220
|
name: string;
|
221
221
|
};
|
222
|
+
getSdkVersion: {
|
223
|
+
name: string;
|
224
|
+
};
|
222
225
|
};
|
223
226
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
224
227
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -178,6 +178,29 @@ 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
|
+
}());
|
181
204
|
eventCenter.listen(EVENT.destroy.name, function (data) {
|
182
205
|
_this.setStatus(IElementStatus.READY);
|
183
206
|
_this.destroy();
|
@@ -208,14 +231,14 @@ export var AntomSDKCore = /*#__PURE__*/function () {
|
|
208
231
|
}, {
|
209
232
|
key: "startBizFlow",
|
210
233
|
value: function () {
|
211
|
-
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
234
|
+
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
|
212
235
|
var _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3;
|
213
236
|
var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
|
214
|
-
return _regeneratorRuntime().wrap(function
|
215
|
-
while (1) switch (
|
237
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
238
|
+
while (1) switch (_context4.prev = _context4.next) {
|
216
239
|
case 0:
|
217
240
|
if (!(!options || !options.paymentSession)) {
|
218
|
-
|
241
|
+
_context4.next = 2;
|
219
242
|
break;
|
220
243
|
}
|
221
244
|
throw new Error('paymentSession is empty');
|
@@ -245,61 +268,61 @@ export var AntomSDKCore = /*#__PURE__*/function () {
|
|
245
268
|
// Invoke processor
|
246
269
|
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;
|
247
270
|
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;
|
248
|
-
|
271
|
+
_context4.prev = 14;
|
249
272
|
if (!this.productProcessors["".concat(productScene, "|").concat(paymentMethod)]) {
|
250
|
-
|
273
|
+
_context4.next = 21;
|
251
274
|
break;
|
252
275
|
}
|
253
|
-
|
276
|
+
_context4.next = 18;
|
254
277
|
return this.productProcessors["".concat(productScene, "|").concat(paymentMethod)].startBizFlow(this.paymentContext);
|
255
278
|
case 18:
|
256
|
-
this.bizFlowStartBehavior =
|
257
|
-
|
279
|
+
this.bizFlowStartBehavior = _context4.sent;
|
280
|
+
_context4.next = 25;
|
258
281
|
break;
|
259
282
|
case 21:
|
260
283
|
if (!this.productProcessors["".concat(productScene)]) {
|
261
|
-
|
284
|
+
_context4.next = 25;
|
262
285
|
break;
|
263
286
|
}
|
264
|
-
|
287
|
+
_context4.next = 24;
|
265
288
|
return this.productProcessors["".concat(productScene)].startBizFlow(this.paymentContext);
|
266
289
|
case 24:
|
267
|
-
this.bizFlowStartBehavior =
|
290
|
+
this.bizFlowStartBehavior = _context4.sent;
|
268
291
|
case 25:
|
269
|
-
|
292
|
+
_context4.next = 30;
|
270
293
|
break;
|
271
294
|
case 27:
|
272
|
-
|
273
|
-
|
274
|
-
console.error('Invoke processor failed',
|
295
|
+
_context4.prev = 27;
|
296
|
+
_context4.t0 = _context4["catch"](14);
|
297
|
+
console.error('Invoke processor failed', _context4.t0);
|
275
298
|
case 30:
|
276
299
|
if (!(!this.bizFlowStartBehavior || this.bizFlowStartBehavior.behaviorType === 'NONE' || !this.bizFlowStartBehavior.payload)) {
|
277
|
-
|
300
|
+
_context4.next = 32;
|
278
301
|
break;
|
279
302
|
}
|
280
|
-
return
|
303
|
+
return _context4.abrupt("return");
|
281
304
|
case 32:
|
282
305
|
if (!(this.bizFlowStartBehavior.behaviorType === 'RENDER')) {
|
283
|
-
|
306
|
+
_context4.next = 35;
|
284
307
|
break;
|
285
308
|
}
|
286
309
|
this.handleBehaviorRender();
|
287
|
-
return
|
310
|
+
return _context4.abrupt("return");
|
288
311
|
case 35:
|
289
312
|
if (!(this.bizFlowStartBehavior.behaviorType === 'REDIRECT')) {
|
290
|
-
|
313
|
+
_context4.next = 39;
|
291
314
|
break;
|
292
315
|
}
|
293
316
|
payload = (_this$bizFlowStartBeh = this.bizFlowStartBehavior) === null || _this$bizFlowStartBeh === void 0 ? void 0 : _this$bizFlowStartBeh.payload;
|
294
317
|
redirect(payload, this.instanceId);
|
295
|
-
return
|
318
|
+
return _context4.abrupt("return");
|
296
319
|
case 39:
|
297
320
|
case "end":
|
298
|
-
return
|
321
|
+
return _context4.stop();
|
299
322
|
}
|
300
|
-
},
|
323
|
+
}, _callee4, this, [[14, 27]]);
|
301
324
|
}));
|
302
|
-
function startBizFlow(
|
325
|
+
function startBizFlow(_x7) {
|
303
326
|
return _startBizFlow.apply(this, arguments);
|
304
327
|
}
|
305
328
|
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, true);
|
50
50
|
}
|
51
51
|
}, {
|
52
52
|
key: "startBizFlow",
|
@@ -113,15 +113,19 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
113
113
|
}, {
|
114
114
|
key: "buildWebAppUrl",
|
115
115
|
value: function buildWebAppUrl() {
|
116
|
-
var _paymentContext$payme3, _paymentContext$payme4, _this$initConfig$anal;
|
116
|
+
var _paymentContext$payme3, _paymentContext$payme4, _paymentContext$payme5, _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
|
119
|
+
var productScene = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productScene;
|
120
|
+
var productSceneVersion = (_paymentContext$payme5 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme5 === void 0 ? void 0 : _paymentContext$payme5.productSceneVersion;
|
120
121
|
var hostSign = this.hostSign;
|
121
|
-
var
|
122
|
+
var mid = paymentContext.paymentSessionObj.clientId;
|
123
|
+
var extendInfo = paymentContext.paymentSessionObj.extendInfo;
|
124
|
+
var webAppUrl = WebAppUrlUtil.getWebAppV2Url({
|
122
125
|
environment: this.initConfig.environment,
|
123
126
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
124
127
|
sdkMetaData: paymentContext.sdkMetaData,
|
128
|
+
productScene: productScene,
|
125
129
|
productSceneVersion: productSceneVersion,
|
126
130
|
isPreload: false,
|
127
131
|
query: {
|
@@ -130,7 +134,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
130
134
|
instanceId: this.instanceId,
|
131
135
|
locale: this.initConfig.locale,
|
132
136
|
hostSign: hostSign
|
133
|
-
}
|
137
|
+
},
|
138
|
+
mid: mid,
|
139
|
+
extendInfo: extendInfo
|
134
140
|
});
|
135
141
|
return webAppUrl;
|
136
142
|
}
|
@@ -277,8 +283,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
277
283
|
paymentSessionData: this.paymentContext.paymentSessionId,
|
278
284
|
env: this.initConfig.environment,
|
279
285
|
sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
|
280
|
-
})) || {};
|
281
|
-
|
286
|
+
})) || {}; // 二次支付不再需要该参数
|
287
|
+
if (!autoDebitWithToken) {
|
288
|
+
extParams.complianceSDK = true;
|
289
|
+
}
|
282
290
|
submitParams.extParams = extParams;
|
283
291
|
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
284
292
|
_context2.prev = 13;
|
@@ -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): void;
|
7
|
+
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): 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, useV2?: boolean): {
|
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 } from "../utils/web_app_url_utils";
|
11
|
+
import { getWebAppUrl, getWebAppV2Url } from "../utils/web_app_url_utils";
|
12
12
|
import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
|
13
13
|
import { getWebAppVersion } from "./payment_context_utils";
|
14
14
|
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
|
@@ -22,12 +22,13 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
22
22
|
key: "preloadWebApp",
|
23
23
|
value: function preloadWebApp(productScene, paymentMethodCategoryType) {
|
24
24
|
var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
|
25
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
25
26
|
try {
|
26
27
|
if (this.isWebAppPreloaded) {
|
27
28
|
console.log('[web-sdk] web app already preloaded');
|
28
29
|
return;
|
29
30
|
}
|
30
|
-
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
|
31
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment, useV2),
|
31
32
|
preloadUrl = _this$buildWebAppPrel.preloadUrl,
|
32
33
|
containerId = _this$buildWebAppPrel.containerId;
|
33
34
|
var preloadIframe = createPreloadIframe(containerId);
|
@@ -89,6 +90,7 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
89
90
|
}, {
|
90
91
|
key: "buildWebAppPreloadUrl",
|
91
92
|
value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
|
93
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
92
94
|
var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
|
93
95
|
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
|
94
96
|
if (previousProductInfo) {
|
@@ -101,14 +103,16 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
101
103
|
webAppVersion: ''
|
102
104
|
};
|
103
105
|
sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
|
104
|
-
var
|
106
|
+
var preloadUrlParams = {
|
105
107
|
environment: environment,
|
106
108
|
sdkMetaData: sdkMetaData,
|
107
109
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
108
110
|
isPreload: true,
|
111
|
+
productScene: productScene,
|
109
112
|
productSceneVersion: productSceneVersion,
|
110
113
|
query: undefined
|
111
|
-
}
|
114
|
+
};
|
115
|
+
var preloadUrl = useV2 ? getWebAppV2Url(preloadUrlParams) : getWebAppUrl(preloadUrlParams);
|
112
116
|
return {
|
113
117
|
preloadUrl: preloadUrl,
|
114
118
|
containerId: containerId
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from '../../types';
|
1
|
+
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
|
2
2
|
import { SDKMetaData } from '../index';
|
3
3
|
/**
|
4
4
|
* Tell the SDK which version of the Web App to load.
|
@@ -16,6 +16,15 @@ 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
|
+
}
|
19
28
|
export interface QueryParams {
|
20
29
|
displayType: DisplayTypeEnum;
|
21
30
|
locale: string;
|
@@ -27,20 +36,56 @@ export interface QueryParams {
|
|
27
36
|
export declare const getWebAppUrlInfo: (params: {
|
28
37
|
environment: string;
|
29
38
|
sdkMetaData: SDKMetaData;
|
39
|
+
productScene: ProductSceneEnum;
|
30
40
|
productSceneVersion: string;
|
31
41
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
32
42
|
isPreload?: boolean;
|
33
43
|
query: QueryParams;
|
44
|
+
v2Url?: string;
|
34
45
|
}) => {
|
35
46
|
path: string;
|
36
47
|
locationSearch: string;
|
37
48
|
};
|
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;
|
38
60
|
export declare const getWebAppUrl: (params: {
|
39
61
|
environment: string;
|
40
62
|
sdkMetaData: SDKMetaData;
|
63
|
+
productScene: ProductSceneEnum;
|
41
64
|
productSceneVersion: string;
|
42
65
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
43
66
|
isPreload?: boolean;
|
44
67
|
query: QueryParams;
|
68
|
+
v2Url?: string;
|
45
69
|
}) => string;
|
46
70
|
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,9 +1,11 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
2
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
3
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
4
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
5
|
-
import { ComponentSignEnum } from "../../types";
|
6
|
-
import { marmotMap } from "../../config";
|
7
|
+
import { ComponentSignEnum, ProductSceneEnum } from "../../types";
|
8
|
+
import { marmotMap, v2AppMarmotMap } from "../../config";
|
7
9
|
import { queryParse, serialize } from "../../util";
|
8
10
|
import { isDebugLog } from "../../util/debug";
|
9
11
|
|
@@ -12,14 +14,21 @@ import { isDebugLog } from "../../util/debug";
|
|
12
14
|
* Sent by server inside paymentSession.
|
13
15
|
*/
|
14
16
|
|
17
|
+
/**
|
18
|
+
* Tell the SDK which Web App URL to load.
|
19
|
+
* Sent by server inside paymentSession.
|
20
|
+
*/
|
21
|
+
|
15
22
|
export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
|
16
23
|
var environment = params.environment,
|
17
24
|
sdkMetaData = params.sdkMetaData,
|
25
|
+
productScene = params.productScene,
|
18
26
|
productSceneVersion = params.productSceneVersion,
|
19
27
|
paymentMethodCategoryType = params.paymentMethodCategoryType,
|
20
28
|
query = params.query,
|
21
|
-
isPreload = params.isPreload
|
22
|
-
|
29
|
+
isPreload = params.isPreload,
|
30
|
+
v2Url = params.v2Url;
|
31
|
+
var path = getAppPath(environment, sdkMetaData, productScene, productSceneVersion, paymentMethodCategoryType, v2Url);
|
23
32
|
var _queryParse = queryParse(),
|
24
33
|
_sandbox = _queryParse._sandbox,
|
25
34
|
_light_sandbox = _queryParse._light_sandbox,
|
@@ -57,6 +66,29 @@ export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
|
|
57
66
|
locationSearch: locationSearch
|
58
67
|
};
|
59
68
|
};
|
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
|
+
};
|
60
92
|
export var getWebAppUrl = function getWebAppUrl(params) {
|
61
93
|
var info = getWebAppUrlInfo(params);
|
62
94
|
var webAppUrl;
|
@@ -70,8 +102,10 @@ export var getWebAppUrl = function getWebAppUrl(params) {
|
|
70
102
|
var getAppPath = function getAppPath() {
|
71
103
|
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
72
104
|
var sdkMetaData = arguments.length > 1 ? arguments[1] : undefined;
|
73
|
-
var
|
74
|
-
var
|
105
|
+
var productScene = arguments.length > 2 ? arguments[2] : undefined;
|
106
|
+
var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
|
107
|
+
var paymentMethodCategoryType = arguments.length > 4 ? arguments[4] : undefined;
|
108
|
+
var v2Url = arguments.length > 5 ? arguments[5] : undefined;
|
75
109
|
var _ref = queryParse() || {},
|
76
110
|
urlTestHost = _ref.host;
|
77
111
|
// only for test while testurl?host=https://xxxxx.test.html
|
@@ -81,7 +115,12 @@ var getAppPath = function getAppPath() {
|
|
81
115
|
var validProductSceneVersion = getValidProductSceneVersion(sdkMetaData.productScene, productSceneVersion, paymentMethodCategoryType);
|
82
116
|
var productSceneWithPaymentMethodCategoryType = "".concat(sdkMetaData.productScene, "_").concat(paymentMethodCategoryType);
|
83
117
|
var webAppVersion = sdkMetaData.webAppVersion;
|
84
|
-
|
118
|
+
switch (productScene) {
|
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
|
+
}
|
85
124
|
};
|
86
125
|
export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo) {
|
87
126
|
if (!extendInfo) {
|
@@ -96,6 +135,18 @@ export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo)
|
|
96
135
|
return [];
|
97
136
|
}
|
98
137
|
};
|
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
|
+
};
|
99
150
|
var getValidProductSceneVersion = function getValidProductSceneVersion(productScene, productSceneVer, paymentMethodCategoryType) {
|
100
151
|
var _supportMapping;
|
101
152
|
var supportMapping = (_supportMapping = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.NONE, ['']), ComponentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), ComponentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), ComponentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), ComponentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), ComponentSignEnum.EASY_PAY_APM, ['2.0']), ComponentSignEnum.VAULTING_CARD, ['1.0']), ComponentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.ELEMENT_ADDRESS, ['1.0']), ComponentSignEnum.CHECKOUT_PAYMENT, ['1.0']));
|
@@ -109,4 +160,75 @@ var getValidProductSceneVersion = function getValidProductSceneVersion(productSc
|
|
109
160
|
});
|
110
161
|
var latestVersion = targetVersions[targetVersions.length - 1];
|
111
162
|
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);
|
112
234
|
};
|
package/esm/index.js
CHANGED
@@ -271,7 +271,7 @@ export var AMSEasyPay = /*#__PURE__*/function () {
|
|
271
271
|
securityRegion: 'SG',
|
272
272
|
environment: 'prod'
|
273
273
|
};
|
274
|
-
PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
|
274
|
+
PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment, true);
|
275
275
|
}
|
276
276
|
}]);
|
277
277
|
return AMSEasyPay;
|
@@ -15,7 +15,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
15
15
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
16
16
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
17
17
|
*/
|
18
|
-
import {
|
18
|
+
import { v2AppMarmotMap, marmotMap, sdkVersion } from "../../config/index";
|
19
19
|
import { ComponentSignEnum, ComponentSignEnumV2 } from "../../types";
|
20
20
|
import { isDebugLog } from "../../util/debug";
|
21
21
|
import { queryParse, serialize } from "../../util/index";
|
@@ -103,7 +103,7 @@ export var getAppPath = function getAppPath() {
|
|
103
103
|
}
|
104
104
|
// 地址应用特殊处理
|
105
105
|
if (componentSign === ComponentSignEnum.ELEMENT_ADDRESS) {
|
106
|
-
return "".concat(
|
106
|
+
return "".concat(v2AppMarmotMap[environment], "/element-address/").concat(finalAppVersion, "/pages/address/index.html");
|
107
107
|
}
|
108
108
|
// element应用特殊处理
|
109
109
|
if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign)) {
|
@@ -117,9 +117,9 @@ export var getAppPath = function getAppPath() {
|
|
117
117
|
}
|
118
118
|
if (isExpressCheckout) {
|
119
119
|
// express_checkout模式走单独映射
|
120
|
-
return "".concat(
|
120
|
+
return "".concat(v2AppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/express_checkout/index.html");
|
121
121
|
} else {
|
122
|
-
return "".concat(
|
122
|
+
return "".concat(v2AppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/").concat(productScene.toLowerCase(), "/index.html");
|
123
123
|
}
|
124
124
|
}
|
125
125
|
return "".concat(marmotMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
@@ -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-v2/easysafepay/pages/double-fa/index-1.0.1.html',
|
75
|
+
dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index-1.0.1.html',
|
76
|
+
sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
|
77
|
+
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
|
78
|
+
prod: 'https://checkout.antom.com/easysafepay/pages/double-fa/index.html'
|
79
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);
|