ソースを参照

[WeChatPay] 解决 未启用缓存时,抛出 System.NotSupportedException: Specified method is not supported.

Roc 4 年 前
コミット
2fcc469146

+ 2 - 0
samples/WebApplicationSample/Controllers/WeChatPayNotifyController.cs

@@ -1,4 +1,5 @@
 using System;
+using System.IO;
 using System.Threading.Tasks;
 using Essensoft.AspNetCore.Payment.WeChatPay;
 using Essensoft.AspNetCore.Payment.WeChatPay.V2;
@@ -32,6 +33,7 @@ namespace WebApplicationSample.Controllers
             {
                 Request.EnableBuffering();
 
+                Request.Body.Seek(0, SeekOrigin.Begin);
                 var notify = await _client.ExecuteAsync<WeChatPayUnifiedOrderNotify>(Request, _optionsAccessor.Value);
                 if (notify.ReturnCode == WeChatPayCode.Success)
                 {

+ 2 - 0
samples/WebApplicationSample/Controllers/WeChatPayV3NotifyController.cs

@@ -1,4 +1,5 @@
 using System;
+using System.IO;
 using System.Threading.Tasks;
 using Essensoft.AspNetCore.Payment.WeChatPay;
 using Essensoft.AspNetCore.Payment.WeChatPay.V3;
@@ -32,6 +33,7 @@ namespace WebApplicationSample.Controllers
             {
                 Request.EnableBuffering();
 
+                Request.Body.Seek(0, SeekOrigin.Begin);
                 var notify = await _client.ExecuteAsync<WeChatPayTransactionsNotify>(Request, _optionsAccessor.Value);
                 if (notify.TradeState == WeChatPayTradeState.Success)
                 {

+ 0 - 1
src/Essensoft.AspNetCore.Payment.WeChatPay/V2/WeChatPayNotifyClient.cs

@@ -29,7 +29,6 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V2
                 throw new ArgumentNullException(nameof(request));
             }
 
-            request.Body.Seek(0, SeekOrigin.Begin);
             using (var reader = new StreamReader(request.Body, Encoding.UTF8, true, 1024, true))
             {
                 var body = await reader.ReadToEndAsync();

+ 0 - 1
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/WeChatPayNotifyClient.cs

@@ -35,7 +35,6 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3
                 throw new ArgumentNullException(nameof(options));
             }
 
-            request.Body.Seek(0, SeekOrigin.Begin);
             var headers = GetWeChatPayHeadersFromRequest(request);
             using (var reader = new StreamReader(request.Body, Encoding.UTF8, true, 1024, true))
             {