feat(tenpayv3): 升级公共组件

This commit is contained in:
Fu Diwei
2024-01-29 23:12:37 +08:00
committed by RHQYZ
parent 84ee19d614
commit a6763ca683
348 changed files with 4397 additions and 3878 deletions

View File

@@ -11,14 +11,14 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample.Controllers
public class TenpayNotifyController : ControllerBase
{
private readonly ILogger _logger;
private readonly Services.HttpClients.IWechatTenpayHttpClientFactory _tenpayHttpClientFactory;
private readonly Services.HttpClients.IWechatTenpayClientFactory _wechatTenpayClientFactory;
public TenpayNotifyController(
ILoggerFactory loggerFactory,
Services.HttpClients.IWechatTenpayHttpClientFactory tenpayHttpClientFactory)
Services.HttpClients.IWechatTenpayClientFactory wechatTenpayClientFactory)
{
_logger = loggerFactory.CreateLogger(GetType());
_tenpayHttpClientFactory = tenpayHttpClientFactory;
_wechatTenpayClientFactory = wechatTenpayClientFactory;
}
@@ -35,13 +35,13 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample.Controllers
string content = await reader.ReadToEndAsync();
_logger.LogInformation("接收到微信支付推送的数据:{0}", content);
var client = _tenpayHttpClientFactory.Create(merchantId);
using var client = _wechatTenpayClientFactory.Create(merchantId);
bool valid = client.VerifyEventSignature(
callbackTimestamp: timestamp,
callbackNonce: nonce,
callbackBody: content,
callbackSignature: signature,
callbackSerialNumber: serialNumber
webhookTimestamp: timestamp,
webhookNonce: nonce,
webhookBody: content,
webhookSignature: signature,
webhookSerialNumber: serialNumber
);
if (!valid)
{

View File

@@ -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
);
}

View File

@@ -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 TenpayRefundController(
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("")]
public async Task<IActionResult> CreateRefund([FromBody] Models.CreateRefundRequest requestModel)
{
var client = _tenpayHttpClientFactory.Create(requestModel.MerchantId);
using var client = _wechatTenpayClientFactory.Create(requestModel.MerchantId);
var request = new CreateRefundDomesticRefundRequest()
{
TransactionId = requestModel.TransactionId,
@@ -49,7 +49,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample.Controllers
{
_logger.LogWarning(
"申请退款失败(状态码:{0},错误代码:{1},错误描述:{2})。",
response.RawStatus, response.ErrorCode, response.ErrorMessage
response.GetRawStatus(), response.ErrorCode, response.ErrorMessage
);
}