@alipay/ams-checkout 0.0.1755258862-dev.4 → 0.0.1755258862-dev.5
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.
@@ -53,16 +53,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
53
53
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
54
54
|
while (1) switch (_context.prev = _context.next) {
|
55
55
|
case 0:
|
56
|
-
console.log('[DEBUG] - startBizFlow
|
57
|
-
paymentContext: paymentContext
|
58
|
-
});
|
59
|
-
this.logger.logInfo({
|
60
|
-
title: '[DEBUG] - startBizFlow - START',
|
61
|
-
msg: JSON.stringify(paymentContext)
|
62
|
-
});
|
63
|
-
|
56
|
+
console.log('[DEBUG] - startBizFlow begin with paymentContext:', paymentContext);
|
64
57
|
// 放在最前面的逻辑
|
65
58
|
// 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
|
59
|
+
console.log('[DEBUG] - startBizFlow check isPC:', isPC());
|
66
60
|
if (isPC()) {
|
67
61
|
// 非TOSS渠道,在PC场景需要改成1.0
|
68
62
|
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)) {
|
@@ -77,45 +71,22 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
77
71
|
requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
|
78
72
|
authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
|
79
73
|
this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
|
80
|
-
console.log('[DEBUG] - startBizFlow - variables initialized', {
|
81
|
-
productSceneVersion: productSceneVersion,
|
82
|
-
paymentMethodCategoryType: paymentMethodCategoryType,
|
83
|
-
autoDebitWithToken: autoDebitWithToken,
|
84
|
-
requireFastSdk: requireFastSdk,
|
85
|
-
hostSign: this.hostSign
|
86
|
-
});
|
87
|
-
this.logger.logInfo({
|
88
|
-
title: '[DEBUG] - startBizFlow - variables initialized',
|
89
|
-
msg: JSON.stringify({
|
90
|
-
productSceneVersion: productSceneVersion,
|
91
|
-
paymentMethodCategoryType: paymentMethodCategoryType,
|
92
|
-
autoDebitWithToken: autoDebitWithToken,
|
93
|
-
requireFastSdk: requireFastSdk,
|
94
|
-
hostSign: this.hostSign
|
95
|
-
})
|
96
|
-
});
|
97
74
|
// 首次支付
|
98
75
|
isFirstTimeToPay = !autoDebitWithToken; // 处理ESP1.0极速外跳支付场景
|
76
|
+
console.log('[DEBUG] - startBizFlow check fastSdk conditions:', {
|
77
|
+
productSceneVersion: productSceneVersion,
|
78
|
+
isFirstTimeToPay: isFirstTimeToPay,
|
79
|
+
requireFastSdk: requireFastSdk
|
80
|
+
});
|
99
81
|
if (!(productSceneVersion === '1.0' && isFirstTimeToPay && requireFastSdk)) {
|
100
|
-
_context.next =
|
82
|
+
_context.next = 15;
|
101
83
|
break;
|
102
84
|
}
|
103
|
-
console.log('[DEBUG] - startBizFlow - ESP1.0 fast redirect scenario');
|
104
|
-
this.logger.logInfo({
|
105
|
-
title: '[DEBUG] - startBizFlow - ESP1.0 fast redirect scenario'
|
106
|
-
});
|
107
|
-
// EASY_PAY 1.0首次支付,requireFastSdk为true,不需要接口请求
|
108
85
|
return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
|
109
|
-
case
|
86
|
+
case 15:
|
110
87
|
// 下面的场景是需要渲染UI的渠道, 打开WebUrl
|
111
88
|
webAppUrl = this.buildWebAppUrl();
|
112
|
-
console.log('[DEBUG] - startBizFlow
|
113
|
-
webAppUrl: webAppUrl
|
114
|
-
});
|
115
|
-
this.logger.logInfo({
|
116
|
-
title: '[DEBUG] - startBizFlow - webAppUrl built',
|
117
|
-
msg: webAppUrl
|
118
|
-
});
|
89
|
+
console.log('[DEBUG] - startBizFlow webAppUrl:', webAppUrl);
|
119
90
|
// const webAppUrl = 'http://svc-9kvjxwjf68cptha8.cloudide.svc.et15-sqa.alipay.net:5173/src/component-app/index.html';
|
120
91
|
resultPayload = {
|
121
92
|
url: webAppUrl,
|
@@ -126,28 +97,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
126
97
|
hostSign: this.hostSign,
|
127
98
|
productSceneVersion: productSceneVersion
|
128
99
|
});
|
129
|
-
|
130
|
-
this.logger.logInfo({
|
131
|
-
title: '[DEBUG] - startBizFlow - START'
|
132
|
-
});
|
100
|
+
// 返回结果之前,发送 sessionData,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
|
133
101
|
this.sendRequestAndWaitWebLaunch();
|
134
|
-
console.log('[DEBUG] - startBizFlow - sendRequestAndWaitWebLaunch completed');
|
135
|
-
this.logger.logInfo({
|
136
|
-
title: '[DEBUG] - startBizFlow - sendRequestAndWaitWebLaunch completed'
|
137
|
-
});
|
138
102
|
// 返回结果,RENDER,让外层去处理iframe加载等逻辑
|
139
|
-
console.log('[DEBUG] - startBizFlow - returning RENDER behavior', {
|
140
|
-
resultPayload: resultPayload
|
141
|
-
});
|
142
|
-
this.logger.logInfo({
|
143
|
-
title: '[DEBUG] - startBizFlow - returning RENDER behavior',
|
144
|
-
msg: JSON.stringify(resultPayload)
|
145
|
-
});
|
146
103
|
return _context.abrupt("return", {
|
147
104
|
behaviorType: 'RENDER',
|
148
105
|
payload: resultPayload
|
149
106
|
});
|
150
|
-
case
|
107
|
+
case 21:
|
151
108
|
case "end":
|
152
109
|
return _context.stop();
|
153
110
|
}
|
@@ -214,51 +171,24 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
214
171
|
key: "sendRequestAndWaitWebLaunch",
|
215
172
|
value: function sendRequestAndWaitWebLaunch() {
|
216
173
|
var _this = this;
|
217
|
-
console.log('[DEBUG] - sendRequestAndWaitWebLaunch
|
218
|
-
this.logger.logInfo({
|
219
|
-
title: '[DEBUG] - sendRequestAndWaitWebLaunch - START'
|
220
|
-
});
|
174
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch start');
|
221
175
|
var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
222
|
-
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - eventCenter initialized');
|
223
|
-
this.logger.logInfo({
|
224
|
-
title: '[DEBUG] - sendRequestAndWaitWebLaunch - eventCenter initialized'
|
225
|
-
});
|
226
176
|
var webLaunchPromise = new Promise(function (resolve) {
|
227
177
|
eventCenter.listen('onLaunch', function (res) {
|
228
|
-
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - onLaunch event received', res);
|
229
|
-
_this.logger.logInfo({
|
230
|
-
title: '[DEBUG] - sendRequestAndWaitWebLaunch - onLaunch event received',
|
231
|
-
msg: res
|
232
|
-
});
|
233
178
|
resolve(res);
|
234
179
|
});
|
235
180
|
});
|
236
181
|
|
237
182
|
// 等请求和 Web启动都Ready之后,发送renderComponent
|
238
|
-
console.log('[DEBUG] - sendRequestAndWaitWebLaunch
|
239
|
-
this.logger.logInfo({
|
240
|
-
title: '[DEBUG] - sendRequestAndWaitWebLaunch - waiting for promises'
|
241
|
-
});
|
183
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch waiting for promises');
|
242
184
|
Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
|
243
185
|
var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
|
244
186
|
var _ref2 = _slicedToArray(_ref, 3),
|
245
187
|
_initSecurityRes = _ref2[0],
|
246
188
|
submitRes = _ref2[1],
|
247
189
|
_webLaunchRes = _ref2[2];
|
248
|
-
|
249
|
-
_this.logger.logInfo({
|
250
|
-
title: '[DEBUG] - sendRequestAndWaitWebLaunch - all promises resolved'
|
251
|
-
});
|
190
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch all promises resolved');
|
252
191
|
var logMetaData = _this.logger.getLogConfig().mdata;
|
253
|
-
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - logMetaData', logMetaData);
|
254
|
-
_this.logger.logInfo({
|
255
|
-
title: '[DEBUG] - sendRequestAndWaitWebLaunch - logMetaData',
|
256
|
-
msg: JSON.stringify(logMetaData)
|
257
|
-
});
|
258
|
-
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - dispatching renderComponent');
|
259
|
-
_this.logger.logInfo({
|
260
|
-
title: '[DEBUG] - sendRequestAndWaitWebLaunch - dispatching renderComponent'
|
261
|
-
});
|
262
192
|
eventCenter.dispatchToApp({
|
263
193
|
event: 'renderComponent',
|
264
194
|
data: {
|
@@ -289,8 +219,6 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
289
219
|
})
|
290
220
|
}
|
291
221
|
});
|
292
|
-
}, function (error) {
|
293
|
-
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - ERROR', error);
|
294
222
|
});
|
295
223
|
}
|
296
224
|
}, {
|
@@ -302,16 +230,17 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
302
230
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
303
231
|
while (1) switch (_context2.prev = _context2.next) {
|
304
232
|
case 0:
|
305
|
-
console.log('[DEBUG] processSubmitPay start');
|
306
|
-
this.logger.logInfo({
|
307
|
-
title: '[DEBUG] processSubmitPay start'
|
308
|
-
});
|
233
|
+
console.log('[DEBUG] - processSubmitPay start');
|
309
234
|
submitParams = {
|
310
235
|
paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionId) || '',
|
311
236
|
paymentSessionConfig: (_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.paymentSessionObj) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionConfig
|
312
237
|
};
|
313
238
|
_ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
|
314
239
|
_ref4 = ((_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.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;
|
240
|
+
console.log('[DEBUG] - processSubmitPay check productSceneVersion:', {
|
241
|
+
productSceneVersion: productSceneVersion,
|
242
|
+
autoDebitWithToken: autoDebitWithToken
|
243
|
+
});
|
315
244
|
if (productSceneVersion === '2.0' && !autoDebitWithToken) {
|
316
245
|
///EasyPay 2.0 首次传signAgreement字段
|
317
246
|
submitParams['signAgreement'] = enableSignAgreement;
|
@@ -326,15 +255,16 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
326
255
|
}
|
327
256
|
this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
|
328
257
|
//console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
|
258
|
+
console.log('[DEBUG] - processSubmitPay check allowSubmitPayCallAhead:', this.allowSubmitPayCallAhead);
|
329
259
|
if (this.allowSubmitPayCallAhead) {
|
330
|
-
_context2.next =
|
260
|
+
_context2.next = 10;
|
331
261
|
break;
|
332
262
|
}
|
333
263
|
return _context2.abrupt("return", {
|
334
264
|
message: 'sdk no need to make submitPay request',
|
335
265
|
success: true
|
336
266
|
});
|
337
|
-
case
|
267
|
+
case 10:
|
338
268
|
requestBizId = uuid(); // 下面真实发请求
|
339
269
|
this.logger.logInfo({
|
340
270
|
title: 'sdk_event_submitPay'
|
@@ -354,13 +284,21 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
354
284
|
extParams.complianceSDK = true;
|
355
285
|
submitParams.extParams = extParams;
|
356
286
|
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
357
|
-
_context2.prev =
|
287
|
+
_context2.prev = 16;
|
288
|
+
console.log('[DEBUG] - processSubmitPay making request with params:', submitParams);
|
289
|
+
// console.log('[web-sdk] DO call submitPay');
|
290
|
+
console.log('[DEBUG] - processSubmitPay request config:', {
|
291
|
+
env: this.initConfig.environment,
|
292
|
+
timeout: 15000,
|
293
|
+
hostSign: this.hostSign,
|
294
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
295
|
+
});
|
358
296
|
_context2.t0 = requester;
|
359
297
|
_context2.t1 = submitParams;
|
360
298
|
_context2.t2 = this.initConfig.environment;
|
361
|
-
_context2.next =
|
299
|
+
_context2.next = 24;
|
362
300
|
return this.acquireApdidToken();
|
363
|
-
case
|
301
|
+
case 24:
|
364
302
|
_context2.t3 = _context2.sent;
|
365
303
|
_context2.t4 = {
|
366
304
|
deviceId: _context2.t3
|
@@ -374,9 +312,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
374
312
|
needEnvInfo: true,
|
375
313
|
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
376
314
|
};
|
377
|
-
_context2.next =
|
315
|
+
_context2.next = 30;
|
378
316
|
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
|
379
|
-
case
|
317
|
+
case 30:
|
380
318
|
res = _context2.sent;
|
381
319
|
this.logger.logInfo({
|
382
320
|
title: 'sdk_event_submitPayEnd'
|
@@ -385,15 +323,11 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
385
323
|
requestId: requestBizId,
|
386
324
|
rpcTraceId: res.traceId
|
387
325
|
});
|
388
|
-
console.log('[DEBUG] processSubmitPay
|
389
|
-
this.logger.logInfo({
|
390
|
-
title: '[DEBUG] processSubmitPay completed',
|
391
|
-
msg: JSON.stringify(res)
|
392
|
-
});
|
326
|
+
console.log('[DEBUG] - processSubmitPay request success:', res);
|
393
327
|
return _context2.abrupt("return", res);
|
394
|
-
case
|
395
|
-
_context2.prev =
|
396
|
-
_context2.t7 = _context2["catch"](
|
328
|
+
case 36:
|
329
|
+
_context2.prev = 36;
|
330
|
+
_context2.t7 = _context2["catch"](16);
|
397
331
|
this.logger.logError({
|
398
332
|
title: 'sdk_event_submitPay_failed'
|
399
333
|
}, {
|
@@ -402,17 +336,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
402
336
|
requestId: requestBizId,
|
403
337
|
rpcTraceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
|
404
338
|
});
|
405
|
-
console.log('[DEBUG] processSubmitPay
|
406
|
-
this.logger.logError({
|
407
|
-
title: '[DEBUG] processSubmitPay ERROR',
|
408
|
-
msg: _context2.t7
|
409
|
-
});
|
339
|
+
console.log('[DEBUG] - processSubmitPay request failed:', _context2.t7);
|
410
340
|
throw _context2.t7;
|
411
|
-
case
|
341
|
+
case 41:
|
412
342
|
case "end":
|
413
343
|
return _context2.stop();
|
414
344
|
}
|
415
|
-
}, _callee2, this, [[
|
345
|
+
}, _callee2, this, [[16, 36]]);
|
416
346
|
}));
|
417
347
|
function processSubmitPay() {
|
418
348
|
return _processSubmitPay.apply(this, arguments);
|
@@ -453,11 +383,8 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
453
383
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
454
384
|
while (1) switch (_context4.prev = _context4.next) {
|
455
385
|
case 0:
|
456
|
-
console.log('[DEBUG] initSecuritySDK start');
|
457
|
-
|
458
|
-
title: '[DEBUG] initSecuritySDK start'
|
459
|
-
});
|
460
|
-
_context4.prev = 2;
|
386
|
+
console.log('[DEBUG] - initSecuritySDK start');
|
387
|
+
_context4.prev = 1;
|
461
388
|
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
462
389
|
nonCompliant = (_this$paymentContext$8 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$8 === void 0 ? void 0 : _this$paymentContext$8.nonCompliant;
|
463
390
|
nonInitSecuritySDK = (_this$paymentContext$9 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$9 === void 0 ? void 0 : _this$paymentContext$9.nonInitSecuritySDK;
|
@@ -489,6 +416,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
489
416
|
}
|
490
417
|
}
|
491
418
|
}
|
419
|
+
console.log('[DEBUG] - initSecuritySDK shouldInitSecuritySDK:', shouldInitSecuritySDK);
|
492
420
|
if (!shouldInitSecuritySDK) {
|
493
421
|
_context4.next = 12;
|
494
422
|
break;
|
@@ -496,31 +424,24 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
496
424
|
_context4.next = 12;
|
497
425
|
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
498
426
|
case 12:
|
499
|
-
console.log('[DEBUG] initSecuritySDK completed');
|
500
|
-
this.logger.logInfo({
|
501
|
-
title: '[DEBUG] initSecuritySDK completed'
|
502
|
-
});
|
503
427
|
this.logger.logInfo({
|
504
428
|
title: 'a3753.b101271.c388193.d514078'
|
505
429
|
}, {
|
506
430
|
riskSdkInfo: shouldInitSecuritySDK ? RiskSdkInfoEnum.NEED : RiskSdkInfoEnum.NO_NEED
|
507
431
|
});
|
508
|
-
|
432
|
+
console.log('[DEBUG] - initSecuritySDK completed');
|
433
|
+
_context4.next = 19;
|
509
434
|
break;
|
510
|
-
case
|
511
|
-
_context4.prev =
|
512
|
-
_context4.t0 = _context4["catch"](
|
513
|
-
console.log('[DEBUG] initSecuritySDK ERROR');
|
514
|
-
this.logger.logError({
|
515
|
-
title: '[DEBUG] initSecuritySDK ERROR',
|
516
|
-
msg: _context4.t0
|
517
|
-
});
|
435
|
+
case 16:
|
436
|
+
_context4.prev = 16;
|
437
|
+
_context4.t0 = _context4["catch"](1);
|
518
438
|
// do nothing when init security failed
|
519
|
-
|
439
|
+
console.log('[DEBUG] - initSecuritySDK catch');
|
440
|
+
case 19:
|
520
441
|
case "end":
|
521
442
|
return _context4.stop();
|
522
443
|
}
|
523
|
-
}, _callee4, this, [[
|
444
|
+
}, _callee4, this, [[1, 16]]);
|
524
445
|
}));
|
525
446
|
function initSecuritySDK() {
|
526
447
|
return _initSecuritySDK.apply(this, arguments);
|
@@ -1,4 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { PaymentContext, Service } from '../../index';
|
2
|
+
import type { IoptionsParams, RequestConfig } from '../../../types';
|
3
|
+
import type { SDKMetaData } from '../../index';
|
2
4
|
/**
|
3
5
|
* @author congle.zzq <congle.zzq@alipay.com>
|
4
6
|
* @date 2024/9/18
|