mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-17 01:46:20 +08:00
chore: 调整部分抛出异常的描述信息
This commit is contained in:
parent
276652edb2
commit
1e3ed8e9fb
@ -40,7 +40,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
if (callbackJson.Contains("\"Encrypt\""))
|
if (callbackJson.Contains("\"Encrypt\""))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(client.Credentials.PushEncodingAESKey))
|
if (string.IsNullOrEmpty(client.Credentials.PushEncodingAESKey))
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Decrypt event failed, because there is no encoding AES key.");
|
throw new Exceptions.WechatApiEventSerializationException("Failed to decrypt event data, because there is no encoding AES key.");
|
||||||
|
|
||||||
InnerEncryptedEvent encryptedEvent = client.JsonSerializer.Deserialize<InnerEncryptedEvent>(callbackJson);
|
InnerEncryptedEvent encryptedEvent = client.JsonSerializer.Deserialize<InnerEncryptedEvent>(callbackJson);
|
||||||
callbackJson = Utilities.WxMsgCryptor.AESDecrypt(cipherText: encryptedEvent.EncryptedData, encodingAESKey: client.Credentials.PushEncodingAESKey!, out _);
|
callbackJson = Utilities.WxMsgCryptor.AESDecrypt(cipherText: encryptedEvent.EncryptedData, encodingAESKey: client.Credentials.PushEncodingAESKey!, out _);
|
||||||
@ -54,7 +54,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Deserialize event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatApiEventSerializationException("Failed to deserialize event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
if (callbackXml.Contains("<Encrypt>") && callbackXml.Contains("</Encrypt>"))
|
if (callbackXml.Contains("<Encrypt>") && callbackXml.Contains("</Encrypt>"))
|
||||||
{
|
{
|
||||||
if (!Utilities.WxMsgCryptor.TryParseXml(callbackXml, out string encryptedXml))
|
if (!Utilities.WxMsgCryptor.TryParseXml(callbackXml, out string encryptedXml))
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Decrypt event failed, because of empty encrypted data.");
|
throw new Exceptions.WechatApiEventSerializationException("Failed to decrypt event data, because of empty encrypted data.");
|
||||||
|
|
||||||
callbackXml = Utilities.WxMsgCryptor.AESDecrypt(cipherText: encryptedXml, encodingAESKey: client.Credentials.PushEncodingAESKey!, out _);
|
callbackXml = Utilities.WxMsgCryptor.AESDecrypt(cipherText: encryptedXml, encodingAESKey: client.Credentials.PushEncodingAESKey!, out _);
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Deserialize event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatApiEventSerializationException("Failed to deserialize event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,15 +153,15 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Serialize event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatApiEventSerializationException("Failed to serialize event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safety)
|
if (safety)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(client.Credentials.PushEncodingAESKey))
|
if (string.IsNullOrEmpty(client.Credentials.PushEncodingAESKey))
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Encrypt event failed, because there is no encoding AES key.");
|
throw new Exceptions.WechatApiEventSerializationException("Failed to encrypt event data, because there is no encoding AES key.");
|
||||||
if (string.IsNullOrEmpty(client.Credentials.PushToken))
|
if (string.IsNullOrEmpty(client.Credentials.PushToken))
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Encrypt event failed, because there is no token.");
|
throw new Exceptions.WechatApiEventSerializationException("Failed to encrypt event data, because there is no token.");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -189,7 +189,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Encrypt event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatApiEventSerializationException("Failed to encrypt event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,15 +215,15 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Serialize event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatApiEventSerializationException("Failed to serialize event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safety)
|
if (safety)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(client.Credentials.PushEncodingAESKey))
|
if (string.IsNullOrEmpty(client.Credentials.PushEncodingAESKey))
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Encrypt event failed, because there is no encoding AES key.");
|
throw new Exceptions.WechatApiEventSerializationException("Failed to encrypt event data, because there is no encoding AES key.");
|
||||||
if (string.IsNullOrEmpty(client.Credentials.PushToken))
|
if (string.IsNullOrEmpty(client.Credentials.PushToken))
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Encrypt event failed, because there is no token.");
|
throw new Exceptions.WechatApiEventSerializationException("Failed to encrypt event data, because there is no token.");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -237,7 +237,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatApiEventSerializationException("Encrypt event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatApiEventSerializationException("Failed to encrypt event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!Utilities.WxMsgCryptor.TryParseXml(callbackXml, out string? encryptedXml))
|
if (!Utilities.WxMsgCryptor.TryParseXml(callbackXml, out string? encryptedXml))
|
||||||
throw new Exceptions.WechatOpenAIEventSerializationException("Encrypt event failed, because of empty encrypted data.");
|
throw new Exceptions.WechatOpenAIEventSerializationException("Failed to encrypt event data, because of empty encrypted data.");
|
||||||
|
|
||||||
callbackXml = Utilities.WxMsgCryptor.AESDecrypt(cipherText: encryptedXml!, encodingAESKey: client.Credentials.EncodingAESKey!, out _);
|
callbackXml = Utilities.WxMsgCryptor.AESDecrypt(cipherText: encryptedXml!, encodingAESKey: client.Credentials.EncodingAESKey!, out _);
|
||||||
return Utilities.XmlUtility.Deserialize<TEvent>(callbackXml);
|
return Utilities.XmlUtility.Deserialize<TEvent>(callbackXml);
|
||||||
@ -27,7 +27,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatOpenAIEventSerializationException("Deserialize event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatOpenAIEventSerializationException("Failed to deserialize event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,13 +73,13 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatOpenAIEventSerializationException("Serialize event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatOpenAIEventSerializationException("Failed to serialize event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(client.Credentials.EncodingAESKey))
|
if (string.IsNullOrEmpty(client.Credentials.EncodingAESKey))
|
||||||
throw new Exceptions.WechatOpenAIEventSerializationException("Encrypt event failed, because there is no encoding AES key.");
|
throw new Exceptions.WechatOpenAIEventSerializationException("Failed to encrypt event data, because there is no encoding AES key.");
|
||||||
if (string.IsNullOrEmpty(client.Credentials.Token))
|
if (string.IsNullOrEmpty(client.Credentials.Token))
|
||||||
throw new Exceptions.WechatOpenAIEventSerializationException("Encrypt event failed, because there is no token.");
|
throw new Exceptions.WechatOpenAIEventSerializationException("Failed to encrypt event data, because there is no token.");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatOpenAIEventSerializationException("Encrypt event failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatOpenAIEventSerializationException("Failed to encrypt event data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
|
@ -39,7 +39,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
error = new Exceptions.WechatTenpayBusinessEventVerificationException("Verify signature of event failed. Please see the `InnerException` for more details.", error);
|
error = new Exceptions.WechatTenpayBusinessEventVerificationException("Verify signature of event failed. Please see the inner exception for more details.", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -150,7 +150,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
error = new Exceptions.WechatTenpayBusinessEventVerificationException("Verify signature of event failed. Please see the `InnerException` for more details.", error);
|
error = new Exceptions.WechatTenpayBusinessEventVerificationException("Verify signature of event failed. Please see the inner exception for more details.", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -54,7 +54,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
}
|
}
|
||||||
catch (Exception ex) when (!(ex is Exceptions.WechatTenpayBusinessRequestEncryptionException))
|
catch (Exception ex) when (!(ex is Exceptions.WechatTenpayBusinessRequestEncryptionException))
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayBusinessRequestEncryptionException("Encrypt request failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayBusinessRequestEncryptionException("Failed to encrypt request. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
throw new Exceptions.WechatTenpayBusinessResponseDecryptionException("Decrypt response failed, because the response is not successful.");
|
throw new Exceptions.WechatTenpayBusinessResponseDecryptionException("Failed to decrypt response, because the response is not successful.");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
if (response.TBEPEncryption is null)
|
if (response.TBEPEncryption is null)
|
||||||
throw new InvalidOperationException("Could not read value of `TBEP-Encrypt`.");
|
throw new InvalidOperationException("Could not read value of `TBEP-Encrypt`.");
|
||||||
if (response.TBEPEncryption.CertificateSerialNumber != client.Credentials.PlatformCertificateSerialNumber)
|
if (response.TBEPEncryption.CertificateSerialNumber != client.Credentials.PlatformCertificateSerialNumber)
|
||||||
throw new Exceptions.WechatTenpayBusinessResponseDecryptionException("Decrypt response failed, because there is no platform certificate matched the serial number.");
|
throw new Exceptions.WechatTenpayBusinessResponseDecryptionException("Failed to decrypt response, because there is no platform certificate matched the serial number.");
|
||||||
|
|
||||||
if (Constants.EncryptionAlgorithms.RSA_OAEP_WITH_SM4_128_CBC.Equals(response.TBEPEncryption.Algorithm))
|
if (Constants.EncryptionAlgorithms.RSA_OAEP_WITH_SM4_128_CBC.Equals(response.TBEPEncryption.Algorithm))
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
}
|
}
|
||||||
catch (Exception ex) when (!(ex is Exceptions.WechatTenpayBusinessResponseDecryptionException))
|
catch (Exception ex) when (!(ex is Exceptions.WechatTenpayBusinessResponseDecryptionException))
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayBusinessResponseDecryptionException("Decrypt response failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayBusinessResponseDecryptionException("Failed to decrypt response. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
@ -41,7 +41,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
error = new Exceptions.WechatTenpayBusinessResponseVerificationException("Verify signature of response failed. Please see the `InnerException` for more details.", error);
|
error = new Exceptions.WechatTenpayBusinessResponseVerificationException("Verify signature of response failed. Please see the inner exception for more details.", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -150,7 +150,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness
|
|||||||
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
error = new Exceptions.WechatTenpayBusinessResponseVerificationException("Verify signature of response failed. Please see the `InnerException` for more details.", error);
|
error = new Exceptions.WechatTenpayBusinessResponseVerificationException("Verify signature of response failed. Please see the inner exception for more details.", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -59,7 +59,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayBusiness.Interceptors
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayBusinessRequestSignatureException("Generate signature of request failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayBusinessRequestSignatureException("Failed to generate signature of request. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2
|
||||||
@ -49,7 +49,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayEventDecryptionException("Decrypt event resource failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayEventDecryptionException("Failed to decrypt event resource data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return client.JsonSerializer.Deserialize<T>(plainJson);
|
return client.JsonSerializer.Deserialize<T>(plainJson);
|
||||||
|
@ -55,7 +55,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
error = new Exceptions.WechatTenpayEventVerificationException("Verify signature of event failed. Please see the `InnerException` for more details.", ex);
|
error = new Exceptions.WechatTenpayEventVerificationException("Verify signature of event failed. Please see the inner exception for more details.", ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayRequestSignatureException("Generate signature of request failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayRequestSignatureException("Failed to generate signature of request. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayEventDecryptionException("Decrypt event resource failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayEventDecryptionException("Failed to decrypt event resource data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -92,7 +92,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayEventDecryptionException("Decrypt event resource failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayEventDecryptionException("Failed to decrypt event resource data. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -123,7 +123,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
error = new Exceptions.WechatTenpayEventVerificationException("Verify signature of event failed. Please see the `InnerException` for more details.", error);
|
error = new Exceptions.WechatTenpayEventVerificationException("Verify signature of event failed. Please see the inner exception for more details.", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -22,7 +22,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
return (false, oldValue);
|
return (false, oldValue);
|
||||||
|
|
||||||
if (client.PlatformCertificateManager == null)
|
if (client.PlatformCertificateManager == null)
|
||||||
throw new Exceptions.WechatTenpayRequestEncryptionException("Encrypt request failed, because the platform certificate manager is not initialized.");
|
throw new Exceptions.WechatTenpayRequestEncryptionException("Failed to encrypt request, because the platform certificate manager is not initialized.");
|
||||||
|
|
||||||
string certificate;
|
string certificate;
|
||||||
if (string.IsNullOrEmpty(request.WechatpayCertificateSerialNumber))
|
if (string.IsNullOrEmpty(request.WechatpayCertificateSerialNumber))
|
||||||
@ -33,7 +33,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
.OrderByDescending(e => e.ExpireTime);
|
.OrderByDescending(e => e.ExpireTime);
|
||||||
if (!entries.Any())
|
if (!entries.Any())
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayEventVerificationException("Encrypt request failed, because there is no platform certificate in the manager, please make sure you have downloaded platform certificates first.");
|
throw new Exceptions.WechatTenpayEventVerificationException("Failed to encrypt request, because there is no platform certificate in the manager, please make sure you have downloaded platform certificates first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var entry = entries.First();
|
var entry = entries.First();
|
||||||
@ -46,7 +46,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
var entry = client.PlatformCertificateManager.GetEntry(request.WechatpayCertificateSerialNumber!);
|
var entry = client.PlatformCertificateManager.GetEntry(request.WechatpayCertificateSerialNumber!);
|
||||||
if (!entry.HasValue)
|
if (!entry.HasValue)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayEventVerificationException($"Encrypt request failed, because there is no platform certificate matched the serial number: \"{request.WechatpayCertificateSerialNumber}\", please make sure you have downloaded platform certificates first.");
|
throw new Exceptions.WechatTenpayEventVerificationException($"Failed to encrypt request, because there is no platform certificate matched the serial number: \"{request.WechatpayCertificateSerialNumber}\", please make sure you have downloaded platform certificates first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
certificate = entry.Value.Certificate;
|
certificate = entry.Value.Certificate;
|
||||||
@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
return (false, oldValue);
|
return (false, oldValue);
|
||||||
|
|
||||||
if (client.PlatformCertificateManager == null)
|
if (client.PlatformCertificateManager == null)
|
||||||
throw new Exceptions.WechatTenpayRequestEncryptionException("Encrypt request failed, because the platform certificate manager is not initialized.");
|
throw new Exceptions.WechatTenpayRequestEncryptionException("Failed to encrypt request, because the platform certificate manager is not initialized.");
|
||||||
|
|
||||||
string certificate;
|
string certificate;
|
||||||
if (string.IsNullOrEmpty(request.WechatpayCertificateSerialNumber))
|
if (string.IsNullOrEmpty(request.WechatpayCertificateSerialNumber))
|
||||||
@ -108,7 +108,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
.OrderByDescending(e => e.ExpireTime);
|
.OrderByDescending(e => e.ExpireTime);
|
||||||
if (!entries.Any())
|
if (!entries.Any())
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayEventVerificationException("Encrypt request failed, because there is no platform certificate in the manager, please make sure you have downloaded platform certificates first.");
|
throw new Exceptions.WechatTenpayEventVerificationException("Failed to encrypt request, because there is no platform certificate in the manager, please make sure you have downloaded platform certificates first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var entry = entries.First();
|
var entry = entries.First();
|
||||||
@ -121,7 +121,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
var entry = client.PlatformCertificateManager.GetEntry(request.WechatpayCertificateSerialNumber!);
|
var entry = client.PlatformCertificateManager.GetEntry(request.WechatpayCertificateSerialNumber!);
|
||||||
if (!entry.HasValue)
|
if (!entry.HasValue)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayEventVerificationException($"Encrypt request failed, because there is no platform certificate matched the serial number: \"{request.WechatpayCertificateSerialNumber}\", please make sure you have downloaded platform certificates first.");
|
throw new Exceptions.WechatTenpayEventVerificationException($"Failed to encrypt request, because there is no platform certificate matched the serial number: \"{request.WechatpayCertificateSerialNumber}\", please make sure you have downloaded platform certificates first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
certificate = entry.Value.Certificate;
|
certificate = entry.Value.Certificate;
|
||||||
@ -187,7 +187,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayRequestEncryptionException("Encrypt request failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayRequestEncryptionException("Failed to encrypt request. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
case Constants.EncryptionAlgorithms.AEAD_AES_256_GCM:
|
case Constants.EncryptionAlgorithms.AEAD_AES_256_GCM:
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(client.Credentials.MerchantCertificatePrivateKey))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantCertificatePrivateKey))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because there is no merchant private key.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Failed to decrypt response, because there is no merchant private key.");
|
||||||
|
|
||||||
certificate.EncryptCertificate.CipherText = Utilities.AESUtility.DecryptWithGCM(
|
certificate.EncryptCertificate.CipherText = Utilities.AESUtility.DecryptWithGCM(
|
||||||
key: client.Credentials.MerchantV3Secret,
|
key: client.Credentials.MerchantV3Secret,
|
||||||
@ -40,7 +40,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
case Constants.EncryptionAlgorithms.AEAD_SM4_128_GCM:
|
case Constants.EncryptionAlgorithms.AEAD_SM4_128_GCM:
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(client.Credentials.MerchantV3Secret))
|
if (string.IsNullOrEmpty(client.Credentials.MerchantV3Secret))
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because there is no merchant APIv3 secret.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Failed to decrypt response, because there is no merchant APIv3 secret.");
|
||||||
|
|
||||||
// REF: https://pay.weixin.qq.com/docs/merchant/development/shangmi/guide.html
|
// REF: https://pay.weixin.qq.com/docs/merchant/development/shangmi/guide.html
|
||||||
// 由于 SM4 密钥长度的限制,密钥由 APIv3 密钥通过国密 SM3 Hash 计算生成。SM4 密钥取其摘要(256bit)的前 128bit。
|
// 由于 SM4 密钥长度的限制,密钥由 APIv3 密钥通过国密 SM3 Hash 计算生成。SM4 密钥取其摘要(256bit)的前 128bit。
|
||||||
@ -160,7 +160,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||||
|
|
||||||
if (!response.IsSuccessful())
|
if (!response.IsSuccessful())
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because the response is not successful.");
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Failed to decrypt response, because the response is not successful.");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -192,7 +192,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayResponseDecryptionException("Failed to decrypt response. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|||||||
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
error = new Exceptions.WechatTenpayEventVerificationException("Verify signature of response failed. Please see the `InnerException` for more details.", error);
|
error = new Exceptions.WechatTenpayEventVerificationException("Verify signature of response failed. Please see the inner exception for more details.", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -59,7 +59,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Interceptors
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayRequestSignatureException("Generate signature of request failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayRequestSignatureException("Failed to generate signature of request. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Interceptors
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exceptions.WechatTenpayRequestSignatureException("Generate signature of request failed. Please see the `InnerException` for more details.", ex);
|
throw new Exceptions.WechatTenpayRequestSignatureException("Failed to generate signature of request. Please see the inner exception for more details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user