mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-20 18:48:10 +08:00
feat(tenpayv3): 升级公共组件
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -15,23 +15,23 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample.Controllers
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly Options.TenpayOptions _tenpayOptions;
|
||||
private readonly Services.HttpClients.IWechatTenpayHttpClientFactory _tenpayHttpClientFactory;
|
||||
private readonly Services.HttpClients.IWechatTenpayClientFactory _wechatTenpayClientFactory;
|
||||
|
||||
public TenpayOrderController(
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptions<Options.TenpayOptions> tenpayOptions,
|
||||
Services.HttpClients.IWechatTenpayHttpClientFactory tenpayHttpClientFactory)
|
||||
Services.HttpClients.IWechatTenpayClientFactory wechatTenpayClientFactory)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(GetType());
|
||||
_tenpayOptions = tenpayOptions.Value;
|
||||
_tenpayHttpClientFactory = tenpayHttpClientFactory;
|
||||
_wechatTenpayClientFactory = wechatTenpayClientFactory;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("jsapi")]
|
||||
public async Task<IActionResult> CreateOrderByJsapi([FromBody] Models.CreateOrderByJsapiRequest requestModel)
|
||||
{
|
||||
var client = _tenpayHttpClientFactory.Create(requestModel.MerchantId);
|
||||
using var client = _wechatTenpayClientFactory.Create(requestModel.MerchantId);
|
||||
var request = new CreatePayTransactionJsapiRequest()
|
||||
{
|
||||
OutTradeNumber = "SAMPLE_OTN_" + DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"),
|
||||
@@ -46,7 +46,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample.Controllers
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"JSAPI 下单失败(状态码:{0},错误代码:{1},错误描述:{2})。",
|
||||
response.RawStatus, response.ErrorCode, response.ErrorMessage
|
||||
response.GetRawStatus(), response.ErrorCode, response.ErrorMessage
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user