mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat(tenpayv3): 重命名部分内部依赖属性
This commit is contained in:
@@ -18,7 +18,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (string.IsNullOrEmpty(callbackJson)) throw new ArgumentNullException(callbackJson);
|
||||
|
||||
return client.JsonSerializer.Deserialize<WechatTenpayEvent>(callbackJson);
|
||||
return client.FlurlJsonSerializer.Deserialize<WechatTenpayEvent>(callbackJson);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,7 +57,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
plainJson = Utilities.AESUtility.DecryptWithGCM(
|
||||
key: client.MerchantV3Secret,
|
||||
key: client.WechatMerchantV3Secret,
|
||||
iv: resource.Nonce,
|
||||
aad: resource.AssociatedData,
|
||||
cipherText: resource.CipherText
|
||||
@@ -73,7 +73,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
throw new Exceptions.WechatTenpayEventDecryptionException("Unknown encrypt algorithm of the resource.");
|
||||
}
|
||||
|
||||
return client.JsonSerializer.Deserialize<T>(plainJson);
|
||||
return client.FlurlJsonSerializer.Deserialize<T>(plainJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||
request.CombineMerchantId = client.MerchantId;
|
||||
request.CombineMerchantId = client.WechatMerchantId;
|
||||
|
||||
if (request.SubOrderList != null)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||
request.CombineMerchantId = client.MerchantId;
|
||||
request.CombineMerchantId = client.WechatMerchantId;
|
||||
|
||||
if (request.SubOrderList != null)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||
request.CombineMerchantId = client.MerchantId;
|
||||
request.CombineMerchantId = client.WechatMerchantId;
|
||||
|
||||
if (request.SubOrderList != null)
|
||||
{
|
||||
@@ -130,7 +130,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||
request.CombineMerchantId = client.MerchantId;
|
||||
request.CombineMerchantId = client.WechatMerchantId;
|
||||
|
||||
if (request.SubOrderList != null)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
foreach (var subOrder in request.SubOrderList)
|
||||
{
|
||||
if (string.IsNullOrEmpty(subOrder.MerchantId))
|
||||
subOrder.MerchantId = client.MerchantId;
|
||||
subOrder.MerchantId = client.WechatMerchantId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.BelongMerchantId))
|
||||
request.BelongMerchantId = client.MerchantId;
|
||||
request.BelongMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "busifavor", "stocks")
|
||||
@@ -326,7 +326,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "marketing", "busifavor", "callbacks")
|
||||
@@ -351,7 +351,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "busifavor", "callbacks")
|
||||
@@ -375,10 +375,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.PayerMerchantId))
|
||||
request.PayerMerchantId = client.MerchantId;
|
||||
request.PayerMerchantId = client.WechatMerchantId;
|
||||
|
||||
if (string.IsNullOrEmpty(request.PayeeMerchantId))
|
||||
request.PayeeMerchantId = client.MerchantId;
|
||||
request.PayeeMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "busifavor", "subsidy", "pay-receipts")
|
||||
@@ -423,10 +423,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.PayerMerchantId))
|
||||
request.PayerMerchantId = client.MerchantId;
|
||||
request.PayerMerchantId = client.WechatMerchantId;
|
||||
|
||||
if (string.IsNullOrEmpty(request.PayeeMerchantId))
|
||||
request.PayeeMerchantId = client.MerchantId;
|
||||
request.PayeeMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "busifavor", "subsidy", "return-receipts")
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.BelongMerchantId))
|
||||
request.BelongMerchantId = client.MerchantId;
|
||||
request.BelongMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "favor", "coupon-stocks")
|
||||
@@ -53,7 +53,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "favor", "stocks", request.StockId, "start")
|
||||
@@ -77,7 +77,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "favor", "stocks", request.StockId, "pause")
|
||||
@@ -101,7 +101,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "favor", "stocks", request.StockId, "restart")
|
||||
@@ -125,7 +125,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "marketing", "favor", "stocks", request.StockId)
|
||||
@@ -150,7 +150,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "marketing", "favor", "stocks")
|
||||
@@ -186,7 +186,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "marketing", "favor", "stocks", request.StockId, "merchants")
|
||||
@@ -213,7 +213,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "marketing", "favor", "stocks", request.StockId, "items")
|
||||
@@ -282,7 +282,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||
request.StockCreatorMerchantId = client.MerchantId;
|
||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "favor", "users", request.OpenId, "coupons")
|
||||
@@ -371,7 +371,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "marketing", "favor", "callbacks")
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.JsonSerializer.Serialize(request)));
|
||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.FlurlJsonSerializer.Serialize(request)));
|
||||
using var httpContent = new MultipartFormDataContent(boundary);
|
||||
httpContent.Add(metaContent, "\"" + Constants.FormDataFields.FORMDATA_META + "\""); // NOTICE: meta 必须要加双引号
|
||||
httpContent.Add(fileContent, "\"file\"", "\"" + request.FileName + "\""); // NOTICE: file 必须要加双引号
|
||||
|
||||
@@ -77,10 +77,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
.SetOptions(request);
|
||||
|
||||
if (request.Partner != null)
|
||||
flurlReq.SetQueryParam("partner", client.JsonSerializer.Serialize(request.Partner));
|
||||
flurlReq.SetQueryParam("partner", client.FlurlJsonSerializer.Serialize(request.Partner));
|
||||
|
||||
if (request.AuthorizedData != null)
|
||||
flurlReq.SetQueryParam("authorized_data", client.JsonSerializer.Serialize(request.AuthorizedData));
|
||||
flurlReq.SetQueryParam("authorized_data", client.FlurlJsonSerializer.Serialize(request.AuthorizedData));
|
||||
|
||||
if (request.Limit.HasValue)
|
||||
flurlReq.SetQueryParam("limit", request.Limit.Value.ToString());
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||
using var metaContent = new StringContent(client.JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
using var metaContent = new StringContent(client.FlurlJsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
using var httpContent = new MultipartFormDataContent(boundary);
|
||||
httpContent.Add(metaContent, "\"" + Constants.FormDataFields.FORMDATA_META + "\""); // NOTICE: meta 必须要加双引号
|
||||
httpContent.Add(fileContent, "\"file\"", "\"" + request.FileName + "\""); // NOTICE: file 必须要加双引号
|
||||
@@ -109,7 +109,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.JsonSerializer.Serialize(request)));
|
||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.FlurlJsonSerializer.Serialize(request)));
|
||||
using var httpContent = new MultipartFormDataContent(boundary);
|
||||
httpContent.Add(metaContent, "\"meta\""); // NOTICE: meta 必须要加双引号
|
||||
httpContent.Add(fileContent, "\"file\"", "\"" + request.FileName + "\""); // NOTICE: file 必须要加双引号
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.ComplaintedMerchantId))
|
||||
request.ComplaintedMerchantId = client.MerchantId;
|
||||
request.ComplaintedMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "merchant-service", "complaints-v2", request.ComplaintId, "response")
|
||||
@@ -134,7 +134,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.ComplaintedMerchantId))
|
||||
request.ComplaintedMerchantId = client.MerchantId;
|
||||
request.ComplaintedMerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "merchant-service", "complaints-v2", request.ComplaintId, "complete")
|
||||
@@ -261,7 +261,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.JsonSerializer.Serialize(request)));
|
||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.FlurlJsonSerializer.Serialize(request)));
|
||||
using var httpContent = new MultipartFormDataContent(boundary);
|
||||
httpContent.Add(metaContent, "\"" + Constants.FormDataFields.FORMDATA_META + "\""); // NOTICE: meta 必须要加双引号
|
||||
httpContent.Add(fileContent, "\"file\"", "\"" + request.FileName + "\""); // NOTICE: file 必须要加双引号
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "partner", "transactions", "app")
|
||||
@@ -55,7 +55,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "partner", "transactions", "jsapi")
|
||||
@@ -79,7 +79,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "partner", "transactions", "h5")
|
||||
@@ -102,7 +102,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "partner", "transactions", "native")
|
||||
@@ -130,7 +130,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "pay", "partner", "transactions", "out-trade-no", request.OutTradeNumber)
|
||||
@@ -160,7 +160,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "pay", "partner", "transactions", "id", request.TransactionId)
|
||||
@@ -190,7 +190,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "partner", "transactions", "out-trade-no", request.OutTradeNumber, "close")
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "transactions", "app")
|
||||
@@ -52,7 +52,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "transactions", "jsapi")
|
||||
@@ -75,7 +75,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "transactions", "h5")
|
||||
@@ -98,7 +98,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "transactions", "native")
|
||||
@@ -125,7 +125,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "pay", "transactions", "out-trade-no", request.OutTradeNumber)
|
||||
@@ -153,7 +153,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "pay", "transactions", "id", request.TransactionId)
|
||||
@@ -181,7 +181,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (string.IsNullOrEmpty(request.MerchantId))
|
||||
request.MerchantId = client.MerchantId;
|
||||
request.MerchantId = client.WechatMerchantId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Post, "pay", "transactions", "out-trade-no", request.OutTradeNumber, "close")
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string package = $"prepay_id={prepayId}";
|
||||
string sign = Utilities.RSAUtility.SignWithSHA256(
|
||||
privateKey: client.MerchantCertPrivateKey,
|
||||
privateKey: client.WechatMerchantCertPrivateKey,
|
||||
plainText: $"{appId}\n{timestamp}\n{nonce}\n{package}"
|
||||
);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <returns></returns>
|
||||
public static IDictionary<string, string> GenerateParametersForAppPayRequest(this WechatTenpayClient client, string appId, string prepayId)
|
||||
{
|
||||
return GenerateParametersForAppPayRequest(client, merchantId: client.MerchantId, appId: appId, prepayId: prepayId);
|
||||
return GenerateParametersForAppPayRequest(client, merchantId: client.WechatMerchantId, appId: appId, prepayId: prepayId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,7 +98,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
string timestamp = DateTimeOffset.Now.ToLocalTime().ToUnixTimeSeconds().ToString();
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string sign = Utilities.RSAUtility.SignWithSHA256(
|
||||
privateKey: client.MerchantCertPrivateKey,
|
||||
privateKey: client.WechatMerchantCertPrivateKey,
|
||||
plainText: $"{appId}\n{timestamp}\n{nonce}\n{prepayId}"
|
||||
);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
@@ -39,7 +39,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
accountValidationModel.AccountNameEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
client.WechatMerchantCertPrivateKey,
|
||||
accountValidationModel.AccountNameEncryptedData
|
||||
);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
accountValidationModel.AccountNumberEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
client.WechatMerchantCertPrivateKey,
|
||||
accountValidationModel.AccountNumberEncryptedData!
|
||||
);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
@@ -101,7 +101,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
downloadBillModel.EncryptKeyEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
client.WechatMerchantCertPrivateKey,
|
||||
downloadBillModel.EncryptKeyEncryptedData
|
||||
);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
@@ -145,7 +145,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
response.PayerPhoneEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
client.WechatMerchantCertPrivateKey,
|
||||
response.PayerPhoneEncryptedData!
|
||||
);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantV3Secret))
|
||||
if (string.IsNullOrEmpty(client.WechatMerchantV3Secret))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant secret.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
@@ -189,7 +189,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
certificateModel.EncryptCertificate.CipherText = Utilities.AESUtility.DecryptWithGCM(
|
||||
key: client.MerchantV3Secret,
|
||||
key: client.WechatMerchantV3Secret,
|
||||
iv: certificateModel.EncryptCertificate.Nonce,
|
||||
aad: certificateModel.EncryptCertificate.AssociatedData,
|
||||
cipherText: certificateModel.EncryptCertificate.CipherText
|
||||
@@ -226,7 +226,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
@@ -243,7 +243,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
complaintModel.PayerPhoneEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
client.WechatMerchantCertPrivateKey,
|
||||
complaintModel.PayerPhoneEncryptedData!
|
||||
);
|
||||
}
|
||||
@@ -274,7 +274,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
@@ -291,7 +291,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
guideModel.UserNameEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
client.WechatMerchantCertPrivateKey,
|
||||
guideModel.UserNameEncryptedData
|
||||
);
|
||||
}
|
||||
@@ -306,7 +306,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
guideModel.UserMobileEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
client.WechatMerchantCertPrivateKey,
|
||||
guideModel.UserMobileEncryptedData
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Interceptors
|
||||
{
|
||||
internal class WechatTenpayAuthenticator
|
||||
{
|
||||
private readonly string _scheme;
|
||||
private readonly string _mchId;
|
||||
private readonly string _mchCertSn;
|
||||
private readonly string _mchCertPk;
|
||||
|
||||
public WechatTenpayAuthenticator(string scheme, string mchId, string mchCertSn, string mchCertPk)
|
||||
{
|
||||
_scheme = scheme;
|
||||
_mchId = mchId;
|
||||
_mchCertSn = mchCertSn;
|
||||
_mchCertPk = mchCertPk;
|
||||
}
|
||||
|
||||
public void Authenticate(FlurlCall flurlCall)
|
||||
{
|
||||
if (flurlCall == null) throw new ArgumentNullException(nameof(flurlCall));
|
||||
|
||||
string method = flurlCall.HttpRequestMessage.Method.ToString().ToUpper();
|
||||
string url = flurlCall.HttpRequestMessage.RequestUri.PathAndQuery;
|
||||
string timestamp = DateTimeOffset.Now.ToLocalTime().ToUnixTimeSeconds().ToString();
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string body = string.Empty;
|
||||
|
||||
if (flurlCall.HttpRequestMessage.Content is MultipartFormDataContent)
|
||||
{
|
||||
// NOTICE: multipart/form-data 文件上传请求的待签名参数需特殊处理
|
||||
var httpContent = (MultipartFormDataContent)flurlCall.HttpRequestMessage.Content;
|
||||
body = httpContent
|
||||
.Where(e => Constants.FormDataFields.FORMDATA_META.Equals(e.Headers.ContentDisposition?.Name?.Trim('\"')))
|
||||
.Select(e => e.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult())
|
||||
.Single();
|
||||
}
|
||||
else
|
||||
{
|
||||
body = flurlCall.RequestBody;
|
||||
}
|
||||
|
||||
string plainText = $"{method}\n{url}\n{timestamp}\n{nonce}\n{body}\n";
|
||||
string signText;
|
||||
|
||||
switch (_scheme)
|
||||
{
|
||||
case WechatTenpayAuthSchemes.WECHATPAY2_SHA256_RSA2048:
|
||||
{
|
||||
try
|
||||
{
|
||||
signText = Utilities.RSAUtility.SignWithSHA256(_mchCertPk, plainText);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exceptions.WechatTenpayRequestSignatureException("Generate signature of request failed.", ex);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exceptions.WechatTenpayRequestSignatureException("Unsupported authorization scheme.");
|
||||
}
|
||||
|
||||
string auth = $"mchid=\"{_mchId}\",nonce_str=\"{nonce}\",signature=\"{signText}\",timestamp=\"{timestamp}\",serial_no=\"{_mchCertSn}\"";
|
||||
flurlCall.Request.Headers.Remove("Authorization");
|
||||
flurlCall.Request.WithHeader("Authorization", $"{_scheme} {auth}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,29 +22,29 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信商户号。
|
||||
/// </summary>
|
||||
public string MerchantId { get; }
|
||||
public string WechatMerchantId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信商户 API 证书序列号(用于请求签名)。
|
||||
/// </summary>
|
||||
internal string MerchantCertSerialNumber { get; }
|
||||
internal string WechatMerchantCertSerialNumber { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信商户 API 证书私钥(用于请求签名、响应数据解密)。
|
||||
/// </summary>
|
||||
internal string MerchantCertPrivateKey { get; }
|
||||
internal string WechatMerchantCertPrivateKey { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信商户 API v3 密钥(用于事件数据解密)。
|
||||
/// </summary>
|
||||
internal string MerchantV3Secret { get; }
|
||||
internal string WechatMerchantV3Secret { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的 JSON 序列化器。
|
||||
/// </summary>
|
||||
internal ISerializer JsonSerializer
|
||||
internal ISerializer FlurlJsonSerializer
|
||||
{
|
||||
get { return ProxyFlurlClient.Settings?.JsonSerializer ?? new FlurlNewtonsoftJsonSerializer(); }
|
||||
get { return FlurlClient.Settings?.JsonSerializer ?? new FlurlNewtonsoftJsonSerializer(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,38 +55,37 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||
|
||||
MerchantId = options.MerchantId;
|
||||
MerchantCertSerialNumber = options.MerchantCertSerialNumber;
|
||||
MerchantCertPrivateKey = options.MerchantCertPrivateKey;
|
||||
MerchantV3Secret = options.MerchantV3Secret;
|
||||
WechatMerchantId = options.MerchantId;
|
||||
WechatMerchantCertSerialNumber = options.MerchantCertSerialNumber;
|
||||
WechatMerchantCertPrivateKey = options.MerchantCertPrivateKey;
|
||||
WechatMerchantV3Secret = options.MerchantV3Secret;
|
||||
|
||||
ProxyFlurlClient.BaseUrl = options.Endpoints ?? WechatTenpayEndpoints.DEFAULT;
|
||||
ProxyFlurlClient.Headers.Remove("Accept");
|
||||
ProxyFlurlClient.Headers.Remove("Accept-Language");
|
||||
ProxyFlurlClient.Headers.Remove("User-Agent");
|
||||
ProxyFlurlClient.WithHeader("Accept", "application/json");
|
||||
ProxyFlurlClient.WithHeader("Accept-Language", options.AcceptLanguage);
|
||||
ProxyFlurlClient.WithHeader("User-Agent", options.UserAgent);
|
||||
ProxyFlurlClient.WithTimeout(TimeSpan.FromMilliseconds(options.Timeout));
|
||||
FlurlClient.BaseUrl = options.Endpoints ?? WechatTenpayEndpoints.DEFAULT;
|
||||
FlurlClient.Headers.Remove("Accept");
|
||||
FlurlClient.Headers.Remove("Accept-Language");
|
||||
FlurlClient.Headers.Remove("User-Agent");
|
||||
FlurlClient.WithHeader("Accept", "application/json");
|
||||
FlurlClient.WithHeader("Accept-Language", options.AcceptLanguage);
|
||||
FlurlClient.WithHeader("User-Agent", options.UserAgent);
|
||||
FlurlClient.WithTimeout(TimeSpan.FromMilliseconds(options.Timeout));
|
||||
|
||||
var interceptorAuthenticator = new Interceptors.WechatTenpayAuthenticator(
|
||||
Interceptors.Add(new Interceptors.WechatTenpaySignInterceptor(
|
||||
scheme: options.AuthScheme,
|
||||
mchId: options.MerchantId,
|
||||
mchCertSn: options.MerchantCertSerialNumber,
|
||||
mchCertPk: options.MerchantCertPrivateKey
|
||||
);
|
||||
ProxyFlurlClient.BeforeCall((call) => interceptorAuthenticator.Authenticate(call));
|
||||
));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步发起请求。
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="flurlRequest"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> SendRequestAsync<T>(IFlurlRequest request, HttpContent? content = null, CancellationToken cancellationToken = default)
|
||||
public async Task<T> SendRequestAsync<T>(IFlurlRequest flurlRequest, HttpContent? content = null, CancellationToken cancellationToken = default)
|
||||
where T : WechatTenpayResponse, new()
|
||||
{
|
||||
if (content != null)
|
||||
@@ -97,8 +96,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
try
|
||||
{
|
||||
using IFlurlResponse response = await base.SendRequestAsync(request, content, cancellationToken).ConfigureAwait(false);
|
||||
return await GetResposneAsync<T>(response).ConfigureAwait(false);
|
||||
using IFlurlResponse flurlResponse = await base.SendRequestAsync(flurlRequest, content, cancellationToken).ConfigureAwait(false);
|
||||
return await GetResposneAsync<T>(flurlResponse).ConfigureAwait(false);
|
||||
}
|
||||
catch (FlurlHttpException ex)
|
||||
{
|
||||
@@ -110,17 +109,17 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// 异步发起请求。
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="flurlRequest"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> SendRequestWithJsonAsync<T>(IFlurlRequest request, object? data = null, CancellationToken cancellationToken = default)
|
||||
public async Task<T> SendRequestWithJsonAsync<T>(IFlurlRequest flurlRequest, object? data = null, CancellationToken cancellationToken = default)
|
||||
where T : WechatTenpayResponse, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
using IFlurlResponse response = await base.SendRequestWithJsonAsync(request, data, cancellationToken).ConfigureAwait(false);
|
||||
return await GetResposneAsync<T>(response).ConfigureAwait(false);
|
||||
using IFlurlResponse flurlResponse = await base.SendRequestWithJsonAsync(flurlRequest, data, cancellationToken).ConfigureAwait(false);
|
||||
return await GetResposneAsync<T>(flurlResponse).ConfigureAwait(false);
|
||||
}
|
||||
catch (FlurlHttpException ex)
|
||||
{
|
||||
@@ -128,30 +127,30 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> GetResposneAsync<T>(IFlurlResponse response)
|
||||
private async Task<T> GetResposneAsync<T>(IFlurlResponse flurlResponse)
|
||||
where T : WechatTenpayResponse, new()
|
||||
{
|
||||
string contentType = response.Headers.GetAll("Content-Type").FirstOrDefault() ?? string.Empty;
|
||||
string contentType = flurlResponse.Headers.GetAll("Content-Type").FirstOrDefault() ?? string.Empty;
|
||||
bool contentTypeIsNotJson =
|
||||
(response.StatusCode == (int)HttpStatusCode.NoContent) ||
|
||||
(response.StatusCode == (int)HttpStatusCode.OK && !contentType.StartsWith("application/json") && !contentType.StartsWith("text/json"));
|
||||
(flurlResponse.StatusCode == (int)HttpStatusCode.NoContent) ||
|
||||
(flurlResponse.StatusCode == (int)HttpStatusCode.OK && !contentType.StartsWith("application/json") && !contentType.StartsWith("text/json"));
|
||||
|
||||
T result = contentTypeIsNotJson ? new T() : await response.GetJsonAsync<T>().ConfigureAwait(false);
|
||||
result.RawStatus = response.StatusCode;
|
||||
T result = contentTypeIsNotJson ? new T() : await flurlResponse.GetJsonAsync<T>().ConfigureAwait(false);
|
||||
result.RawStatus = flurlResponse.StatusCode;
|
||||
result.RawHeaders = new ReadOnlyDictionary<string, string>(
|
||||
response.Headers
|
||||
flurlResponse.Headers
|
||||
.GroupBy(e => e.Name)
|
||||
.ToDictionary(
|
||||
k => k.Key,
|
||||
v => string.Join(", ", v.Select(e => e.Value))
|
||||
)
|
||||
);
|
||||
result.RawBytes = await response.ResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
result.WechatpayRequestId = response.Headers.GetAll("Request-ID").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpayNonce = response.Headers.GetAll("Wechatpay-Nonce").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpayTimestamp = response.Headers.GetAll("Wechatpay-Timestamp").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpaySignature = response.Headers.GetAll("Wechatpay-Signature").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpayCertSerialNumber = response.Headers.GetAll("Wechatpay-Serial").FirstOrDefault() ?? string.Empty;
|
||||
result.RawBytes = await flurlResponse.ResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
result.WechatpayRequestId = flurlResponse.Headers.GetAll("Request-ID").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpayNonce = flurlResponse.Headers.GetAll("Wechatpay-Nonce").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpayTimestamp = flurlResponse.Headers.GetAll("Wechatpay-Timestamp").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpaySignature = flurlResponse.Headers.GetAll("Wechatpay-Signature").FirstOrDefault() ?? string.Empty;
|
||||
result.WechatpayCertSerialNumber = flurlResponse.Headers.GetAll("Wechatpay-Serial").FirstOrDefault() ?? string.Empty;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user