| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 | 
							- using System;
 
- using System.Threading.Tasks;
 
- using Essensoft.AspNetCore.Payment.WeChatPay;
 
- using Essensoft.AspNetCore.Payment.WeChatPay.V2;
 
- using Essensoft.AspNetCore.Payment.WeChatPay.V2.Notify;
 
- using Microsoft.AspNetCore.Http;
 
- using Microsoft.AspNetCore.Mvc;
 
- using Microsoft.Extensions.Options;
 
- namespace WebApplicationSample.Controllers
 
- {
 
-     [Route("wechatpay/notify")]
 
-     public class WeChatPayNotifyController : Controller
 
-     {
 
-         private readonly IWeChatPayNotifyClient _client;
 
-         private readonly IOptions<WeChatPayOptions> _optionsAccessor;
 
-         public WeChatPayNotifyController(IWeChatPayNotifyClient client, IOptions<WeChatPayOptions> optionsAccessor)
 
-         {
 
-             _client = client;
 
-             _optionsAccessor = optionsAccessor;
 
-         }
 
-         /// <summary>
 
-         /// 统一下单支付结果通知
 
-         /// </summary>
 
-         [Route("unifiedorder")]
 
-         [HttpPost]
 
-         public async Task<IActionResult> Unifiedorder()
 
-         {
 
-             try
 
-             {
 
-                 Request.EnableBuffering();
 
-                 var notify = await _client.ExecuteAsync<WeChatPayUnifiedOrderNotify>(Request, _optionsAccessor.Value);
 
-                 if (notify.ReturnCode == WeChatPayCode.Success)
 
-                 {
 
-                     if (notify.ResultCode == WeChatPayCode.Success)
 
-                     {
 
-                         Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
 
-                         return WeChatPayNotifyResult.Success;
 
-                     }
 
-                 }
 
-                 return WeChatPayNotifyResult.Failure;
 
-             }
 
-             catch
 
-             {
 
-                 return WeChatPayNotifyResult.Failure;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 退款结果通知
 
-         /// </summary>
 
-         [Route("refund")]
 
-         [HttpPost]
 
-         public async Task<IActionResult> Refund()
 
-         {
 
-             try
 
-             {
 
-                 Request.EnableBuffering();
 
-                 var notify = await _client.ExecuteAsync<WeChatPayRefundNotify>(Request, _optionsAccessor.Value);
 
-                 if (notify.ReturnCode == WeChatPayCode.Success)
 
-                 {
 
-                     if (notify.RefundStatus == WeChatPayCode.Success)
 
-                     {
 
-                         Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
 
-                         return WeChatPayNotifyResult.Success;
 
-                     }
 
-                 }
 
-                 return WeChatPayNotifyResult.Failure;
 
-             }
 
-             catch
 
-             {
 
-                 return WeChatPayNotifyResult.Failure;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |