@alipay/ams-checkout 0.0.1755258862-dev.2 → 0.0.1755258862-dev.4

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,6 +53,14 @@ 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 - START', {
57
+ paymentContext: paymentContext
58
+ });
59
+ this.logger.logInfo({
60
+ title: '[DEBUG] - startBizFlow - START',
61
+ msg: JSON.stringify(paymentContext)
62
+ });
63
+
56
64
  // 放在最前面的逻辑
57
65
  // 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
58
66
  if (isPC()) {
@@ -69,16 +77,46 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
69
77
  requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
70
78
  authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
71
79
  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
+ });
72
97
  // 首次支付
73
98
  isFirstTimeToPay = !autoDebitWithToken; // 处理ESP1.0极速外跳支付场景
74
99
  if (!(productSceneVersion === '1.0' && isFirstTimeToPay && requireFastSdk)) {
75
- _context.next = 12;
100
+ _context.next = 18;
76
101
  break;
77
102
  }
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,不需要接口请求
78
108
  return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
79
- case 12:
109
+ case 18:
80
110
  // 下面的场景是需要渲染UI的渠道, 打开WebUrl
81
- webAppUrl = this.buildWebAppUrl(); // const webAppUrl = 'http://svc-9kvjxwjf68cptha8.cloudide.svc.et15-sqa.alipay.net:5173/src/component-app/index.html';
111
+ webAppUrl = this.buildWebAppUrl();
112
+ console.log('[DEBUG] - startBizFlow - webAppUrl built', {
113
+ webAppUrl: webAppUrl
114
+ });
115
+ this.logger.logInfo({
116
+ title: '[DEBUG] - startBizFlow - webAppUrl built',
117
+ msg: webAppUrl
118
+ });
119
+ // const webAppUrl = 'http://svc-9kvjxwjf68cptha8.cloudide.svc.et15-sqa.alipay.net:5173/src/component-app/index.html';
82
120
  resultPayload = {
83
121
  url: webAppUrl,
84
122
  allowClickPopupOutsideClose: (_this$channelBehavior = this.channelBehavior) === null || _this$channelBehavior === void 0 ? void 0 : _this$channelBehavior.allowClickOutsideClose
@@ -88,16 +126,28 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
88
126
  hostSign: this.hostSign,
89
127
  productSceneVersion: productSceneVersion
90
128
  });
91
- // 返回结果之前,发送 sessionData,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
92
- console.log('[DEBUG] sendRequestAndWaitWebLaunch start');
129
+ console.log('[DEBUG] - startBizFlow - product info saved');
130
+ this.logger.logInfo({
131
+ title: '[DEBUG] - startBizFlow - START'
132
+ });
93
133
  this.sendRequestAndWaitWebLaunch();
94
- console.log('[DEBUG] sendRequestAndWaitWebLaunch completed');
134
+ console.log('[DEBUG] - startBizFlow - sendRequestAndWaitWebLaunch completed');
135
+ this.logger.logInfo({
136
+ title: '[DEBUG] - startBizFlow - sendRequestAndWaitWebLaunch completed'
137
+ });
95
138
  // 返回结果,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
+ });
96
146
  return _context.abrupt("return", {
97
147
  behaviorType: 'RENDER',
98
148
  payload: resultPayload
99
149
  });
100
- case 19:
150
+ case 31:
101
151
  case "end":
102
152
  return _context.stop();
103
153
  }
@@ -164,21 +214,51 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
164
214
  key: "sendRequestAndWaitWebLaunch",
165
215
  value: function sendRequestAndWaitWebLaunch() {
166
216
  var _this = this;
217
+ console.log('[DEBUG] - sendRequestAndWaitWebLaunch - START');
218
+ this.logger.logInfo({
219
+ title: '[DEBUG] - sendRequestAndWaitWebLaunch - START'
220
+ });
167
221
  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
+ });
168
226
  var webLaunchPromise = new Promise(function (resolve) {
169
227
  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
+ });
170
233
  resolve(res);
171
234
  });
172
235
  });
173
236
 
174
237
  // 等请求和 Web启动都Ready之后,发送renderComponent
238
+ console.log('[DEBUG] - sendRequestAndWaitWebLaunch - waiting for promises');
239
+ this.logger.logInfo({
240
+ title: '[DEBUG] - sendRequestAndWaitWebLaunch - waiting for promises'
241
+ });
175
242
  Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
176
243
  var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
177
244
  var _ref2 = _slicedToArray(_ref, 3),
178
245
  _initSecurityRes = _ref2[0],
179
246
  submitRes = _ref2[1],
180
247
  _webLaunchRes = _ref2[2];
248
+ {}
249
+ _this.logger.logInfo({
250
+ title: '[DEBUG] - sendRequestAndWaitWebLaunch - all promises resolved'
251
+ });
181
252
  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
+ });
182
262
  eventCenter.dispatchToApp({
183
263
  event: 'renderComponent',
184
264
  data: {
@@ -223,6 +303,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
223
303
  while (1) switch (_context2.prev = _context2.next) {
224
304
  case 0:
225
305
  console.log('[DEBUG] processSubmitPay start');
306
+ this.logger.logInfo({
307
+ title: '[DEBUG] processSubmitPay start'
308
+ });
226
309
  submitParams = {
227
310
  paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionId) || '',
228
311
  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
@@ -244,14 +327,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
244
327
  this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
245
328
  //console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
246
329
  if (this.allowSubmitPayCallAhead) {
247
- _context2.next = 8;
330
+ _context2.next = 9;
248
331
  break;
249
332
  }
250
333
  return _context2.abrupt("return", {
251
334
  message: 'sdk no need to make submitPay request',
252
335
  success: true
253
336
  });
254
- case 8:
337
+ case 9:
255
338
  requestBizId = uuid(); // 下面真实发请求
256
339
  this.logger.logInfo({
257
340
  title: 'sdk_event_submitPay'
@@ -271,13 +354,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
271
354
  extParams.complianceSDK = true;
272
355
  submitParams.extParams = extParams;
273
356
  requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
274
- _context2.prev = 14;
357
+ _context2.prev = 15;
275
358
  _context2.t0 = requester;
276
359
  _context2.t1 = submitParams;
277
360
  _context2.t2 = this.initConfig.environment;
278
- _context2.next = 20;
361
+ _context2.next = 21;
279
362
  return this.acquireApdidToken();
280
- case 20:
363
+ case 21:
281
364
  _context2.t3 = _context2.sent;
282
365
  _context2.t4 = {
283
366
  deviceId: _context2.t3
@@ -291,9 +374,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
291
374
  needEnvInfo: true,
292
375
  'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
293
376
  };
294
- _context2.next = 26;
377
+ _context2.next = 27;
295
378
  return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
296
- case 26:
379
+ case 27:
297
380
  res = _context2.sent;
298
381
  this.logger.logInfo({
299
382
  title: 'sdk_event_submitPayEnd'
@@ -303,10 +386,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
303
386
  rpcTraceId: res.traceId
304
387
  });
305
388
  console.log('[DEBUG] processSubmitPay completed', res);
389
+ this.logger.logInfo({
390
+ title: '[DEBUG] processSubmitPay completed',
391
+ msg: JSON.stringify(res)
392
+ });
306
393
  return _context2.abrupt("return", res);
307
- case 32:
308
- _context2.prev = 32;
309
- _context2.t7 = _context2["catch"](14);
394
+ case 34:
395
+ _context2.prev = 34;
396
+ _context2.t7 = _context2["catch"](15);
310
397
  this.logger.logError({
311
398
  title: 'sdk_event_submitPay_failed'
312
399
  }, {
@@ -316,12 +403,16 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
316
403
  rpcTraceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
317
404
  });
318
405
  console.log('[DEBUG] processSubmitPay ERROR', _context2.t7);
406
+ this.logger.logError({
407
+ title: '[DEBUG] processSubmitPay ERROR',
408
+ msg: _context2.t7
409
+ });
319
410
  throw _context2.t7;
320
- case 37:
411
+ case 40:
321
412
  case "end":
322
413
  return _context2.stop();
323
414
  }
324
- }, _callee2, this, [[14, 32]]);
415
+ }, _callee2, this, [[15, 34]]);
325
416
  }));
326
417
  function processSubmitPay() {
327
418
  return _processSubmitPay.apply(this, arguments);
@@ -363,7 +454,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
363
454
  while (1) switch (_context4.prev = _context4.next) {
364
455
  case 0:
365
456
  console.log('[DEBUG] initSecuritySDK start');
366
- _context4.prev = 1;
457
+ this.logger.logInfo({
458
+ title: '[DEBUG] initSecuritySDK start'
459
+ });
460
+ _context4.prev = 2;
367
461
  productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
368
462
  nonCompliant = (_this$paymentContext$8 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$8 === void 0 ? void 0 : _this$paymentContext$8.nonCompliant;
369
463
  nonInitSecuritySDK = (_this$paymentContext$9 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$9 === void 0 ? void 0 : _this$paymentContext$9.nonInitSecuritySDK;
@@ -396,30 +490,37 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
396
490
  }
397
491
  }
398
492
  if (!shouldInitSecuritySDK) {
399
- _context4.next = 11;
493
+ _context4.next = 12;
400
494
  break;
401
495
  }
402
- _context4.next = 11;
496
+ _context4.next = 12;
403
497
  return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
404
- case 11:
498
+ case 12:
405
499
  console.log('[DEBUG] initSecuritySDK completed');
500
+ this.logger.logInfo({
501
+ title: '[DEBUG] initSecuritySDK completed'
502
+ });
406
503
  this.logger.logInfo({
407
504
  title: 'a3753.b101271.c388193.d514078'
408
505
  }, {
409
506
  riskSdkInfo: shouldInitSecuritySDK ? RiskSdkInfoEnum.NEED : RiskSdkInfoEnum.NO_NEED
410
507
  });
411
- _context4.next = 18;
508
+ _context4.next = 21;
412
509
  break;
413
- case 15:
414
- _context4.prev = 15;
415
- _context4.t0 = _context4["catch"](1);
510
+ case 17:
511
+ _context4.prev = 17;
512
+ _context4.t0 = _context4["catch"](2);
416
513
  console.log('[DEBUG] initSecuritySDK ERROR');
514
+ this.logger.logError({
515
+ title: '[DEBUG] initSecuritySDK ERROR',
516
+ msg: _context4.t0
517
+ });
417
518
  // do nothing when init security failed
418
- case 18:
519
+ case 21:
419
520
  case "end":
420
521
  return _context4.stop();
421
522
  }
422
- }, _callee4, this, [[1, 15]]);
523
+ }, _callee4, this, [[2, 17]]);
423
524
  }));
424
525
  function initSecuritySDK() {
425
526
  return _initSecuritySDK.apply(this, arguments);
@@ -46,11 +46,19 @@ export var RequesterService = /*#__PURE__*/function () {
46
46
  key: "request",
47
47
  value: (function () {
48
48
  var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestData, options) {
49
- var envInfo, _data, startTime, traceId, myRequest, data, headers, response, resData, handleGetWayError, errorMessage, errorCode, _error$message, _error, timeoutCode, _errorCode;
49
+ var logger, envInfo, _data, startTime, traceId, myRequest, _yield$myRequest, data, headers, resData, handleGetWayError, errorMessage, errorCode, _error$message, _error, timeoutCode, _errorCode;
50
50
  return _regeneratorRuntime().wrap(function _callee$(_context) {
51
51
  while (1) switch (_context.prev = _context.next) {
52
52
  case 0:
53
53
  console.log('[DEBUG] request start', requestData, options);
54
+ logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
55
+ logger.logInfo({
56
+ title: '[DEBUG] request start',
57
+ msg: JSON.stringify({
58
+ requestData: requestData,
59
+ options: options
60
+ })
61
+ });
54
62
  envInfo = this.getEnvInfo(options);
55
63
  _data = [_objectSpread(_objectSpread({}, requestData), {}, {
56
64
  envInfo: envInfo,
@@ -60,40 +68,65 @@ export var RequesterService = /*#__PURE__*/function () {
60
68
  })];
61
69
  startTime = Date.now();
62
70
  traceId = '';
63
- _context.prev = 5;
71
+ _context.prev = 7;
64
72
  console.log('[DEBUG] createRequestInstance start');
73
+ logger.logInfo({
74
+ title: '[DEBUG] createRequestInstance start'
75
+ });
65
76
  myRequest = this.createRequestInstance(options);
66
77
  console.log('[DEBUG] createRequestInstance completed', myRequest);
67
- _context.prev = 9;
78
+ logger.logInfo({
79
+ title: '[DEBUG] createRequestInstance completed',
80
+ msg: JSON.stringify({
81
+ myRequest: myRequest
82
+ })
83
+ });
68
84
  console.log('[DEBUG] myRequest start');
69
- _context.next = 13;
85
+ logger.logInfo({
86
+ title: '[DEBUG] myRequest start'
87
+ });
88
+ _context.next = 17;
70
89
  return myRequest({
71
90
  data: _data
72
91
  });
73
- case 13:
74
- response = _context.sent;
75
- data = response.data;
76
- headers = response.headers;
92
+ case 17:
93
+ _yield$myRequest = _context.sent;
94
+ data = _yield$myRequest.data;
95
+ headers = _yield$myRequest.headers;
77
96
  console.log('[DEBUG] myRequest completed', data, headers);
78
- _context.next = 23;
79
- break;
80
- case 19:
81
- _context.prev = 19;
82
- _context.t0 = _context["catch"](9);
83
- console.error('[DEBUG] myRequest failed', _context.t0);
84
- throw _context.t0;
85
- case 23:
97
+ logger.logInfo({
98
+ title: '[DEBUG] myRequest completed',
99
+ msg: JSON.stringify({
100
+ data: data,
101
+ headers: headers
102
+ })
103
+ });
86
104
  resData = data || {};
87
105
  traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
88
106
  resData.traceId = traceId || '';
89
107
  console.log('[DEBUG] handleGetWayError start');
108
+ logger.logInfo({
109
+ title: '[DEBUG] handleGetWayError start'
110
+ });
90
111
  handleGetWayError = fomatGetwayError(headers, traceId);
91
112
  console.log('[DEBUG] handleGetWayError completed', handleGetWayError);
113
+ logger.logInfo({
114
+ title: '[DEBUG] handleGetWayError completed',
115
+ msg: JSON.stringify({
116
+ handleGetWayError: handleGetWayError
117
+ })
118
+ });
92
119
  if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
93
- _context.next = 36;
120
+ _context.next = 39;
94
121
  break;
95
122
  }
96
123
  console.log('[DEBUG] handleGetWayError errorCode', handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode);
124
+ logger.logInfo({
125
+ title: '[DEBUG] handleGetWayError errorCode',
126
+ msg: JSON.stringify({
127
+ errorCode: handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode
128
+ })
129
+ });
97
130
  errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
98
131
  errorCode = handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode;
99
132
  this.reportRequestTimeCost({
@@ -111,12 +144,20 @@ export var RequesterService = /*#__PURE__*/function () {
111
144
  errorCode: errorCode,
112
145
  success: false
113
146
  });
147
+ logger.logInfo({
148
+ title: '[DEBUG] handleGetWayError error',
149
+ msg: JSON.stringify({
150
+ errorMessage: errorMessage,
151
+ errorCode: errorCode,
152
+ success: false
153
+ })
154
+ });
114
155
  throw new Error(JSON.stringify({
115
156
  errorMessage: errorMessage,
116
157
  errorCode: errorCode,
117
158
  success: false
118
159
  }));
119
- case 36:
160
+ case 39:
120
161
  this.reportRequestTimeCost({
121
162
  title: 'a3753.b101271.c388193.d521387',
122
163
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
@@ -128,18 +169,31 @@ export var RequesterService = /*#__PURE__*/function () {
128
169
  traceId: traceId
129
170
  });
130
171
  console.log('[DEBUG] request completed', resData);
172
+ logger.logInfo({
173
+ title: '[DEBUG] request completed',
174
+ msg: JSON.stringify({
175
+ resData: resData
176
+ })
177
+ });
131
178
  return _context.abrupt("return", resData);
132
- case 41:
133
- _context.prev = 41;
134
- _context.t1 = _context["catch"](5);
135
- _error = safeJson(_context.t1 === null || _context.t1 === void 0 ? void 0 : _context.t1.message, {
179
+ case 45:
180
+ _context.prev = 45;
181
+ _context.t0 = _context["catch"](7);
182
+ _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
136
183
  success: false,
137
184
  errorCode: errorEnum.SYSTEM,
138
185
  traceId: traceId,
139
- errorMessage: _context.t1 === null || _context.t1 === void 0 ? void 0 : _context.t1.message
186
+ errorMessage: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message
187
+ });
188
+ console.log('[DEBUG] request error 1', _error, 'Original error:', _context.t0);
189
+ logger.logInfo({
190
+ title: '[DEBUG] request error 1',
191
+ msg: JSON.stringify({
192
+ _error: _error,
193
+ originalError: _context.t0
194
+ })
140
195
  });
141
- console.log('[DEBUG] request error 1', _error, 'Original error:', _context.t1);
142
- timeoutCode = _context.t1 !== null && _context.t1 !== void 0 && (_error$message = _context.t1.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
196
+ timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
143
197
  _errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
144
198
  this.reportRequestTimeCost({
145
199
  title: 'a3753.b101271.c388193.d521387',
@@ -148,7 +202,7 @@ export var RequesterService = /*#__PURE__*/function () {
148
202
  time: Date.now() - startTime,
149
203
  success: false,
150
204
  code: _errorCode,
151
- msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t1)
205
+ msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
152
206
  });
153
207
  console.log('[DEBUG] request error 2', {
154
208
  success: false,
@@ -156,17 +210,26 @@ export var RequesterService = /*#__PURE__*/function () {
156
210
  traceId: traceId,
157
211
  errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
158
212
  });
213
+ logger.logInfo({
214
+ title: '[DEBUG] request error 2',
215
+ msg: JSON.stringify({
216
+ success: false,
217
+ errorCode: _errorCode,
218
+ traceId: traceId,
219
+ errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
220
+ })
221
+ });
159
222
  return _context.abrupt("return", Promise.reject({
160
223
  success: false,
161
224
  errorCode: _errorCode,
162
225
  traceId: traceId,
163
226
  errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
164
227
  }));
165
- case 50:
228
+ case 56:
166
229
  case "end":
167
230
  return _context.stop();
168
231
  }
169
- }, _callee, this, [[5, 41], [9, 19]]);
232
+ }, _callee, this, [[7, 45]]);
170
233
  }));
171
234
  function request(_x, _x2) {
172
235
  return _request.apply(this, arguments);
@@ -225,14 +288,35 @@ export var RequesterService = /*#__PURE__*/function () {
225
288
  withCredentials: options.withCredentials,
226
289
  headers: Object.keys(options.headers || {})
227
290
  });
291
+ var logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
292
+ logger.logInfo({
293
+ title: '[DEBUG] createRequestInstance start',
294
+ msg: JSON.stringify({
295
+ env: options.env,
296
+ 'Operation-Type': options['Operation-Type'],
297
+ hostSign: options === null || options === void 0 ? void 0 : options.hostSign,
298
+ timeout: options.timeout,
299
+ method: options === null || options === void 0 ? void 0 : options.method,
300
+ withCredentials: options.withCredentials,
301
+ headers: Object.keys(options.headers || {})
302
+ })
303
+ });
228
304
  var date = new Date(); // 获取当前时间
229
305
  var timestamp = date.getTime(); // 获取时间戳
230
306
  var utcTimestamp = timestamp + date.getTimezoneOffset() * 60 * 1000; // 获取 UTC 时间戳
231
307
  var env = options.env || 'prod';
232
308
  var lightSandboxConfig = lightSandboxMap(options['Operation-Type'], env); // light_sandbox
233
309
  console.log('[DEBUG] lightSandboxConfig:', lightSandboxConfig);
310
+ logger.logInfo({
311
+ title: '[DEBUG] lightSandboxConfig',
312
+ msg: JSON.stringify(lightSandboxConfig)
313
+ });
234
314
  var baseURL = options.baseURL || lightSandboxConfig.baseURL || hostSignMap(options === null || options === void 0 ? void 0 : options.hostSign, env) || requestHost[env];
235
315
  console.log('[DEBUG] baseURL:', baseURL);
316
+ logger.logInfo({
317
+ title: '[DEBUG] baseURL',
318
+ msg: baseURL
319
+ });
236
320
  var _headers = _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
237
321
  appId: lightSandboxConfig.appId || appId,
238
322
  workspaceId: options.env === 'pre' ? 'pre' : 'default'
@@ -245,7 +329,23 @@ export var RequesterService = /*#__PURE__*/function () {
245
329
  }
246
330
  if (env !== 'dev') delete _headers['sofa-group-name'];
247
331
  console.log('[DEBUG] request headers keys:', Object.keys(_headers));
248
- console.log('[DEBUG] axios:', axios);
332
+ logger.logInfo({
333
+ title: '[DEBUG] request headers keys',
334
+ msg: JSON.stringify(Object.keys(_headers))
335
+ });
336
+
337
+ // 确保 axios 库正确加载
338
+ if (typeof axios === 'undefined') {
339
+ console.log('[DEBUG] axios undefined');
340
+ logger.logError({
341
+ title: '[DEBUG] axios undefined'
342
+ });
343
+ }
344
+ console.log('[DEBUG] axios version:', axios.VERSION);
345
+ logger.logInfo({
346
+ title: '[DEBUG] axios version',
347
+ msg: axios.VERSION
348
+ });
249
349
  var instance = axios.create({
250
350
  baseURL: baseURL,
251
351
  timeout: (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 15000,
@@ -259,8 +359,28 @@ export var RequesterService = /*#__PURE__*/function () {
259
359
  method: instance.defaults.method,
260
360
  withCredentials: instance.defaults.withCredentials
261
361
  });
262
- return instance.request;
263
- // return instance.request.bind(instance);
362
+ logger.logInfo({
363
+ title: '[DEBUG] axios instance created',
364
+ msg: JSON.stringify({
365
+ baseURL: instance.defaults.baseURL,
366
+ timeout: instance.defaults.timeout,
367
+ method: instance.defaults.method,
368
+ withCredentials: instance.defaults.withCredentials
369
+ })
370
+ });
371
+ console.log('[DEBUG] instance.request', instance.request);
372
+ logger.logInfo({
373
+ title: '[DEBUG] instance.request',
374
+ msg: JSON.stringify(instance.request)
375
+ });
376
+ console.log('[DEBUG] instance.request.bind(instance)', instance.request.bind(instance));
377
+ logger.logInfo({
378
+ title: '[DEBUG] instance.request.bind',
379
+ msg: JSON.stringify(instance.request.bind(instance))
380
+ });
381
+
382
+ // return instance.request;
383
+ return instance.request.bind(instance);
264
384
  }
265
385
  }]);
266
386
  return RequesterService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1755258862-dev.2",
3
+ "version": "0.0.1755258862-dev.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",