mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 23:13:32 +08:00
feat(tenpayv3): 新增 Credentials 类型,存储初始化客户端时的凭证副本
This commit is contained in:
parent
191c781d27
commit
4d70b2ac5e
@ -18,7 +18,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (string.IsNullOrEmpty(callbackJson)) throw new ArgumentNullException(callbackJson);
|
if (string.IsNullOrEmpty(callbackJson)) throw new ArgumentNullException(callbackJson);
|
||||||
|
|
||||||
return client.FlurlJsonSerializer.Deserialize<WechatTenpayEvent>(callbackJson);
|
return client.JsonSerializer.Deserialize<WechatTenpayEvent>(callbackJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -57,7 +57,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
plainJson = Utilities.AESUtility.DecryptWithGCM(
|
plainJson = Utilities.AESUtility.DecryptWithGCM(
|
||||||
key: client.WechatMerchantV3Secret,
|
key: client.Credentials.MerchantV3Secret,
|
||||||
iv: resource.Nonce,
|
iv: resource.Nonce,
|
||||||
aad: resource.AssociatedData,
|
aad: resource.AssociatedData,
|
||||||
cipherText: resource.CipherText
|
cipherText: resource.CipherText
|
||||||
@ -73,7 +73,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
throw new Exceptions.WechatTenpayEventDecryptionException("Unknown encrypt algorithm of the resource.");
|
throw new Exceptions.WechatTenpayEventDecryptionException("Unknown encrypt algorithm of the resource.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return client.FlurlJsonSerializer.Deserialize<T>(plainJson);
|
return client.JsonSerializer.Deserialize<T>(plainJson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,13 +35,13 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (callbackSignature == null) throw new ArgumentNullException(nameof(callbackSignature));
|
if (callbackSignature == null) throw new ArgumentNullException(nameof(callbackSignature));
|
||||||
if (callbackSerialNumber == null) throw new ArgumentNullException(nameof(callbackSerialNumber));
|
if (callbackSerialNumber == null) throw new ArgumentNullException(nameof(callbackSerialNumber));
|
||||||
|
|
||||||
if (client.WechatCertificateManager == null)
|
if (client.CertificateManager == null)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayResponseVerificationException($"You must set an instance of `{nameof(Settings.ICertificateManager)}` at first.");
|
throw new Exceptions.WechatTenpayResponseVerificationException($"You must set an instance of `{nameof(Settings.CertificateManager)}` at first.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string? certificate = client.WechatCertificateManager.GetCertificate(callbackSerialNumber);
|
string? certificate = client.CertificateManager.GetCertificate(callbackSerialNumber);
|
||||||
if (certificate == null)
|
if (certificate == null)
|
||||||
throw new Exceptions.WechatTenpayResponseVerificationException("Cannot get certificate by the serial number, may not be stored.");
|
throw new Exceptions.WechatTenpayResponseVerificationException("Cannot get certificate by the serial number, may not be stored.");
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||||
request.CombineMerchantId = client.WechatMerchantId;
|
request.CombineMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
if (request.SubOrderList != null)
|
if (request.SubOrderList != null)
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||||
request.CombineMerchantId = client.WechatMerchantId;
|
request.CombineMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
if (request.SubOrderList != null)
|
if (request.SubOrderList != null)
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||||
request.CombineMerchantId = client.WechatMerchantId;
|
request.CombineMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
if (request.SubOrderList != null)
|
if (request.SubOrderList != null)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
if (string.IsNullOrEmpty(request.CombineMerchantId))
|
||||||
request.CombineMerchantId = client.WechatMerchantId;
|
request.CombineMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
if (request.SubOrderList != null)
|
if (request.SubOrderList != null)
|
||||||
{
|
{
|
||||||
@ -183,7 +183,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
foreach (var subOrder in request.SubOrderList)
|
foreach (var subOrder in request.SubOrderList)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(subOrder.MerchantId))
|
if (string.IsNullOrEmpty(subOrder.MerchantId))
|
||||||
subOrder.MerchantId = client.WechatMerchantId;
|
subOrder.MerchantId = client.Credentials.MerchantId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.BelongMerchantId))
|
if (string.IsNullOrEmpty(request.BelongMerchantId))
|
||||||
request.BelongMerchantId = client.WechatMerchantId;
|
request.BelongMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "busifavor", "stocks");
|
.CreateRequest(request, HttpMethod.Post, "marketing", "busifavor", "stocks");
|
||||||
@ -313,7 +313,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "marketing", "busifavor", "callbacks")
|
.CreateRequest(request, HttpMethod.Get, "marketing", "busifavor", "callbacks")
|
||||||
@ -337,7 +337,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "busifavor", "callbacks");
|
.CreateRequest(request, HttpMethod.Post, "marketing", "busifavor", "callbacks");
|
||||||
@ -360,10 +360,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.PayerMerchantId))
|
if (string.IsNullOrEmpty(request.PayerMerchantId))
|
||||||
request.PayerMerchantId = client.WechatMerchantId;
|
request.PayerMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.PayeeMerchantId))
|
if (string.IsNullOrEmpty(request.PayeeMerchantId))
|
||||||
request.PayeeMerchantId = client.WechatMerchantId;
|
request.PayeeMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "busifavor", "subsidy", "pay-receipts");
|
.CreateRequest(request, HttpMethod.Post, "marketing", "busifavor", "subsidy", "pay-receipts");
|
||||||
@ -406,10 +406,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.PayerMerchantId))
|
if (string.IsNullOrEmpty(request.PayerMerchantId))
|
||||||
request.PayerMerchantId = client.WechatMerchantId;
|
request.PayerMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.PayeeMerchantId))
|
if (string.IsNullOrEmpty(request.PayeeMerchantId))
|
||||||
request.PayeeMerchantId = client.WechatMerchantId;
|
request.PayeeMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "busifavor", "subsidy", "return-receipts");
|
.CreateRequest(request, 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 (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.BelongMerchantId))
|
if (string.IsNullOrEmpty(request.BelongMerchantId))
|
||||||
request.BelongMerchantId = client.WechatMerchantId;
|
request.BelongMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "coupon-stocks")
|
.CreateRequest(request, 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 (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "stocks", request.StockId, "start")
|
.CreateRequest(request, 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 (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "stocks", request.StockId, "pause")
|
.CreateRequest(request, 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 (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "stocks", request.StockId, "restart")
|
.CreateRequest(request, 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 (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks", request.StockId)
|
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks", request.StockId)
|
||||||
@ -149,7 +149,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks")
|
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks")
|
||||||
@ -184,7 +184,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks", request.StockId, "merchants")
|
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks", request.StockId, "merchants")
|
||||||
@ -210,7 +210,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks", request.StockId, "items")
|
.CreateRequest(request, HttpMethod.Get, "marketing", "favor", "stocks", request.StockId, "items")
|
||||||
@ -278,7 +278,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
if (string.IsNullOrEmpty(request.StockCreatorMerchantId))
|
||||||
request.StockCreatorMerchantId = client.WechatMerchantId;
|
request.StockCreatorMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "users", request.OpenId, "coupons")
|
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "users", request.OpenId, "coupons")
|
||||||
@ -365,7 +365,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "callbacks")
|
.CreateRequest(request, HttpMethod.Post, "marketing", "favor", "callbacks")
|
||||||
|
@ -44,7 +44,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
|
|
||||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.FlurlJsonSerializer.Serialize(request)));
|
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.JsonSerializer.Serialize(request)));
|
||||||
using var httpContent = new MultipartFormDataContent(boundary);
|
using var httpContent = new MultipartFormDataContent(boundary);
|
||||||
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
||||||
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
||||||
|
@ -74,10 +74,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
.CreateRequest(request, HttpMethod.Get, "marketing", "partnerships");
|
.CreateRequest(request, HttpMethod.Get, "marketing", "partnerships");
|
||||||
|
|
||||||
if (request.Partner != null)
|
if (request.Partner != null)
|
||||||
flurlReq.SetQueryParam("partner", client.FlurlJsonSerializer.Serialize(request.Partner));
|
flurlReq.SetQueryParam("partner", client.JsonSerializer.Serialize(request.Partner));
|
||||||
|
|
||||||
if (request.AuthorizedData != null)
|
if (request.AuthorizedData != null)
|
||||||
flurlReq.SetQueryParam("authorized_data", client.FlurlJsonSerializer.Serialize(request.AuthorizedData));
|
flurlReq.SetQueryParam("authorized_data", client.JsonSerializer.Serialize(request.AuthorizedData));
|
||||||
|
|
||||||
if (request.Limit.HasValue)
|
if (request.Limit.HasValue)
|
||||||
flurlReq.SetQueryParam("limit", request.Limit.Value.ToString());
|
flurlReq.SetQueryParam("limit", request.Limit.Value.ToString());
|
||||||
|
@ -44,7 +44,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
|
|
||||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||||
using var metaContent = new StringContent(client.FlurlJsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
using var metaContent = new StringContent(client.JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||||
using var httpContent = new MultipartFormDataContent(boundary);
|
using var httpContent = new MultipartFormDataContent(boundary);
|
||||||
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
||||||
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
||||||
@ -83,7 +83,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
|
|
||||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.FlurlJsonSerializer.Serialize(request)));
|
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.JsonSerializer.Serialize(request)));
|
||||||
using var httpContent = new MultipartFormDataContent(boundary);
|
using var httpContent = new MultipartFormDataContent(boundary);
|
||||||
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
||||||
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
||||||
|
@ -108,7 +108,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.ComplaintedMerchantId))
|
if (string.IsNullOrEmpty(request.ComplaintedMerchantId))
|
||||||
request.ComplaintedMerchantId = client.WechatMerchantId;
|
request.ComplaintedMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "merchant-service", "complaints-v2", request.ComplaintId, "response");
|
.CreateRequest(request, HttpMethod.Post, "merchant-service", "complaints-v2", request.ComplaintId, "response");
|
||||||
@ -131,7 +131,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.ComplaintedMerchantId))
|
if (string.IsNullOrEmpty(request.ComplaintedMerchantId))
|
||||||
request.ComplaintedMerchantId = client.WechatMerchantId;
|
request.ComplaintedMerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "merchant-service", "complaints-v2", request.ComplaintId, "complete");
|
.CreateRequest(request, HttpMethod.Post, "merchant-service", "complaints-v2", request.ComplaintId, "complete");
|
||||||
@ -247,7 +247,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
|
|
||||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||||
using var fileContent = new ByteArrayContent(request.FileBytes);
|
using var fileContent = new ByteArrayContent(request.FileBytes);
|
||||||
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.FlurlJsonSerializer.Serialize(request)));
|
using var metaContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.JsonSerializer.Serialize(request)));
|
||||||
using var httpContent = new MultipartFormDataContent(boundary);
|
using var httpContent = new MultipartFormDataContent(boundary);
|
||||||
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
httpContent.Add(metaContent, $"\"{Constants.FormDataFields.FORMDATA_META}\"");
|
||||||
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
httpContent.Add(fileContent, "\"file\"", $"\"{HttpUtility.UrlEncode(request.FileName)}\"");
|
||||||
|
@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "app");
|
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "app");
|
||||||
@ -54,7 +54,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "jsapi");
|
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "jsapi");
|
||||||
@ -77,7 +77,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "h5");
|
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "h5");
|
||||||
@ -99,7 +99,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "native");
|
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "native");
|
||||||
@ -126,7 +126,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "pay", "partner", "transactions", "out-trade-no", request.OutTradeNumber)
|
.CreateRequest(request, HttpMethod.Get, "pay", "partner", "transactions", "out-trade-no", request.OutTradeNumber)
|
||||||
@ -155,7 +155,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "pay", "partner", "transactions", "id", request.TransactionId)
|
.CreateRequest(request, HttpMethod.Get, "pay", "partner", "transactions", "id", request.TransactionId)
|
||||||
@ -184,7 +184,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "partner", "transactions", "out-trade-no", request.OutTradeNumber, "close");
|
.CreateRequest(request, 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 (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "app");
|
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "app");
|
||||||
@ -51,7 +51,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "jsapi");
|
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "jsapi");
|
||||||
@ -73,7 +73,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "h5");
|
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "h5");
|
||||||
@ -95,7 +95,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "native");
|
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "native");
|
||||||
@ -121,7 +121,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "pay", "transactions", "out-trade-no", request.OutTradeNumber)
|
.CreateRequest(request, HttpMethod.Get, "pay", "transactions", "out-trade-no", request.OutTradeNumber)
|
||||||
@ -148,7 +148,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Get, "pay", "transactions", "id", request.TransactionId)
|
.CreateRequest(request, HttpMethod.Get, "pay", "transactions", "id", request.TransactionId)
|
||||||
@ -175,7 +175,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.MerchantId))
|
if (string.IsNullOrEmpty(request.MerchantId))
|
||||||
request.MerchantId = client.WechatMerchantId;
|
request.MerchantId = client.Credentials.MerchantId;
|
||||||
|
|
||||||
IFlurlRequest flurlReq = client
|
IFlurlRequest flurlReq = client
|
||||||
.CreateRequest(request, HttpMethod.Post, "pay", "transactions", "out-trade-no", request.OutTradeNumber, "close");
|
.CreateRequest(request, 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 nonce = Guid.NewGuid().ToString("N");
|
||||||
string package = $"prepay_id={prepayId}";
|
string package = $"prepay_id={prepayId}";
|
||||||
string sign = Utilities.RSAUtility.SignWithSHA256(
|
string sign = Utilities.RSAUtility.SignWithSHA256(
|
||||||
privateKey: client.WechatMerchantCertPrivateKey,
|
privateKey: client.Credentials.MerchantCertPrivateKey,
|
||||||
plainText: $"{appId}\n{timestamp}\n{nonce}\n{package}\n"
|
plainText: $"{appId}\n{timestamp}\n{nonce}\n{package}\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IDictionary<string, string> GenerateParametersForAppPayRequest(this WechatTenpayClient client, string appId, string prepayId)
|
public static IDictionary<string, string> GenerateParametersForAppPayRequest(this WechatTenpayClient client, string appId, string prepayId)
|
||||||
{
|
{
|
||||||
return GenerateParametersForAppPayRequest(client, merchantId: client.WechatMerchantId, appId: appId, prepayId: prepayId);
|
return GenerateParametersForAppPayRequest(client, merchantId: client.Credentials.MerchantId, appId: appId, prepayId: prepayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -98,7 +98,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
string timestamp = DateTimeOffset.Now.ToLocalTime().ToUnixTimeSeconds().ToString();
|
string timestamp = DateTimeOffset.Now.ToLocalTime().ToUnixTimeSeconds().ToString();
|
||||||
string nonce = Guid.NewGuid().ToString("N");
|
string nonce = Guid.NewGuid().ToString("N");
|
||||||
string sign = Utilities.RSAUtility.SignWithSHA256(
|
string sign = Utilities.RSAUtility.SignWithSHA256(
|
||||||
privateKey: client.WechatMerchantCertPrivateKey,
|
privateKey: client.Credentials.MerchantCertPrivateKey,
|
||||||
plainText: $"{appId}\n{timestamp}\n{nonce}\n{prepayId}\n"
|
plainText: $"{appId}\n{timestamp}\n{nonce}\n{prepayId}\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -37,7 +37,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
accountValidationModel.AccountName = Utilities.RSAUtility.DecryptWithECB(
|
accountValidationModel.AccountName = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
accountValidationModel.AccountName
|
accountValidationModel.AccountName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
accountValidationModel.AccountNumber = Utilities.RSAUtility.DecryptWithECB(
|
accountValidationModel.AccountNumber = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
accountValidationModel.AccountNumber!
|
accountValidationModel.AccountNumber!
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
downloadBillModel.EncryptKey = Utilities.RSAUtility.DecryptWithECB(
|
downloadBillModel.EncryptKey = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
downloadBillModel.EncryptKey
|
downloadBillModel.EncryptKey
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -139,7 +139,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
response.PayerPhone = Utilities.RSAUtility.DecryptWithECB(
|
response.PayerPhone = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
response.PayerPhone!
|
response.PayerPhone!
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantV3Secret))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantV3Secret))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant secret.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant secret.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -181,7 +181,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
certificateModel.EncryptCertificate.CipherText = Utilities.AESUtility.DecryptWithGCM(
|
certificateModel.EncryptCertificate.CipherText = Utilities.AESUtility.DecryptWithGCM(
|
||||||
key: client.WechatMerchantV3Secret,
|
key: client.Credentials.MerchantV3Secret,
|
||||||
iv: certificateModel.EncryptCertificate.Nonce,
|
iv: certificateModel.EncryptCertificate.Nonce,
|
||||||
aad: certificateModel.EncryptCertificate.AssociatedData,
|
aad: certificateModel.EncryptCertificate.AssociatedData,
|
||||||
cipherText: certificateModel.EncryptCertificate.CipherText
|
cipherText: certificateModel.EncryptCertificate.CipherText
|
||||||
@ -216,7 +216,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -233,7 +233,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
complaintModel.PayerPhone = Utilities.RSAUtility.DecryptWithECB(
|
complaintModel.PayerPhone = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
complaintModel.PayerPhone!
|
complaintModel.PayerPhone!
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -279,7 +279,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
guideModel.UserName = Utilities.RSAUtility.DecryptWithECB(
|
guideModel.UserName = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
guideModel.UserName
|
guideModel.UserName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
guideModel.UserMobile = Utilities.RSAUtility.DecryptWithECB(
|
guideModel.UserMobile = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
guideModel.UserMobile
|
guideModel.UserMobile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -334,7 +334,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
response.UserName
|
response.UserName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -358,7 +358,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -369,7 +369,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
response.UserName
|
response.UserName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -404,7 +404,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
response.UserName
|
response.UserName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -428,7 +428,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.WechatMerchantCertPrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertPrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
@ -439,7 +439,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
response.UserName = Utilities.RSAUtility.DecryptWithECB(
|
||||||
client.WechatMerchantCertPrivateKey,
|
client.Credentials.MerchantCertPrivateKey,
|
||||||
response.UserName
|
response.UserName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -23,16 +23,16 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (client.WechatCertificateManager == null)
|
if (client.CertificateManager == null)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayResponseVerificationException($"You must set an instance of `{nameof(Settings.ICertificateManager)}` at first.");
|
throw new Exceptions.WechatTenpayResponseVerificationException($"You must set an instance of `{nameof(Settings.CertificateManager)}` at first.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (response.WechatpayCertSerialNumber == null)
|
if (response.WechatpayCertSerialNumber == null)
|
||||||
throw new Exceptions.WechatTenpayResponseVerificationException("Cannot read the serial number in headers of this response.");
|
throw new Exceptions.WechatTenpayResponseVerificationException("Cannot read the serial number in headers of this response.");
|
||||||
|
|
||||||
string? certificate = client.WechatCertificateManager.GetCertificate(response.WechatpayCertSerialNumber);
|
string? certificate = client.CertificateManager.GetCertificate(response.WechatpayCertSerialNumber);
|
||||||
if (certificate == null)
|
if (certificate == null)
|
||||||
throw new Exceptions.WechatTenpayResponseVerificationException("Cannot get certificate by the serial number, may not be stored.");
|
throw new Exceptions.WechatTenpayResponseVerificationException("Cannot get certificate by the serial number, may not be stored.");
|
||||||
|
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 微信商户平台证书管理器接口。
|
||||||
|
/// </summary>
|
||||||
|
public abstract class CertificateManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根据证书序列号获取证书(cer 格式)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serialNumber"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public abstract string? GetCertificate(string serialNumber);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置证书序列号与证书(cer 格式)的映射关系。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serialNumber"></param>
|
||||||
|
/// <param name="certificate"></param>
|
||||||
|
public abstract void SetCertificate(string serialNumber, string certificate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 一个基于内存实现的 <see cref="CertificateManager"/>。
|
||||||
|
/// </summary>
|
||||||
|
public class InMemoryCertificateManager : CertificateManager
|
||||||
|
{
|
||||||
|
public IDictionary<string, string> _dict;
|
||||||
|
|
||||||
|
public InMemoryCertificateManager()
|
||||||
|
{
|
||||||
|
_dict = new ConcurrentDictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string? GetCertificate(string serialNumber)
|
||||||
|
{
|
||||||
|
if (serialNumber == null) throw new ArgumentNullException(nameof(serialNumber));
|
||||||
|
|
||||||
|
return _dict[serialNumber];
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetCertificate(string serialNumber, string certificate)
|
||||||
|
{
|
||||||
|
if (serialNumber == null) throw new ArgumentNullException(nameof(serialNumber));
|
||||||
|
if (certificate == null) throw new ArgumentNullException(nameof(certificate));
|
||||||
|
|
||||||
|
_dict[serialNumber] = certificate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings
|
||||||
|
{
|
||||||
|
public class Credentials
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化客户端时 <see cref="WechatTenpayClientOptions.MerchantId"/> 的副本。
|
||||||
|
/// </summary>
|
||||||
|
public string MerchantId { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化客户端时 <see cref="WechatTenpayClientOptions.MerchantV3Secret"/> 的副本。
|
||||||
|
/// </summary>
|
||||||
|
public string MerchantV3Secret { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化客户端时 <see cref="WechatTenpayClientOptions.MerchantCertSerialNumber"/> 的副本。
|
||||||
|
/// </summary>
|
||||||
|
public string MerchantCertSerialNumber { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化客户端时 <see cref="WechatTenpayClientOptions.MerchantCertPrivateKey"/> 的副本。
|
||||||
|
/// </summary>
|
||||||
|
public string MerchantCertPrivateKey { get; }
|
||||||
|
|
||||||
|
internal Credentials(WechatTenpayClientOptions options)
|
||||||
|
{
|
||||||
|
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||||
|
|
||||||
|
MerchantId = options.MerchantId;
|
||||||
|
MerchantV3Secret = options.MerchantV3Secret;
|
||||||
|
MerchantCertSerialNumber = options.MerchantCertSerialNumber;
|
||||||
|
MerchantCertPrivateKey = options.MerchantCertPrivateKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 微信商户平台证书管理器接口。
|
|
||||||
/// </summary>
|
|
||||||
public interface ICertificateManager
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 根据证书序列号获取证书(cer 格式)。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="serialNumber"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
string? GetCertificate(string serialNumber);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置证书序列号与证书(cer 格式)的映射关系。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="serialNumber"></param>
|
|
||||||
/// <param name="certificate"></param>
|
|
||||||
void SetCertificate(string serialNumber, string certificate);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 一个基于内存实现的 <see cref="ICertificateManager"/>。
|
|
||||||
/// </summary>
|
|
||||||
public class InMemoryCertificateManager : ICertificateManager
|
|
||||||
{
|
|
||||||
public IDictionary<string, string> _dict;
|
|
||||||
|
|
||||||
public InMemoryCertificateManager()
|
|
||||||
{
|
|
||||||
_dict = new ConcurrentDictionary<string, string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
string? ICertificateManager.GetCertificate(string serialNumber)
|
|
||||||
{
|
|
||||||
if (serialNumber == null) throw new ArgumentNullException(nameof(serialNumber));
|
|
||||||
|
|
||||||
return _dict[serialNumber];
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICertificateManager.SetCertificate(string serialNumber, string certificate)
|
|
||||||
{
|
|
||||||
if (serialNumber == null) throw new ArgumentNullException(nameof(serialNumber));
|
|
||||||
if (certificate == null) throw new ArgumentNullException(nameof(certificate));
|
|
||||||
|
|
||||||
_dict[serialNumber] = certificate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,37 +20,14 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
public partial class WechatTenpayClient : WechatClientBase
|
public partial class WechatTenpayClient : WechatClientBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前客户端使用的微信商户号。
|
/// 获取当前客户端使用的微信商户平台凭证。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string WechatMerchantId { get; }
|
public Settings.Credentials Credentials { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前客户端使用的微信商户 API 证书序列号(用于请求签名)。
|
/// 获取当前客户端使用的微信商户平台证书管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal string WechatMerchantCertSerialNumber { get; }
|
internal Settings.CertificateManager CertificateManager { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取当前客户端使用的微信商户 API 证书私钥(用于请求签名、响应数据解密)。
|
|
||||||
/// </summary>
|
|
||||||
internal string WechatMerchantCertPrivateKey { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取当前客户端使用的微信商户 API v3 密钥(用于事件数据解密)。
|
|
||||||
/// </summary>
|
|
||||||
internal string WechatMerchantV3Secret { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取当前客户端使用的微信商户平台证书存储器。
|
|
||||||
/// </summary>
|
|
||||||
internal Settings.ICertificateManager? WechatCertificateManager { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取当前客户端使用的 JSON 序列化器。
|
|
||||||
/// </summary>
|
|
||||||
internal ISerializer FlurlJsonSerializer
|
|
||||||
{
|
|
||||||
get { return FlurlClient.Settings?.JsonSerializer ?? new FlurlNewtonsoftJsonSerializer(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用指定的配置项初始化 <see cref="WechatTenpayClient"/> 类的新实例。
|
/// 用指定的配置项初始化 <see cref="WechatTenpayClient"/> 类的新实例。
|
||||||
@ -60,11 +37,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
{
|
{
|
||||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||||
|
|
||||||
WechatMerchantId = options.MerchantId;
|
Credentials = new Settings.Credentials(options);
|
||||||
WechatMerchantCertSerialNumber = options.MerchantCertSerialNumber;
|
CertificateManager = options.CertificateManager;
|
||||||
WechatMerchantCertPrivateKey = options.MerchantCertPrivateKey;
|
|
||||||
WechatMerchantV3Secret = options.MerchantV3Secret;
|
|
||||||
WechatCertificateManager = options.CertificateManager;
|
|
||||||
|
|
||||||
FlurlClient.BaseUrl = options.Endpoints ?? WechatTenpayEndpoints.DEFAULT;
|
FlurlClient.BaseUrl = options.Endpoints ?? WechatTenpayEndpoints.DEFAULT;
|
||||||
FlurlClient.Headers.Remove("Accept");
|
FlurlClient.Headers.Remove("Accept");
|
||||||
@ -76,7 +50,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
FlurlClient.WithTimeout(TimeSpan.FromMilliseconds(options.Timeout));
|
FlurlClient.WithTimeout(TimeSpan.FromMilliseconds(options.Timeout));
|
||||||
|
|
||||||
Interceptors.Add(new Interceptors.WechatTenpaySignInterceptor(
|
Interceptors.Add(new Interceptors.WechatTenpaySignInterceptor(
|
||||||
scheme: options.AuthScheme,
|
scheme: options.SignAlgorithm,
|
||||||
mchId: options.MerchantId,
|
mchId: options.MerchantId,
|
||||||
mchCertSn: options.MerchantCertSerialNumber,
|
mchCertSn: options.MerchantCertSerialNumber,
|
||||||
mchCertPk: options.MerchantCertPrivateKey
|
mchCertPk: options.MerchantCertPrivateKey
|
||||||
|
@ -36,7 +36,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
/// 获取或设置微信支付 API 签名认证方式。
|
/// 获取或设置微信支付 API 签名认证方式。
|
||||||
/// <para>默认值:<see cref="Constants.SignAlgorithms.WECHATPAY2_SHA256_RSA2048"/></para>
|
/// <para>默认值:<see cref="Constants.SignAlgorithms.WECHATPAY2_SHA256_RSA2048"/></para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AuthScheme { get; set; } = Constants.SignAlgorithms.WECHATPAY2_SHA256_RSA2048;
|
public string SignAlgorithm { get; set; } = Constants.SignAlgorithms.WECHATPAY2_SHA256_RSA2048;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取或设置微信商户号。
|
/// 获取或设置微信商户号。
|
||||||
@ -59,9 +59,9 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
public string MerchantCertPrivateKey { get; set; } = default!;
|
public string MerchantCertPrivateKey { get; set; } = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取或设置微信商户平台证书存储器。
|
/// 获取或设置微信商户平台证书管理器。
|
||||||
/// <para>默认值:<see cref="Settings.InMemoryCertificateManager"/></para>
|
/// <para>默认值:<see cref="Settings.InMemoryCertificateManager"/></para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Settings.ICertificateManager? CertificateManager { get; set; } = new Settings.InMemoryCertificateManager();
|
public Settings.CertificateManager CertificateManager { get; set; } = new Settings.InMemoryCertificateManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user