浏览代码

WeChatPayV3Notify 删除 StatusCode
新增 WeChatPayTradeState

Roc 5 年之前
父节点
当前提交
733888f1b5

+ 1 - 1
samples/WebApplicationSample/Controllers/NotifyController.cs

@@ -358,7 +358,7 @@ namespace WebApplicationSample.Controllers
             try
             try
             {
             {
                 var notify = await _client.ExecuteAsync<WeChatPayTransactionsNotify>(Request, _optionsAccessor.Value);
                 var notify = await _client.ExecuteAsync<WeChatPayTransactionsNotify>(Request, _optionsAccessor.Value);
-                if (notify.StatusCode == 200)
+                if (notify.TradeState == WeChatPayTradeState.Success)
                 {
                 {
                     Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
                     Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
                     return WeChatPayV3NotifyResult.Success;
                     return WeChatPayV3NotifyResult.Success;

+ 1 - 1
src/Essensoft.AspNetCore.Payment.WeChatPay/Parser/IWeChatPayV3NotifyJsonParser.cs

@@ -6,7 +6,7 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.Parser
 {
 {
     public interface IWeChatPayV3NotifyJsonParser<T> where T : WeChatPayV3Notify
     public interface IWeChatPayV3NotifyJsonParser<T> where T : WeChatPayV3Notify
     {
     {
-        T Parse(string body, string v3key, int statusCode);
+        T Parse(string body, string v3key);
     }
     }
 }
 }
 
 

+ 1 - 2
src/Essensoft.AspNetCore.Payment.WeChatPay/Parser/WeChatPayV3NotifyJsonParser.cs

@@ -12,7 +12,7 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.Parser
     {
     {
         private static readonly JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
         private static readonly JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
 
 
-        public T Parse(string body, string v3key, int statusCode)
+        public T Parse(string body, string v3key)
         {
         {
             T result = null;
             T result = null;
             var notifyCiphertext = default(NotifyCiphertext);
             var notifyCiphertext = default(NotifyCiphertext);
@@ -52,7 +52,6 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.Parser
             result.Body = body;
             result.Body = body;
             result.NotifyCiphertext = notifyCiphertext;
             result.NotifyCiphertext = notifyCiphertext;
             result.ResourcePlaintext = resourcePlaintext;
             result.ResourcePlaintext = resourcePlaintext;
-            result.StatusCode = statusCode;
             return result;
             return result;
         }
         }
     }
     }

+ 43 - 0
src/Essensoft.AspNetCore.Payment.WeChatPay/WeChatPayTradeState.cs

@@ -0,0 +1,43 @@
+namespace Essensoft.AspNetCore.Payment.WeChatPay
+{
+    /// <summary>
+    /// 交易状态
+    /// </summary>
+    public static class WeChatPayTradeState
+    {
+        /// <summary>
+        /// 支付成功
+        /// </summary>
+        public const string Success = "SUCCESS";
+
+        /// <summary>
+        /// 转入退款
+        /// </summary>
+        public const string Refund = "REFUND";
+
+        /// <summary>
+        /// 未支付
+        /// </summary>
+        public const string NotPay = "NOTPAY";
+
+        /// <summary>
+        /// 已关闭
+        /// </summary>
+        public const string Closed = "CLOSED";
+
+        /// <summary>
+        /// 已撤销(付款码支付)
+        /// </summary>
+        public const string Revoked = "REVOKED";
+
+        /// <summary>
+        /// 用户支付中(付款码支付)
+        /// </summary>
+        public const string UserPaying = "USERPAYING";
+
+        /// <summary>
+        /// 支付失败(其他原因,如银行返回失败)
+        /// </summary>
+        public const string PayError = "PAYERROR";
+    }
+}

+ 0 - 6
src/Essensoft.AspNetCore.Payment.WeChatPay/WeChatPayV3Notify.cs

@@ -24,12 +24,6 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay
         /// </summary>
         /// </summary>
         [JsonIgnore]
         [JsonIgnore]
         public string ResourcePlaintext { get; set; }
         public string ResourcePlaintext { get; set; }
-
-        /// <summary>
-        /// HTTP状态码
-        /// </summary>
-        [JsonIgnore]
-        public int StatusCode { get; set; }
     }
     }
 }
 }
 
 

+ 1 - 1
src/Essensoft.AspNetCore.Payment.WeChatPay/WeChatPayV3NotifyClient.cs

@@ -47,7 +47,7 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay
             await CheckNotifySignAsync(request, body, options);
             await CheckNotifySignAsync(request, body, options);
 
 
             var parser = new WeChatPayV3NotifyJsonParser<T>();
             var parser = new WeChatPayV3NotifyJsonParser<T>();
-            var notify = parser.Parse(body, options.V3Key, request.HttpContext.Response.StatusCode);
+            var notify = parser.Parse(body, options.V3Key);
 
 
             return notify;
             return notify;
         }
         }