Skip to content

Commit

Permalink
Merge pull request #111 from EasyAbp/add-payment-event-handler-base-c…
Browse files Browse the repository at this point in the history
…lasses

Add payment event handler base classes
  • Loading branch information
gdlcf88 authored Apr 13, 2024
2 parents a7a4ee7 + ddde1b2 commit 1514f42
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 20 deletions.
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>3.0.0</Version>
<Version>3.1.0-preview.1</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>
Expand Down
12 changes: 4 additions & 8 deletions docs/WeChatPay.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,9 @@ public override void ConfigureServices (ServiceConfigurationContext context)
用户如果需要对支付结果进行处理,只需要实现一个或多个 `IWeChatPayEventHandler` 处理器即可。当框架接受到微信通知时,会触发开发人员编写的处理器,并将微信结果传递给这些处理器。

```csharp
public class PaidWeChatPayEventHandler : IWeChatPayEventHandler<QueryOrderResponse>
public class PaidWeChatPayEventHandler : WeChatPayPaidEventHandlerBase
{
public WeChatHandlerType Type => WeChatHandlerType.Paid;

public Task<WeChatRequestHandlingResult> HandleAsync(WeChatPayEventModel<QueryOrderResponse> model)
public Task<WeChatRequestHandlingResult> HandleAsync(WeChatPayEventModel<WeChatPayPaidEventModel> model)
{
Console.WriteLine("支付成功。");
return Task.FromResult(new WeChatRequestHandlingResult(true));
Expand Down Expand Up @@ -175,11 +173,9 @@ WeChatPay 模块默认提供了参数校验处理器,各个处理器的调用
用户如果需要对退款通知进行处理,只需要实现一个或多个 `IWeChatPayEventHandler` 处理器即可。当框架接受到微信通知时,会触发开发人员编写的处理器,并将微信结果传递给这些处理器。

```csharp
public class RefundWeChatPayEventHandler : IWeChatPayEventHandler<RefundOrderResponse>
public class RefundWeChatPayEventHandler : WeChatPayRefundEventHandlerBase
{
public WeChatHandlerType Type => WeChatHandlerType.Refund;

public Task<WeChatRequestHandlingResult> HandleAsync(WeChatPayEventModel<RefundOrderResponse> model)
public Task<WeChatRequestHandlingResult> HandleAsync(WeChatPayEventModel<WeChatPayRefundEventModel> model)
{
Console.WriteLine("退款成功。");
return Task.FromResult(new WeChatRequestHandlingResult(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace EasyAbp.Abp.WeChat.Pay.RequestHandling
/// <summary>
/// 定义了微信支付回调处理器。
/// </summary>
public interface IWeChatPayEventHandler<TResource>
public interface IWeChatPayEventHandler<TEventModel>
{
WeChatHandlerType Type { get; }

Task<WeChatRequestHandlingResult> HandleAsync(WeChatPayEventModel<TResource> model);
Task<WeChatRequestHandlingResult> HandleAsync(WeChatPayEventModel<TEventModel> model);
}
}
Loading

0 comments on commit 1514f42

Please sign in to comment.