Browse Source

[WebApplicationSample] 添加 企业付款 - 用户到账通知

Roc 6 years ago
parent
commit
3a3ebce0c6

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

@@ -13,7 +13,6 @@ using Essensoft.AspNetCore.Payment.UnionPay.Notify;
 using Essensoft.AspNetCore.Payment.WeChatPay;
 using Essensoft.AspNetCore.Payment.WeChatPay.Notify;
 using Microsoft.AspNetCore.Mvc;
-using WebApplicationSample.Helpers;
 
 namespace WebApplicationSample.Controllers
 {
@@ -261,6 +260,26 @@ namespace WebApplicationSample.Controllers
                 return NoContent();
             }
         }
+
+        /// <summary>
+        /// 企业付款 - 用户到账通知
+        /// </summary>
+        /// <returns></returns>
+        [Route("b2cpay")]
+        [HttpPost]
+        public async Task<IActionResult> B2CPay()
+        {
+            try
+            {
+                var notify = await _client.ExecuteAsync<QPayEPayB2CNotify>(Request);
+                Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
+                return QPayNotifyResult.Success;
+            }
+            catch
+            {
+                return NoContent();
+            }
+        }
     }
 
     #endregion

+ 1 - 1
samples/WebApplicationSample/Views/QPay/B2CPay.cshtml

@@ -51,7 +51,7 @@
             </div>
             <div class="form-group">
                 <label asp-for="NotifyUrl"></label>
-                <input type="text" class="form-control" asp-for="NotifyUrl" />
+                <input type="text" class="form-control" asp-for="NotifyUrl" value="http://*/notify/qpay/b2cpay" />
             </div>
             <button type="submit" class="btn btn-primary">提交请求</button>
         </form>