@alipay/ams-checkout 0.0.1745808793-dev.6 → 0.0.1745808793-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.d.ts +2 -1
- package/esm/component/channel.js +8 -9
- package/esm/foundation/product-processor/easysafepay/index.js +43 -39
- package/esm/foundation/utils/web_app_url_utils.d.ts +18 -2
- package/esm/foundation/utils/web_app_url_utils.js +94 -43
- package/esm/plugin/component/channel.d.ts +1 -0
- package/esm/plugin/component/channel.js +5 -4
- package/esm/plugin/component/index.js +1 -0
- package/package.json +1 -1
@@ -9,12 +9,13 @@ export type IChannelBehavior = {
|
|
9
9
|
type GetDoubleFaParams = {
|
10
10
|
instanceId: string;
|
11
11
|
paymentSessionData: string;
|
12
|
+
paymentSessionObj: IPaymentSessionMetaData;
|
12
13
|
locale: string;
|
13
14
|
paymentMethodType: string;
|
14
15
|
env: string;
|
15
16
|
sdkVersion: string;
|
16
17
|
notRedirectAfterComplete: boolean;
|
17
18
|
};
|
18
|
-
export declare function getChannelBehavior(paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
|
19
|
+
export declare function getChannelBehavior(notRedirectAfterComplete: boolean, paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
|
19
20
|
export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
|
20
21
|
export {};
|
package/esm/component/channel.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
export function getChannelBehavior(paymentSessionMetaData) {
|
4
|
-
var _paymentSessionMetaDa
|
5
|
-
_this = this;
|
1
|
+
import { getDoubleFaUrlFromSession } from "../foundation/utils/web_app_url_utils";
|
2
|
+
import { MODE } from "../constant/easysafepay";
|
3
|
+
export function getChannelBehavior(notRedirectAfterComplete, paymentSessionMetaData) {
|
4
|
+
var _paymentSessionMetaDa;
|
6
5
|
var allowSubmitPayCallAhead = false;
|
7
6
|
var allowClickOutsideClose = false;
|
8
7
|
var buildSubmitPayExtParams = undefined;
|
@@ -21,11 +20,10 @@ export function getChannelBehavior(paymentSessionMetaData) {
|
|
21
20
|
if (isTossPayment) {
|
22
21
|
allowClickOutsideClose = false;
|
23
22
|
buildSubmitPayExtParams = function buildSubmitPayExtParams(params) {
|
24
|
-
var _this$paymentContext$;
|
25
23
|
var callBackUrl = getDoubleFaUrl(params);
|
26
24
|
return {
|
27
25
|
callBackUrl: callBackUrl,
|
28
|
-
notRedirectAfterComplete:
|
26
|
+
notRedirectAfterComplete: notRedirectAfterComplete
|
29
27
|
};
|
30
28
|
};
|
31
29
|
}
|
@@ -41,12 +39,13 @@ export function getDoubleFaUrl(params) {
|
|
41
39
|
var instanceId = params.instanceId,
|
42
40
|
paymentMethodType = params.paymentMethodType,
|
43
41
|
paymentSessionData = params.paymentSessionData,
|
42
|
+
paymentSessionObj = params.paymentSessionObj,
|
44
43
|
locale = params.locale,
|
45
44
|
env = params.env,
|
46
45
|
sdkVersion = params.sdkVersion,
|
47
46
|
notRedirectAfterComplete = params.notRedirectAfterComplete;
|
48
47
|
var isLandscapeOrientation = false; // Web 不含横屏
|
49
48
|
|
50
|
-
var
|
51
|
-
return "".concat(
|
49
|
+
var baseDoubleFaUrl = getDoubleFaUrlFromSession(paymentSessionObj, env);
|
50
|
+
return "".concat(baseDoubleFaUrl) + '?' + "scene=cashierResultPage" + '&' + "instanceId=".concat(instanceId) + '&' + "paymentSessionData=".concat(encodeURIComponent(paymentSessionData)) + '&' + "isLandscape=".concat(isLandscapeOrientation ? 'true' : '') + '&' + "pmt=".concat(paymentMethodType) + '&' + "locale=".concat(locale) + '&' + "sdkVersion=".concat(sdkVersion) + '&' + "mode=".concat(MODE.SDK) + '&' + "¬RedirectAfterComplete=".concat(notRedirectAfterComplete);
|
52
51
|
}
|
@@ -19,8 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
19
19
|
import PreloadHelper from "../../../foundation/utils/preload_helper";
|
20
20
|
import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil, EVENT, eventCodeEnum } from "./deps";
|
21
21
|
import { isEmpty } from "../../../util";
|
22
|
-
import {
|
23
|
-
import { ESP_PAGE_NAME } from "../../../constant/easysafepay";
|
22
|
+
import { getDoubleFaUrlFromSession } from "../../utils/web_app_url_utils";
|
24
23
|
export var EasySafePayProcessor = /*#__PURE__*/function () {
|
25
24
|
function EasySafePayProcessor() {
|
26
25
|
_classCallCheck(this, EasySafePayProcessor);
|
@@ -56,7 +55,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
56
55
|
key: "startBizFlow",
|
57
56
|
value: function () {
|
58
57
|
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentContext) {
|
59
|
-
var _paymentContext$payme2, _this$channelBehavior;
|
58
|
+
var _paymentContext$payme2, _paymentContext$start, _this$channelBehavior;
|
60
59
|
var _paymentContext$payme, productSceneVersion, paymentMethodCategoryType, autoDebitWithToken, requireFastSdk, authUrlInfo, isFirstTimeToPay, webAppUrl, resultPayload;
|
61
60
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
62
61
|
while (1) switch (_context.prev = _context.next) {
|
@@ -64,9 +63,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
64
63
|
// 放在最前面的逻辑
|
65
64
|
// 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
|
66
65
|
if (isPC()) {
|
67
|
-
// 非TOSS渠道,在PC场景需要改成1.0
|
66
|
+
// 非TOSS渠道,在PC场景需要改成1.0/needAccountConfirmPage=false
|
68
67
|
if ('BANKTRANSFER_QUICKPAY' !== ((_paymentContext$payme = paymentContext.paymentSessionObj) === null || _paymentContext$payme === void 0 || (_paymentContext$payme = _paymentContext$payme.paymentMethodInfoView) === null || _paymentContext$payme === void 0 ? void 0 : _paymentContext$payme.paymentMethodType)) {
|
69
68
|
paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion = '1.0';
|
69
|
+
paymentContext.paymentSessionObj.needAccountConfirmPage = false;
|
70
70
|
}
|
71
71
|
}
|
72
72
|
this.paymentContext = paymentContext;
|
@@ -76,7 +76,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
76
76
|
autoDebitWithToken = paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
77
77
|
requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
|
78
78
|
authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
|
79
|
-
this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
|
79
|
+
this.channelBehavior = ChannelCustomize.getChannelBehavior(((_paymentContext$start = paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _paymentContext$start === void 0 ? void 0 : _paymentContext$start.notRedirectAfterComplete) === true, paymentContext.paymentSessionObj);
|
80
80
|
|
81
81
|
// 首次支付
|
82
82
|
isFirstTimeToPay = !autoDebitWithToken; // 处理ESP极速外跳支付场景
|
@@ -189,7 +189,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
189
189
|
|
190
190
|
// 等请求和 Web启动都Ready之后,发送renderComponent
|
191
191
|
Promise.all([this.initSecuritySDK(), this.processQuery(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
|
192
|
-
var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
|
192
|
+
var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext3, _this$paymentContext$4;
|
193
193
|
var _ref2 = _slicedToArray(_ref, 4),
|
194
194
|
_initSecurityRes = _ref2[0],
|
195
195
|
queryRes = _ref2[1],
|
@@ -207,7 +207,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
207
207
|
isAppWebview: _this.paymentContext.startBizFlowOptions.isAppWebview,
|
208
208
|
merchantAppointParam: (_this$paymentContext$3 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.merchantAppointParam,
|
209
209
|
allowSubmitPayCallAhead: _this.allowSubmitPayCallAhead,
|
210
|
-
doubleFaUrl:
|
210
|
+
doubleFaUrl: getDoubleFaUrlFromSession((_this$paymentContext3 = _this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionObj, _this.initConfig.environment),
|
211
211
|
envInfo: {
|
212
212
|
screenHeight: screen.height,
|
213
213
|
screenWidth: screen.width
|
@@ -245,29 +245,32 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
245
245
|
key: "processQuery",
|
246
246
|
value: function () {
|
247
247
|
var _processQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
248
|
-
var _this$
|
249
|
-
var queryParams, extendInfo,
|
248
|
+
var _this$paymentContext4, _this$paymentContext5, _this$paymentContext6, _this$paymentContext$5, _this$paymentContext7, _this$paymentContext8;
|
249
|
+
var queryParams, extendInfo, needAccountConfirmPage, isFirstTimeToPay, needQueryRender, extendInfoData, requestBizId, requester, _this$paymentContext$6, res;
|
250
250
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
251
251
|
while (1) switch (_context2.prev = _context2.next) {
|
252
252
|
case 0:
|
253
253
|
queryParams = {
|
254
|
-
paymentSessionData: ((_this$
|
255
|
-
paymentSessionConfig: (_this$
|
254
|
+
paymentSessionData: ((_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionId) || '',
|
255
|
+
paymentSessionConfig: (_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 || (_this$paymentContext5 = _this$paymentContext5.paymentSessionObj) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.paymentSessionConfig
|
256
256
|
};
|
257
|
-
extendInfo = this.paymentContext.paymentSessionObj.extendInfo;
|
257
|
+
extendInfo = (_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.paymentSessionObj.extendInfo;
|
258
|
+
needAccountConfirmPage = (_this$paymentContext$5 = (_this$paymentContext7 = this.paymentContext) === null || _this$paymentContext7 === void 0 ? void 0 : _this$paymentContext7.paymentSessionObj.needAccountConfirmPage) !== null && _this$paymentContext$5 !== void 0 ? _this$paymentContext$5 : true;
|
259
|
+
isFirstTimeToPay = !((_this$paymentContext8 = this.paymentContext) !== null && _this$paymentContext8 !== void 0 && (_this$paymentContext8 = _this$paymentContext8.paymentSessionObj.action) !== null && _this$paymentContext8 !== void 0 && _this$paymentContext8.autoDebitWithToken);
|
260
|
+
needQueryRender = true;
|
258
261
|
try {
|
259
262
|
extendInfoData = JSON.parse(extendInfo);
|
260
263
|
needQueryRender = isEmpty(extendInfoData.needQueryRender) || extendInfoData.needQueryRender === true;
|
261
|
-
this.allowQueryCall = needQueryRender;
|
262
264
|
} catch (error) {
|
263
265
|
console.log(error);
|
264
266
|
}
|
267
|
+
this.allowQueryCall = needQueryRender && isFirstTimeToPay && needAccountConfirmPage;
|
265
268
|
if (this.allowQueryCall) {
|
266
|
-
_context2.next =
|
269
|
+
_context2.next = 9;
|
267
270
|
break;
|
268
271
|
}
|
269
272
|
return _context2.abrupt("return", null);
|
270
|
-
case
|
273
|
+
case 9:
|
271
274
|
requestBizId = uuid();
|
272
275
|
this.logger.logInfo({
|
273
276
|
title: 'sdk_event_sdkQuery'
|
@@ -276,12 +279,12 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
276
279
|
requestId: requestBizId
|
277
280
|
});
|
278
281
|
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
279
|
-
_context2.prev =
|
280
|
-
_context2.next =
|
282
|
+
_context2.prev = 12;
|
283
|
+
_context2.next = 15;
|
281
284
|
return requester.request(_objectSpread(_objectSpread({}, queryParams), {}, {
|
282
285
|
actionType: 'init',
|
283
286
|
integrationType: 'SDK',
|
284
|
-
sdkVersion: (_this$paymentContext$
|
287
|
+
sdkVersion: (_this$paymentContext$6 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$6 !== void 0 ? _this$paymentContext$6 : '1.0.0'
|
285
288
|
}), {
|
286
289
|
env: this.initConfig.environment,
|
287
290
|
timeout: this.SDK_REQUEST_TIMEOUT,
|
@@ -289,7 +292,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
289
292
|
needEnvInfo: true,
|
290
293
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
291
294
|
});
|
292
|
-
case
|
295
|
+
case 15:
|
293
296
|
res = _context2.sent;
|
294
297
|
this.logger.logInfo({
|
295
298
|
title: 'sdk_event_sdkQueryEnd'
|
@@ -299,9 +302,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
299
302
|
rpcTraceId: res.traceId
|
300
303
|
});
|
301
304
|
return _context2.abrupt("return", res);
|
302
|
-
case
|
303
|
-
_context2.prev =
|
304
|
-
_context2.t0 = _context2["catch"](
|
305
|
+
case 20:
|
306
|
+
_context2.prev = 20;
|
307
|
+
_context2.t0 = _context2["catch"](12);
|
305
308
|
this.logger.logError({
|
306
309
|
title: 'sdk_event_sdkQuery_failed'
|
307
310
|
}, {
|
@@ -311,11 +314,11 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
311
314
|
rpcTraceId: _context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.traceId
|
312
315
|
});
|
313
316
|
return _context2.abrupt("return", null);
|
314
|
-
case
|
317
|
+
case 24:
|
315
318
|
case "end":
|
316
319
|
return _context2.stop();
|
317
320
|
}
|
318
|
-
}, _callee2, this, [[
|
321
|
+
}, _callee2, this, [[12, 20]]);
|
319
322
|
}));
|
320
323
|
function processQuery() {
|
321
324
|
return _processQuery.apply(this, arguments);
|
@@ -326,21 +329,21 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
326
329
|
key: "processSubmitPay",
|
327
330
|
value: function () {
|
328
331
|
var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
329
|
-
var _this$
|
330
|
-
var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$
|
332
|
+
var _this$paymentContext9, _this$paymentContext10, _this$paymentContext11, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$8, _this$paymentContext12;
|
333
|
+
var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$7, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, _this$paymentContext$9, res;
|
331
334
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
332
335
|
while (1) switch (_context3.prev = _context3.next) {
|
333
336
|
case 0:
|
334
337
|
submitParams = {
|
335
|
-
paymentSessionData: ((_this$
|
336
|
-
paymentSessionConfig: (_this$
|
338
|
+
paymentSessionData: ((_this$paymentContext9 = this.paymentContext) === null || _this$paymentContext9 === void 0 ? void 0 : _this$paymentContext9.paymentSessionId) || '',
|
339
|
+
paymentSessionConfig: (_this$paymentContext10 = this.paymentContext) === null || _this$paymentContext10 === void 0 || (_this$paymentContext10 = _this$paymentContext10.paymentSessionObj) === null || _this$paymentContext10 === void 0 ? void 0 : _this$paymentContext10.paymentSessionConfig
|
337
340
|
};
|
338
341
|
_ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
|
339
|
-
_ref4 = ((_this$
|
342
|
+
_ref4 = ((_this$paymentContext11 = this.paymentContext) === null || _this$paymentContext11 === void 0 ? void 0 : _this$paymentContext11.paymentSessionObj) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$enableS = _ref4$action2.enableSignAgreement, enableSignAgreement = _ref4$action2$enableS === void 0 ? false : _ref4$action2$enableS, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
340
343
|
if (productSceneVersion === '2.0' && !autoDebitWithToken) {
|
341
344
|
///EasyPay 2.0 首次传signAgreement字段
|
342
345
|
submitParams['signAgreement'] = enableSignAgreement;
|
343
|
-
paymentMethodType = (_this$paymentContext$
|
346
|
+
paymentMethodType = (_this$paymentContext$7 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$7 === void 0 || (_this$paymentContext$7 = _this$paymentContext$7.paymentMethodInfoView) === null || _this$paymentContext$7 === void 0 ? void 0 : _this$paymentContext$7.paymentMethodType;
|
344
347
|
isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
|
345
348
|
if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
|
346
349
|
backScheme = getBackScheme(undefined, this.logger);
|
@@ -371,11 +374,12 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
371
374
|
extParams = ((_this$channelBehavior2 = this.channelBehavior) === null || _this$channelBehavior2 === void 0 || (_this$channelBehavior3 = _this$channelBehavior2.buildSubmitPayExtParams) === null || _this$channelBehavior3 === void 0 ? void 0 : _this$channelBehavior3.call(_this$channelBehavior2, {
|
372
375
|
instanceId: this.instanceId,
|
373
376
|
locale: this.initConfig.locale,
|
374
|
-
paymentMethodType: (_this$paymentContext$
|
377
|
+
paymentMethodType: (_this$paymentContext$8 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$8 === void 0 || (_this$paymentContext$8 = _this$paymentContext$8.paymentMethodInfoView) === null || _this$paymentContext$8 === void 0 ? void 0 : _this$paymentContext$8.paymentMethodType,
|
375
378
|
paymentSessionData: this.paymentContext.paymentSessionId,
|
379
|
+
paymentSessionObj: this.paymentContext.paymentSessionObj,
|
376
380
|
env: this.initConfig.environment,
|
377
381
|
sdkVersion: this.paymentContext.sdkMetaData.sdkVersion,
|
378
|
-
notRedirectAfterComplete: ((_this$
|
382
|
+
notRedirectAfterComplete: ((_this$paymentContext12 = this.paymentContext) === null || _this$paymentContext12 === void 0 || (_this$paymentContext12 = _this$paymentContext12.startBizFlowOptions) === null || _this$paymentContext12 === void 0 || (_this$paymentContext12 = _this$paymentContext12.submitPayRequestExtra) === null || _this$paymentContext12 === void 0 ? void 0 : _this$paymentContext12.notRedirectAfterComplete) === true
|
379
383
|
})) || {}; // 二次支付不再需要该参数
|
380
384
|
if (!autoDebitWithToken) {
|
381
385
|
extParams.complianceSDK = true;
|
@@ -386,7 +390,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
386
390
|
_context3.t0 = requester;
|
387
391
|
_context3.t1 = _objectSpread(_objectSpread({}, submitParams), {}, {
|
388
392
|
integrationType: 'SDK',
|
389
|
-
sdkVersion: (_this$paymentContext$
|
393
|
+
sdkVersion: (_this$paymentContext$9 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$9 !== void 0 ? _this$paymentContext$9 : '1.0.0'
|
390
394
|
});
|
391
395
|
_context3.t2 = this.initConfig.environment;
|
392
396
|
_context3.t3 = this.SDK_REQUEST_TIMEOUT;
|
@@ -445,13 +449,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
445
449
|
key: "acquireApdidToken",
|
446
450
|
value: function () {
|
447
451
|
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
448
|
-
var _this$paymentContext$
|
452
|
+
var _this$paymentContext$10;
|
449
453
|
var securityService, productScene, deviceId;
|
450
454
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
451
455
|
while (1) switch (_context4.prev = _context4.next) {
|
452
456
|
case 0:
|
453
457
|
securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
454
|
-
productScene = (_this$paymentContext$
|
458
|
+
productScene = (_this$paymentContext$10 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$10 === void 0 || (_this$paymentContext$10 = _this$paymentContext$10.paymentSessionConfig) === null || _this$paymentContext$10 === void 0 ? void 0 : _this$paymentContext$10.productScene;
|
455
459
|
deviceId = securityService.getDeviceId({
|
456
460
|
productScene: productScene
|
457
461
|
});
|
@@ -471,15 +475,15 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
471
475
|
key: "initSecuritySDK",
|
472
476
|
value: function () {
|
473
477
|
var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
474
|
-
var _this$paymentContext$
|
478
|
+
var _this$paymentContext$11, _this$paymentContext$12, _this$paymentContext$13, _this$paymentContext$14, _this$paymentContext$15, _this$paymentContext$16, productSceneVersion, nonInitSecuritySDK, signButtonDisplay, userSignAgreement, isFirstTimeToPay, shouldInitSecuritySDK;
|
475
479
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
476
480
|
while (1) switch (_context5.prev = _context5.next) {
|
477
481
|
case 0:
|
478
482
|
_context5.prev = 0;
|
479
483
|
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
480
|
-
nonInitSecuritySDK = (_this$paymentContext$
|
481
|
-
signButtonDisplay = (_this$paymentContext$
|
482
|
-
userSignAgreement = (_this$paymentContext$
|
484
|
+
nonInitSecuritySDK = (_this$paymentContext$11 = (_this$paymentContext$12 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$12 === void 0 ? void 0 : _this$paymentContext$12.nonInitSecuritySDK) !== null && _this$paymentContext$11 !== void 0 ? _this$paymentContext$11 : false;
|
485
|
+
signButtonDisplay = (_this$paymentContext$13 = (_this$paymentContext$14 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$14 === void 0 ? void 0 : _this$paymentContext$14.signButtonDisplay) !== null && _this$paymentContext$13 !== void 0 ? _this$paymentContext$13 : false;
|
486
|
+
userSignAgreement = (_this$paymentContext$15 = (_this$paymentContext$16 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$16 === void 0 ? void 0 : _this$paymentContext$16.userSignAgreement) !== null && _this$paymentContext$15 !== void 0 ? _this$paymentContext$15 : false;
|
483
487
|
isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
484
488
|
shouldInitSecuritySDK = false;
|
485
489
|
if (nonInitSecuritySDK) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
|
1
|
+
import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum, IPaymentSessionMetaData } from '../../types';
|
2
2
|
import { SDKMetaData } from '../index';
|
3
3
|
import { ESP_PAGE_NAME } from "../../constant/easysafepay";
|
4
4
|
/**
|
@@ -77,6 +77,21 @@ export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUr
|
|
77
77
|
* @param productScene - The product scene for which the checkout URL should be saved.
|
78
78
|
*/
|
79
79
|
export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url: string) => void;
|
80
|
+
/**
|
81
|
+
* 获取从外部动态下发的V2AppUrl.
|
82
|
+
*
|
83
|
+
* @param config - sessionData解析来的checkoutInfo列表.
|
84
|
+
*/
|
85
|
+
export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, configs: WebAppUrlMatchConfig[], env: string) => string;
|
86
|
+
/**
|
87
|
+
* 获取ESP从sessionData.checkoutInfo内动态下发的Url.
|
88
|
+
*/
|
89
|
+
export declare const matchEasySafePayV2Url: (params: {
|
90
|
+
configs: WebAppUrlMatchConfig[];
|
91
|
+
mid: string;
|
92
|
+
env: string;
|
93
|
+
pageName: ESP_PAGE_NAME;
|
94
|
+
}) => string;
|
80
95
|
/**
|
81
96
|
* Retrieve the saved checkout URL from localStorage for the specified product scene.
|
82
97
|
* If no url is found, a default checkout url string is returned.
|
@@ -91,10 +106,11 @@ export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, envir
|
|
91
106
|
* @param productScene - The product scene for which the default checkout URL should be provided.
|
92
107
|
*/
|
93
108
|
export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
|
94
|
-
export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, config: WebAppUrlMatchConfig[], environment: string) => string;
|
95
109
|
/**
|
96
110
|
* V2应用EasySafePay 热更新兜底URL构建规则
|
97
111
|
* 1. 兜底URL版本与sdk版本保持一致
|
98
112
|
* 2. DEV环境下html新增版本前缀
|
99
113
|
**/
|
100
114
|
export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
|
115
|
+
/**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
|
116
|
+
export declare const getDoubleFaUrlFromSession: (paymentSessionObj: IPaymentSessionMetaData, env?: string) => string;
|
@@ -176,42 +176,40 @@ export var saveLocalCheckoutUrl = function saveLocalCheckoutUrl(productScene, ur
|
|
176
176
|
};
|
177
177
|
|
178
178
|
/**
|
179
|
-
*
|
180
|
-
* If no url is found, a default checkout url string is returned.
|
181
|
-
*
|
182
|
-
* @param productScene - The product scene for which the checkout URL should be retrieved.
|
183
|
-
*/
|
184
|
-
export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene, environment) {
|
185
|
-
var key = KEY_CHECKOUT_URL + productScene;
|
186
|
-
var previousCheckoutUrl = localStorage.getItem(key);
|
187
|
-
return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene, environment);
|
188
|
-
};
|
189
|
-
|
190
|
-
/**
|
191
|
-
* Provide default checkout URL for the specified product scene.
|
192
|
-
* Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
|
179
|
+
* 获取从外部动态下发的V2AppUrl.
|
193
180
|
*
|
194
|
-
* @param
|
181
|
+
* @param config - sessionData解析来的checkoutInfo列表.
|
195
182
|
*/
|
196
|
-
export var
|
197
|
-
var
|
183
|
+
export var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene) {
|
184
|
+
var mid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
185
|
+
var configs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
186
|
+
var env = arguments.length > 3 ? arguments[3] : undefined;
|
198
187
|
switch (productScene) {
|
199
188
|
case ProductSceneEnum.EASY_PAY:
|
200
|
-
return
|
189
|
+
return matchEasySafePayV2Url({
|
190
|
+
configs: configs,
|
191
|
+
mid: mid,
|
192
|
+
env: env,
|
193
|
+
pageName: ESP_PAGE_NAME.SDK_PORTAL
|
194
|
+
});
|
201
195
|
default:
|
202
|
-
return
|
196
|
+
return defaultCheckoutUrl(productScene, env);
|
203
197
|
}
|
204
198
|
};
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
199
|
+
|
200
|
+
/**
|
201
|
+
* 获取ESP从sessionData.checkoutInfo内动态下发的Url.
|
202
|
+
*/
|
203
|
+
export var matchEasySafePayV2Url = function matchEasySafePayV2Url(params) {
|
204
|
+
var _params$configs = params.configs,
|
205
|
+
configs = _params$configs === void 0 ? [] : _params$configs,
|
206
|
+
_params$mid = params.mid,
|
207
|
+
mid = _params$mid === void 0 ? '' : _params$mid,
|
208
|
+
env = params.env,
|
209
|
+
pageName = params.pageName;
|
213
210
|
var matchURLByMid = function matchURLByMid() {
|
214
|
-
var
|
211
|
+
var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
212
|
+
var targetConfigEntry = sortedConfigs.find(function (configEntry) {
|
215
213
|
var _configEntry$mids;
|
216
214
|
var isMatchMid = !!(configEntry !== null && configEntry !== void 0 && (_configEntry$mids = configEntry.mids) !== null && _configEntry$mids !== void 0 && _configEntry$mids.includes(mid));
|
217
215
|
var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
|
@@ -219,34 +217,71 @@ export var getMatchedWebAppV2Url = function getMatchedWebAppV2Url(productScene)
|
|
219
217
|
return configEntry;
|
220
218
|
}
|
221
219
|
});
|
222
|
-
return targetConfigEntry
|
220
|
+
return targetConfigEntry;
|
223
221
|
};
|
224
222
|
var matchURLBySDKVersion = function matchURLBySDKVersion() {
|
225
|
-
var
|
223
|
+
var sortedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
224
|
+
var targetConfigEntry = sortedConfigs.find(function (configEntry) {
|
226
225
|
var isCommonConfig = (configEntry === null || configEntry === void 0 ? void 0 : configEntry.mids) === undefined;
|
227
226
|
var isMatchVersion = compareVersion(sdkVersion, configEntry.minSDKVersion) >= 0;
|
228
227
|
if (isCommonConfig && isMatchVersion) {
|
229
228
|
return configEntry;
|
230
229
|
}
|
231
230
|
});
|
232
|
-
return targetConfigEntry
|
231
|
+
return targetConfigEntry;
|
233
232
|
};
|
233
|
+
var matchConfig = function matchConfig() {
|
234
|
+
// 按SDK版本降排序
|
235
|
+
var sortedConfig = configs.sort(function (a, b) {
|
236
|
+
return compareVersion(b.minSDKVersion, a.minSDKVersion);
|
237
|
+
});
|
234
238
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
});
|
239
|
+
// 匹配仅针对部分商户生效(mid),且符合版本号的URL
|
240
|
+
var matchedURLByMid = matchURLByMid(sortedConfig);
|
241
|
+
if (matchedURLByMid) return matchedURLByMid;
|
239
242
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
+
// 匹配对所有商户生效(无mid),且符合版本号的URL
|
244
|
+
var matchedURLBySDKVersion = matchURLBySDKVersion(sortedConfig);
|
245
|
+
if (matchedURLBySDKVersion) return matchedURLBySDKVersion;
|
246
|
+
};
|
247
|
+
var defaultEspUrl = getDefaultEasySafePayPageUrl(pageName, env);
|
243
248
|
|
244
|
-
//
|
245
|
-
var
|
246
|
-
if (
|
249
|
+
// 匹配config
|
250
|
+
var config = matchConfig();
|
251
|
+
if (!config) return defaultEspUrl;
|
247
252
|
|
248
|
-
//
|
249
|
-
return
|
253
|
+
// 根据pageName匹配URL
|
254
|
+
if (pageName == ESP_PAGE_NAME.SDK_PORTAL) return (config === null || config === void 0 ? void 0 : config.url) || defaultEspUrl;
|
255
|
+
if (pageName == ESP_PAGE_NAME.DOUBLE_FA) return (config === null || config === void 0 ? void 0 : config.doubleFa) || defaultEspUrl;
|
256
|
+
return defaultEspUrl;
|
257
|
+
};
|
258
|
+
|
259
|
+
/**
|
260
|
+
* Retrieve the saved checkout URL from localStorage for the specified product scene.
|
261
|
+
* If no url is found, a default checkout url string is returned.
|
262
|
+
*
|
263
|
+
* @param productScene - The product scene for which the checkout URL should be retrieved.
|
264
|
+
*/
|
265
|
+
export var getLocalCheckoutUrl = function getLocalCheckoutUrl(productScene, environment) {
|
266
|
+
var key = KEY_CHECKOUT_URL + productScene;
|
267
|
+
var previousCheckoutUrl = localStorage.getItem(key);
|
268
|
+
return previousCheckoutUrl !== null && previousCheckoutUrl !== void 0 ? previousCheckoutUrl : defaultCheckoutUrl(productScene, environment);
|
269
|
+
};
|
270
|
+
|
271
|
+
/**
|
272
|
+
* Provide default checkout URL for the specified product scene.
|
273
|
+
* Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
|
274
|
+
*
|
275
|
+
* @param productScene - The product scene for which the default checkout URL should be provided.
|
276
|
+
*/
|
277
|
+
export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
|
278
|
+
var environment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "prod";
|
279
|
+
switch (productScene) {
|
280
|
+
case ProductSceneEnum.EASY_PAY:
|
281
|
+
return getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.SDK_PORTAL, environment);
|
282
|
+
default:
|
283
|
+
return '';
|
284
|
+
}
|
250
285
|
};
|
251
286
|
|
252
287
|
/**
|
@@ -265,4 +300,20 @@ export var getDefaultEasySafePayPageUrl = function getDefaultEasySafePayPageUrl(
|
|
265
300
|
// };
|
266
301
|
var environment = env || "prod";
|
267
302
|
if (environment === "dev") return "".concat(v2AppMarmotMap[environment], "/easysafepay/").concat(sdkVersion, "/pages/").concat(pageName, "/index-").concat(sdkVersion, ".html");else return "".concat(v2AppMarmotMap[environment], "/easysafepay/").concat(sdkVersion, "/pages/").concat(pageName, "/index.html");
|
303
|
+
};
|
304
|
+
|
305
|
+
/**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
|
306
|
+
//TODO 后续需要构造一个类,专门用于构造&存储web应用url
|
307
|
+
export var getDoubleFaUrlFromSession = function getDoubleFaUrlFromSession(paymentSessionObj) {
|
308
|
+
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "prod";
|
309
|
+
var mid = paymentSessionObj.clientId;
|
310
|
+
var extendInfo = paymentSessionObj.extendInfo;
|
311
|
+
var configs = parseWebAppUrlMatchConfig(extendInfo);
|
312
|
+
var url = matchEasySafePayV2Url({
|
313
|
+
configs: configs,
|
314
|
+
mid: mid,
|
315
|
+
env: env,
|
316
|
+
pageName: ESP_PAGE_NAME.DOUBLE_FA
|
317
|
+
});
|
318
|
+
return url;
|
268
319
|
};
|
@@ -14,8 +14,8 @@ import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
|
14
14
|
import { EnvironmentEnum } from "../../types";
|
15
15
|
import { device, isEmpty } from "../../util";
|
16
16
|
import { APPLE_PAY_RECURRING_VERSION, APPLE_PAY_VERSION } from "../applepay/interface";
|
17
|
-
import {
|
18
|
-
import {
|
17
|
+
import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
|
18
|
+
import { MODE } from "../../constant/easysafepay";
|
19
19
|
var APPLEPAYERRORENUM = /*#__PURE__*/function (APPLEPAYERRORENUM) {
|
20
20
|
APPLEPAYERRORENUM["APPLE_PAY_MISSING_DATA"] = "APPLE_PAY_MISSING_DATA";
|
21
21
|
APPLEPAYERRORENUM["APPLE_PAY_NOT_SUPPORTED"] = "APPLE_PAY_NOT_SUPPORTED";
|
@@ -68,14 +68,15 @@ export function getDoubleFaUrl(params) {
|
|
68
68
|
var instanceId = params.instanceId,
|
69
69
|
paymentMethodType = params.paymentMethodType,
|
70
70
|
paymentSessionData = params.paymentSessionData,
|
71
|
+
paymentSessionObj = params.paymentSessionObj,
|
71
72
|
locale = params.locale,
|
72
73
|
env = params.env,
|
73
74
|
sdkVersion = params.sdkVersion,
|
74
75
|
notRedirectAfterComplete = params.notRedirectAfterComplete;
|
75
76
|
var isLandscapeOrientation = false; // Web 不含横屏
|
76
77
|
|
77
|
-
var
|
78
|
-
return "".concat(
|
78
|
+
var baseDoubleFaUrl = getDoubleFaUrlFromSession(paymentSessionObj, env);
|
79
|
+
return "".concat(baseDoubleFaUrl) + '?' + "scene=cashierResultPage" + '&' + "instanceId=".concat(instanceId) + '&' + "paymentSessionData=".concat(encodeURIComponent(paymentSessionData)) + '&' + "isLandscape=".concat(isLandscapeOrientation ? 'true' : '') + '&' + "pmt=".concat(paymentMethodType) + '&' + "locale=".concat(locale) + '&' + "mode=".concat(MODE.SDK) + '&' + "sdkVersion=".concat(sdkVersion) + '&' + "¬RedirectAfterComplete=".concat(notRedirectAfterComplete);
|
79
80
|
}
|
80
81
|
export var handleGooglePay = function handleGooglePay(data) {
|
81
82
|
return new Promise(function (resolve, reject) {
|
@@ -772,6 +772,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
772
772
|
locale: _this6.AMSSDK.options.locale,
|
773
773
|
paymentMethodType: (_this6$_renderParams$ = _this6._renderParams.paymentSessionMetaData) === null || _this6$_renderParams$ === void 0 || (_this6$_renderParams$ = _this6$_renderParams$.paymentMethodInfoView) === null || _this6$_renderParams$ === void 0 ? void 0 : _this6$_renderParams$.paymentMethodType,
|
774
774
|
paymentSessionData: _this6._renderParams.sessionData,
|
775
|
+
paymentSessionObj: _this6._renderParams.paymentSessionMetaData,
|
775
776
|
env: _this6.AMSSDK.options.env.environment,
|
776
777
|
sdkVersion: _this6._appVersion,
|
777
778
|
notRedirectAfterComplete: ((_this6$_renderParams4 = _this6._renderParams) === null || _this6$_renderParams4 === void 0 ? void 0 : _this6$_renderParams4.notRedirectAfterComplete) === true
|