mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-16 16:50:43 +08:00
feat(tenpayv3): 重命名回调通知事件相关的模型
This commit is contained in:
parent
e0bb33d266
commit
782d46cad9
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 MALL_REFUND.SUCCESS 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class MallRefundResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class MallRefundResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置微信商户号。
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 MALL_TRANSACTION.SUCCESS 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class MallTransactionResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class MallTransactionResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置微信商户号。
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 TRANSACTION.SUCCESS 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class CombineTransactionResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class CombineTransactionResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 DISCOUNT_CARD.USER_ACCEPTED 通知的数据。</para>
|
||||
/// <para>表示 DISCOUNT_CARD.AGREEMENT_ENDED 通知的数据。</para>
|
||||
/// <para>表示 DISCOUNT_CARD.USER_PAID 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class DiscountCardResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class DiscountCardResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 COUPON.SEND 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class MarketingBusifavorCouponResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class MarketingBusifavorCouponResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 COUPON.USE 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class MarketingFavorCouponResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class MarketingFavorCouponResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 COMPLAINT.CREATE 通知的数据。</para>
|
||||
/// <para>表示 COMPLAINT.STATE_CHANGE 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class ComplaintResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class ComplaintResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置投诉单号。
|
@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 REFUND.SUCCESS (仅服务商)通知的数据。</para>
|
||||
/// <para>表示 REFUND.ABNORMAL (仅服务商)通知的数据。</para>
|
||||
/// <para>表示 REFUND.CLOSED (仅服务商)通知的数据。</para>
|
||||
/// </summary>
|
||||
public class PartnerRefundResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class PartnerRefundResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 TRANSACTION.SUCCESS (仅限服务商)通知的数据。</para>
|
||||
/// </summary>
|
||||
public class PartnerTransactionResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class PartnerTransactionResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 PAYSCORE.USER_OPEN_SERVICE 通知的数据。</para>
|
||||
/// <para>表示 PAYSCORE.USER_CLOSE_SERVICE 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class PayScorePartnerPermissionsResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class PayScorePartnerPermissionsResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置服务商商户号。
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 PAYSCORE.USER_CONFIRM 通知的数据。</para>
|
||||
/// <para>表示 PAYSCORE.USER_PAID 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class PayScorePartnerServiceOrderResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class PayScorePartnerServiceOrderResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 PAYSCORE.USER_OPEN_SERVICE 通知的数据。</para>
|
||||
/// <para>表示 PAYSCORE.USER_CLOSE_SERVICE 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class PayScorePermissionsResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class PayScorePermissionsResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置微信商户号。
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 PAYSCORE.USER_CONFIRM 通知的数据。</para>
|
||||
/// <para>表示 PAYSCORE.USER_PAID 通知的数据。</para>
|
||||
/// </summary>
|
||||
public class PayScoreServiceOrderResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class PayScoreServiceOrderResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 TRANSACTION.SUCCESS (仅限直连商户)通知的数据。</para>
|
||||
/// </summary>
|
||||
public class TransactionResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class TransactionResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Resources
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 REFUND.SUCCESS (仅直连商户)通知的数据。</para>
|
||||
/// <para>表示 REFUND.ABNORMAL (仅直连商户)通知的数据。</para>
|
||||
/// <para>表示 REFUND.CLOSED (仅直连商户)通知的数据。</para>
|
||||
/// </summary>
|
||||
public class RefundResource : WechatTenpayCallback.Types.IDecryptedResource
|
||||
public class RefundResource : WechatTenpayEvent.Types.IDecryptedResource
|
||||
{
|
||||
public static class Types
|
||||
{
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Exceptions
|
||||
{
|
||||
public class WechatTenpayCallbackDecryptionException : WechatTenpayException
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
internal WechatTenpayCallbackDecryptionException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
internal WechatTenpayCallbackDecryptionException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
internal WechatTenpayCallbackDecryptionException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Exceptions
|
||||
{
|
||||
public class WechatTenpayEventDecryptionException : WechatTenpayException
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
internal WechatTenpayEventDecryptionException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
internal WechatTenpayEventDecryptionException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
internal WechatTenpayEventDecryptionException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -5,21 +5,20 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <summary>
|
||||
/// 为 <see cref="WechatTenpayClient"/> 提供回调通知事件的扩展方法。
|
||||
/// </summary>
|
||||
public static class WechatTenpayClientCallbackDeserializationExtensions
|
||||
public static class WechatTenpayClientEventExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>反序列化得到 <see cref="WechatTenpayCallback"/> 对象。</para>
|
||||
/// <para>反序列化得到 <see cref="WechatTenpayEvent"/> 对象。</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse"></typeparam>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="callbackJson"></param>
|
||||
/// <returns></returns>
|
||||
public static WechatTenpayCallback DeserializeCallback(this WechatTenpayClient client, string callbackJson)
|
||||
public static WechatTenpayEvent DeserializeEvent(this WechatTenpayClient client, string callbackJson)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (string.IsNullOrEmpty(callbackJson)) throw new ArgumentNullException(callbackJson);
|
||||
|
||||
return client.JsonSerializer.Deserialize<WechatTenpayCallback>(callbackJson);
|
||||
return client.JsonSerializer.Deserialize<WechatTenpayEvent>(callbackJson);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -29,13 +28,13 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <param name="client"></param>
|
||||
/// <param name="callback"></param>
|
||||
/// <returns></returns>
|
||||
public static T DecryptCallbackResource<T>(this WechatTenpayClient client, WechatTenpayCallback callback)
|
||||
where T : WechatTenpayCallback.Types.IDecryptedResource, new()
|
||||
public static T DecryptEventResource<T>(this WechatTenpayClient client, WechatTenpayEvent callback)
|
||||
where T : WechatTenpayEvent.Types.IDecryptedResource, new()
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (callback == null) throw new ArgumentNullException(nameof(callback));
|
||||
|
||||
return DecryptCallbackResource<T>(client, callback.Resource);
|
||||
return DecryptEventResource<T>(client, callback.Resource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -45,8 +44,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <param name="client"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
public static T DecryptCallbackResource<T>(this WechatTenpayClient client, WechatTenpayCallback.Types.Resource resource)
|
||||
where T : WechatTenpayCallback.Types.IDecryptedResource, new()
|
||||
public static T DecryptEventResource<T>(this WechatTenpayClient client, WechatTenpayEvent.Types.Resource resource)
|
||||
where T : WechatTenpayEvent.Types.IDecryptedResource, new()
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (resource == null) throw new ArgumentNullException(nameof(resource));
|
||||
@ -66,12 +65,12 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exceptions.WechatTenpayCallbackDecryptionException("Decrypt callback failed.", ex);
|
||||
throw new Exceptions.WechatTenpayEventDecryptionException("Decrypt event resource failed.", ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exceptions.WechatTenpayCallbackDecryptionException("Unknown encrypt algorithm of the resource.");
|
||||
throw new Exceptions.WechatTenpayEventDecryptionException("Unknown encrypt algorithm of the resource.");
|
||||
}
|
||||
|
||||
return client.JsonSerializer.Deserialize<T>(plainJson);
|
@ -14,12 +14,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse"></typeparam>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static TResponse DecryptResponseEncryptedData<TResponse>(this WechatTenpayClient client, TResponse response)
|
||||
where TResponse : WechatTenpayResponse
|
||||
public static Models.GetEcommerceApplymentByOutRequestNumberResponse DecryptResponseEncryptedData(this WechatTenpayClient client, Models.GetEcommerceApplymentByOutRequestNumberResponse response)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
@ -30,42 +28,6 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (!response.IsSuccessful())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of the response is not successful.");
|
||||
|
||||
if (response is Models.GetEcommerceApplymentByOutRequestNumberResponse resGetEcommerceApplymentByOutRequestNumber)
|
||||
{
|
||||
DecryptResponse(resGetEcommerceApplymentByOutRequestNumber, client.MerchantCertPrivateKey);
|
||||
return (resGetEcommerceApplymentByOutRequestNumber as TResponse)!;
|
||||
}
|
||||
else if (response is Models.GetEcommerceBillFundflowBillResponse resGetEcommerceBillFundflowBill)
|
||||
{
|
||||
DecryptResponse(resGetEcommerceBillFundflowBill, client.MerchantCertPrivateKey);
|
||||
return (resGetEcommerceBillFundflowBill as TResponse)!;
|
||||
}
|
||||
else if (response is Models.GetMerchantServiceComplaintByComplaintIdResponse resGetMerchantServiceComplaintByComplaintId)
|
||||
{
|
||||
DecryptResponse(resGetMerchantServiceComplaintByComplaintId, client.MerchantCertPrivateKey);
|
||||
return (resGetMerchantServiceComplaintByComplaintId as TResponse)!;
|
||||
}
|
||||
else if (response is Models.QueryCertificatesResponse resQueryCertificates)
|
||||
{
|
||||
DecryptResponse(resQueryCertificates, client.MerchantV3Secret);
|
||||
return (resQueryCertificates as TResponse)!;
|
||||
}
|
||||
else if (response is Models.QueryMerchantServiceComplaintsResponse resQueryMerchantServiceComplaints)
|
||||
{
|
||||
DecryptResponse(resQueryMerchantServiceComplaints, client.MerchantCertPrivateKey);
|
||||
return (resQueryMerchantServiceComplaints as TResponse)!;
|
||||
}
|
||||
else if (response is Models.QuerySmartGuidesResponse resQuerySmartGuides)
|
||||
{
|
||||
DecryptResponse(resQuerySmartGuides, client.MerchantCertPrivateKey);
|
||||
return (resQuerySmartGuides as TResponse)!;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void DecryptResponse(Models.GetEcommerceApplymentByOutRequestNumberResponse response, string privateKey)
|
||||
{
|
||||
if (response.AccountValidation != null)
|
||||
{
|
||||
IList<Exception> exceptions = new List<Exception>();
|
||||
@ -77,7 +39,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
accountValidationModel.AccountNameEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
privateKey,
|
||||
client.MerchantCertPrivateKey,
|
||||
accountValidationModel.AccountNameEncryptedData
|
||||
);
|
||||
}
|
||||
@ -92,7 +54,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
accountValidationModel.AccountNumberEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
privateKey,
|
||||
client.MerchantCertPrivateKey,
|
||||
accountValidationModel.AccountNumberEncryptedData!
|
||||
);
|
||||
}
|
||||
@ -105,10 +67,29 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (exceptions.Any())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed.", new AggregateException(exceptions));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void DecryptResponse(Models.GetEcommerceBillFundflowBillResponse response, string privateKey)
|
||||
/// <summary>
|
||||
/// <para>解密响应中返回的敏感数据。该方法会改变传入的响应信息。</para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static Models.GetEcommerceBillFundflowBillResponse DecryptResponseEncryptedData(this WechatTenpayClient client, Models.GetEcommerceBillFundflowBillResponse response)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of the response is not successful.");
|
||||
|
||||
if (response.DownloadBillList != null)
|
||||
{
|
||||
IList<Exception> exceptions = new List<Exception>();
|
||||
@ -120,7 +101,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
downloadBillModel.EncryptKeyEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
privateKey,
|
||||
client.MerchantCertPrivateKey,
|
||||
downloadBillModel.EncryptKeyEncryptedData
|
||||
);
|
||||
}
|
||||
@ -134,10 +115,29 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (exceptions.Any())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed.", new AggregateException(exceptions));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void DecryptResponse(Models.GetMerchantServiceComplaintByComplaintIdResponse response, string privateKey)
|
||||
/// <summary>
|
||||
/// <para>解密响应中返回的敏感数据。该方法会改变传入的响应信息。</para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static Models.GetMerchantServiceComplaintByComplaintIdResponse DecryptResponseEncryptedData(this WechatTenpayClient client, Models.GetMerchantServiceComplaintByComplaintIdResponse response)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of the response is not successful.");
|
||||
|
||||
if (response.ComplaintDetail != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(response.PayerPhoneEncryptedData))
|
||||
@ -145,7 +145,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
response.PayerPhoneEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
privateKey,
|
||||
client.MerchantCertPrivateKey,
|
||||
response.PayerPhoneEncryptedData!
|
||||
);
|
||||
}
|
||||
@ -155,10 +155,29 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void DecryptResponse(Models.QueryCertificatesResponse response, string aesKey)
|
||||
/// <summary>
|
||||
/// <para>解密响应中返回的敏感数据。该方法会改变传入的响应信息。</para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static Models.QueryCertificatesResponse DecryptResponseEncryptedData(this WechatTenpayClient client, Models.QueryCertificatesResponse response)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantV3Secret))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant secret.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of the response is not successful.");
|
||||
|
||||
if (response.CertificateList != null)
|
||||
{
|
||||
IList<Exception> exceptions = new List<Exception>();
|
||||
@ -170,7 +189,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
certificateModel.EncryptCertificate.CipherText = Utilities.AesUtil.DecryptWithGCM(
|
||||
aesKey: aesKey,
|
||||
aesKey: client.MerchantV3Secret,
|
||||
nonce: certificateModel.EncryptCertificate.Nonce,
|
||||
associatedData: certificateModel.EncryptCertificate.AssociatedData,
|
||||
cipherText: certificateModel.EncryptCertificate.CipherText
|
||||
@ -190,10 +209,29 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (exceptions.Any())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed.", new AggregateException(exceptions));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void DecryptResponse(Models.QueryMerchantServiceComplaintsResponse response, string privateKey)
|
||||
/// <summary>
|
||||
/// <para>解密响应中返回的敏感数据。该方法会改变传入的响应信息。</para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static Models.QueryMerchantServiceComplaintsResponse DecryptResponseEncryptedData(this WechatTenpayClient client, Models.QueryMerchantServiceComplaintsResponse response)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of the response is not successful.");
|
||||
|
||||
if (response.ComplaintList != null)
|
||||
{
|
||||
IList<Exception> exceptions = new List<Exception>();
|
||||
@ -205,7 +243,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
complaintModel.PayerPhoneEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
privateKey,
|
||||
client.MerchantCertPrivateKey,
|
||||
complaintModel.PayerPhoneEncryptedData!
|
||||
);
|
||||
}
|
||||
@ -219,10 +257,29 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (exceptions.Any())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed.", new AggregateException(exceptions));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void DecryptResponse(Models.QuerySmartGuidesResponse response, string privateKey)
|
||||
/// <summary>
|
||||
/// <para>解密响应中返回的敏感数据。该方法会改变传入的响应信息。</para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay4_3.shtml </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static Models.QuerySmartGuidesResponse DecryptResponseEncryptedData(this WechatTenpayClient client, Models.QuerySmartGuidesResponse response)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (response == null) throw new ArgumentNullException(nameof(response));
|
||||
|
||||
if (string.IsNullOrEmpty(client.MerchantCertPrivateKey))
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of there is no merchant private key.");
|
||||
|
||||
if (!response.IsSuccessful())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed, because of the response is not successful.");
|
||||
|
||||
if (response.GuideList != null)
|
||||
{
|
||||
IList<Exception> exceptions = new List<Exception>();
|
||||
@ -234,7 +291,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
guideModel.UserNameEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
privateKey,
|
||||
client.MerchantCertPrivateKey,
|
||||
guideModel.UserNameEncryptedData
|
||||
);
|
||||
}
|
||||
@ -249,7 +306,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
try
|
||||
{
|
||||
guideModel.UserMobileEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
privateKey,
|
||||
client.MerchantCertPrivateKey,
|
||||
guideModel.UserMobileEncryptedData
|
||||
);
|
||||
}
|
||||
@ -263,6 +320,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
if (exceptions.Any())
|
||||
throw new Exceptions.WechatTenpayResponseDecryptionException("Decrypt response failed.", new AggregateException(exceptions));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <summary>
|
||||
/// 表示微信支付 API 回调通知事件的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatTenpayCallback
|
||||
[Serializable]
|
||||
public class WechatTenpayEvent
|
||||
{
|
||||
public static class Types
|
||||
{
|
Loading…
Reference in New Issue
Block a user