21
This commit is contained in:
parent
01efec146c
commit
c7bf419208
|
|
@ -151,7 +151,25 @@ public class WechatPayV3Service : IWechatPayV3Service
|
|||
|
||||
_logger.LogDebug("V3 下单请求: URL={Url}, Body={Body}", V3_JSAPI_URL, requestBody);
|
||||
|
||||
var response = await _httpClient.SendAsync(httpRequest);
|
||||
HttpResponseMessage response;
|
||||
try
|
||||
{
|
||||
response = await _httpClient.SendAsync(httpRequest);
|
||||
}
|
||||
catch (HttpRequestException ex) when (ex.InnerException is IOException)
|
||||
{
|
||||
// SSL 冷启动可能导致首次连接失败,重试一次
|
||||
_logger.LogWarning(ex, "V3 下单首次请求失败(SSL冷启动),正在重试: OrderNo={OrderNo}", request.OrderNo);
|
||||
|
||||
using var retryRequest = new HttpRequestMessage(HttpMethod.Post, V3_JSAPI_URL);
|
||||
retryRequest.Headers.Add("Authorization", authorization);
|
||||
retryRequest.Headers.Add("Accept", "application/json");
|
||||
retryRequest.Headers.Add("User-Agent", "MiAssessment/1.0");
|
||||
retryRequest.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
|
||||
|
||||
response = await _httpClient.SendAsync(retryRequest);
|
||||
}
|
||||
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
_logger.LogDebug("V3 下单响应: StatusCode={StatusCode}, Body={Body}", response.StatusCode, responseContent);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user