Browse Source

[示例] 同步连连支付变更

Roc 7 years ago
parent
commit
b52e41931f

+ 20 - 45
samples/WebApplicationSample/Controllers/LianLianPayController.cs

@@ -1,9 +1,9 @@
-using Essensoft.AspNetCore.Payment.LianLianPay;
+using System.Threading.Tasks;
+using Essensoft.AspNetCore.Payment.LianLianPay;
 using Essensoft.AspNetCore.Payment.LianLianPay.Notify;
 using Essensoft.AspNetCore.Payment.LianLianPay.Request;
 using Microsoft.AspNetCore.Mvc;
 using WebApplicationSample.Models;
-using System.Threading.Tasks;
 
 namespace WebApplicationSample.Controllers
 {
@@ -32,56 +32,47 @@ namespace WebApplicationSample.Controllers
         [HttpPost]
         public async Task<IActionResult> WebQuickPay(LianLianPayWebQuickPayViewModel viewModel)
         {
-            var request = new LianLianPayWebQuickPayRequest()
+            var request = new LianLianPayCreateBillRequest()
             {
+                UserId = viewModel.UserId,
                 NoOrder = viewModel.NoOrder,
                 DtOrder = viewModel.DtOrder,
-                MoneyOrder = viewModel.MoneyOrder,
                 NameGoods = viewModel.NameGoods,
-                UserId = viewModel.UserId,
+                MoneyOrder = viewModel.MoneyOrder,
                 NotifyUrl = viewModel.NotifyUrl,
                 UrlReturn = viewModel.UrlReturn,
-                BankCode = viewModel.BankCode,
-                PayType = viewModel.PayType,
-                NoAgree = viewModel.NoAgree,
                 RiskItem = viewModel.RiskItem,
-                IdType = viewModel.IdType,
-                IdNo = viewModel.IdNo,
-                AcctName = viewModel.AcctName,
-                CardNo = viewModel.CardNo,
+                FlagPayProduct = "0",
+                FlagChnl = "2",
             };
-            var response = await _client.PageExecuteAsync(request);
-            return Content(response.Body, "text/html;charset=utf-8");
+            var response = await _client.ExecuteAsync(request);
+            return Redirect(response.GatewayUrl);
         }
 
         [HttpGet]
-        public IActionResult WapQuickPay()
+        public IActionResult H5QuickPay()
         {
             return View();
         }
 
         [HttpPost]
-        public async Task<IActionResult> WapQuickPay(LianLianPayWapQuickPayViewModel viewModel)
+        public async Task<IActionResult> H5QuickPay(LianLianPayH5QuickPayViewModel viewModel)
         {
-            var request = new LianLianPayWapQuickPayRequest()
+            var request = new LianLianPayCreateBillRequest()
             {
+                UserId = viewModel.UserId,
                 NoOrder = viewModel.NoOrder,
                 DtOrder = viewModel.DtOrder,
-                MoneyOrder = viewModel.MoneyOrder,
                 NameGoods = viewModel.NameGoods,
-                UserId = viewModel.UserId,
-                AppRequest = viewModel.AppRequest,
+                MoneyOrder = viewModel.MoneyOrder,
                 NotifyUrl = viewModel.NotifyUrl,
                 UrlReturn = viewModel.UrlReturn,
-                NoAgree = viewModel.NoAgree,
                 RiskItem = viewModel.RiskItem,
-                IdType = viewModel.IdType,
-                IdNo = viewModel.IdNo,
-                AcctName = viewModel.AcctName,
-                CardNo = viewModel.CardNo,
+                FlagPayProduct = "0",
+                FlagChnl = "3",
             };
-            var response = await _client.PageReqDataExecuteAsync(request);
-            return Content(response.Body, "text/html;charset=utf-8");
+            var response = await _client.ExecuteAsync(request);
+            return Redirect(response.GatewayUrl);
         }
 
         [HttpGet]
@@ -149,27 +140,11 @@ namespace WebApplicationSample.Controllers
         }
 
         [HttpPost]
-        public async Task<IActionResult> WebQuickPayReturn()
-        {
-            try
-            {
-                var notify = await _notifyClient.ExecuteAsync<LianLianPayWebQuickPayReturnResponse>(Request);
-                ViewData["response"] = "支付成功";
-                return View();
-            }
-            catch
-            {
-                ViewData["response"] = "出现错误";
-                return View();
-            }
-        }
-
-        [HttpPost]
-        public async Task<IActionResult> WapQuickPayReturn()
+        public async Task<IActionResult> QuickPayReturn()
         {
             try
             {
-                var notify = await _notifyClient.ExecuteAsync<LianLianPayWapQuickPayReturnResponse>(Request);
+                var notify = await _notifyClient.ExecuteAsync<LianLianPayReceiveMoneyReturnResponse>(Request);
                 ViewData["response"] = "支付成功";
                 return View();
             }

+ 6 - 22
samples/WebApplicationSample/Controllers/NotifyController.cs

@@ -1,4 +1,6 @@
-using Essensoft.AspNetCore.Payment.Alipay;
+using System;
+using System.Threading.Tasks;
+using Essensoft.AspNetCore.Payment.Alipay;
 using Essensoft.AspNetCore.Payment.Alipay.Notify;
 using Essensoft.AspNetCore.Payment.JDPay;
 using Essensoft.AspNetCore.Payment.JDPay.Notify;
@@ -11,8 +13,6 @@ using Essensoft.AspNetCore.Payment.UnionPay.Notify;
 using Essensoft.AspNetCore.Payment.WeChatPay;
 using Essensoft.AspNetCore.Payment.WeChatPay.Notify;
 using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Threading.Tasks;
 
 namespace WebApplicationSample.Controllers
 {
@@ -318,29 +318,13 @@ namespace WebApplicationSample.Controllers
             _client = client;
         }
 
-        [Route("webquickpay")]
-        [HttpPost]
-        public async Task<IActionResult> WebQuickPay()
-        {
-            try
-            {
-                var notify = await _client.ExecuteAsync<LianLianPayWebQuickPayNotifyResponse>(Request);
-                Console.WriteLine("NoOrder: " + notify.NoOrder);
-                return LianLianPayNotifyResult.Success;
-            }
-            catch
-            {
-                return NoContent();
-            }
-        }
-
-        [Route("wapquickpay")]
+        [Route("receivemoney")]
         [HttpPost]
-        public async Task<IActionResult> WapQuickPay()
+        public async Task<IActionResult> ReceiveMoney()
         {
             try
             {
-                var notify = await _client.ExecuteAsync<LianLianPayWapQuickPayNotifyResponse>(Request);
+                var notify = await _client.ExecuteAsync<LianLianPayReceiveMoneyNotifyResponse>(Request);
                 Console.WriteLine("NoOrder: " + notify.NoOrder);
                 return LianLianPayNotifyResult.Success;
             }

+ 1 - 41
samples/WebApplicationSample/Models/LianLianPayViewModel.cs

@@ -31,33 +31,12 @@ namespace WebApplicationSample.Models
         [Display(Name = "url_return")]
         public string UrlReturn { get; set; }
 
-        [Display(Name = "bank_code")]
-        public string BankCode { get; set; }
-
-        [Display(Name = "pay_type")]
-        public string PayType { get; set; }
-
-        [Display(Name = "no_agree")]
-        public string NoAgree { get; set; }
-
         [Required]
         [Display(Name = "risk_item")]
         public string RiskItem { get; set; }
-
-        [Display(Name = "id_type")]
-        public string IdType { get; set; }
-
-        [Display(Name = "id_no")]
-        public string IdNo { get; set; }
-
-        [Display(Name = "acct_name")]
-        public string AcctName { get; set; }
-
-        [Display(Name = "card_no")]
-        public string CardNo { get; set; }
     }
 
-    public class LianLianPayWapQuickPayViewModel
+    public class LianLianPayH5QuickPayViewModel
     {
         [Required]
         [Display(Name = "no_order")]
@@ -79,10 +58,6 @@ namespace WebApplicationSample.Models
         [Display(Name = "user_id")]
         public string UserId { get; set; }
 
-        [Required]
-        [Display(Name = "app_request")]
-        public string AppRequest { get; set; }
-
         [Required]
         [Display(Name = "notify_url")]
         public string NotifyUrl { get; set; }
@@ -90,24 +65,9 @@ namespace WebApplicationSample.Models
         [Display(Name = "url_return")]
         public string UrlReturn { get; set; }
 
-        [Display(Name = "no_agree")]
-        public string NoAgree { get; set; }
-
         [Required]
         [Display(Name = "risk_item")]
         public string RiskItem { get; set; }
-
-        [Display(Name = "id_type")]
-        public string IdType { get; set; }
-
-        [Display(Name = "id_no")]
-        public string IdNo { get; set; }
-
-        [Display(Name = "acct_name")]
-        public string AcctName { get; set; }
-
-        [Display(Name = "card_no")]
-        public string CardNo { get; set; }
     }
 
     public class LianLianPayOrderQueryViewModel

+ 5 - 29
samples/WebApplicationSample/Views/LianLianPay/WapQuickPay.cshtml → samples/WebApplicationSample/Views/LianLianPay/H5QuickPay.cshtml

@@ -1,6 +1,6 @@
-@model LianLianPayWapQuickPayViewModel
+@model LianLianPayH5QuickPayViewModel
 @{
-    ViewData["Title"] = "WAP快捷支付";
+    ViewData["Title"] = "H5快捷支付";
 }
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
@@ -11,7 +11,7 @@
 <br />
 <div class="card">
     <div class="card-body">
-        <form asp-controller="LianLianPay" asp-action="WapQuickPay" target="_blank">
+        <form asp-controller="LianLianPay" asp-action="H5QuickPay" target="_blank">
             <div asp-validation-summary="All" class="text-danger"></div>
             <div class="form-group">
                 <label asp-for="NoOrder"></label>
@@ -33,42 +33,18 @@
                 <label asp-for="UserId"></label>
                 <input type="text" class="form-control" asp-for="UserId" />
             </div>
-            <div class="form-group">
-                <label asp-for="AppRequest"></label>
-                <input type="text" class="form-control" asp-for="AppRequest" value="3" />
-            </div>
             <div class="form-group">
                 <label asp-for="NotifyUrl"></label>
-                <input type="text" class="form-control" asp-for="NotifyUrl" value="http://*/notify/lianlianpay/wapquickpay" />
+                <input type="text" class="form-control" asp-for="NotifyUrl" value="http://*/notify/lianlianpay/receivemoney" />
             </div>
             <div class="form-group">
                 <label asp-for="UrlReturn"></label>
-                <input type="text" class="form-control" asp-for="UrlReturn" value="http://*/lianlianpay/wapquickpayreturn" />
-            </div>
-            <div class="form-group">
-                <label asp-for="NoAgree"></label>
-                <input type="text" class="form-control" asp-for="NoAgree" />
+                <input type="text" class="form-control" asp-for="UrlReturn" value="http://*/lianlianpay/quickpayreturn" />
             </div>
             <div class="form-group">
                 <label asp-for="RiskItem"></label>
                 <input type="text" class="form-control" asp-for="RiskItem" value='{"frms_ware_category":"1999","user_info_full_name":"你好"}' />
             </div>
-            <div class="form-group">
-                <label asp-for="IdType"></label>
-                <input type="text" class="form-control" asp-for="IdType" />
-            </div>
-            <div class="form-group">
-                <label asp-for="IdNo"></label>
-                <input type="text" class="form-control" asp-for="IdNo" />
-            </div>
-            <div class="form-group">
-                <label asp-for="AcctName"></label>
-                <input type="text" class="form-control" asp-for="AcctName" />
-            </div>
-            <div class="form-group">
-                <label asp-for="CardNo"></label>
-                <input type="text" class="form-control" asp-for="CardNo" />
-            </div>
             <button type="submit" class="btn btn-primary">提交请求</button>
         </form>
     </div>

+ 3 - 3
samples/WebApplicationSample/Views/LianLianPay/Index.cshtml

@@ -20,15 +20,15 @@
     <tbody>
         <tr>
             <th scope="row">1</th>
-            <td>WEB快捷支付</td>
+            <td>Web快捷支付</td>
             <td><a href="http://open.lianlianpay.com/#cat=35" target="_blank">https://payment.lianlianpay.com/payment/bankgateway.htm</a></td>
             <td><a asp-controller="LianLianPay" asp-action="WebQuickPay">立即测试</a></td>
         </tr>
         <tr>
             <th scope="row">2</th>
-            <td>WAP快捷支付</td>
+            <td>H5快捷支付</td>
             <td><a href="http://open.lianlianpay.com/#cat=36" target="_blank">https://wap.lianlianpay.com/payment.htm</a></td>
-            <td><a asp-controller="LianLianPay" asp-action="WapQuickPay">立即测试</a></td>
+            <td><a asp-controller="LianLianPay" asp-action="H5QuickPay">立即测试</a></td>
         </tr>
         <tr>
             <th scope="row">3</th>

+ 1 - 1
samples/WebApplicationSample/Views/LianLianPay/WapQuickPayReturn.cshtml → samples/WebApplicationSample/Views/LianLianPay/QuickPayCallback.cshtml

@@ -1,5 +1,5 @@
 @{
-    ViewData["Title"] = "WAP快捷支付-同步跳转";
+    ViewData["Title"] = "快捷支付-同步通知";
 }
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">

+ 2 - 30
samples/WebApplicationSample/Views/LianLianPay/WebQuickPay.cshtml

@@ -35,44 +35,16 @@
             </div>
             <div class="form-group">
                 <label asp-for="NotifyUrl"></label>
-                <input type="text" class="form-control" asp-for="NotifyUrl" value="http://*/notify/lianlianpay/webquickpay" />
+                <input type="text" class="form-control" asp-for="NotifyUrl" value="http://*/notify/lianlianpay/receivemoney" />
             </div>
             <div class="form-group">
                 <label asp-for="UrlReturn"></label>
-                <input type="text" class="form-control" asp-for="UrlReturn" value="http://*/lianlianpay/webquickpayreturn" />
-            </div>
-            <div class="form-group">
-                <label asp-for="BankCode"></label>
-                <input type="text" class="form-control" asp-for="BankCode" />
-            </div>
-            <div class="form-group">
-                <label asp-for="PayType"></label>
-                <input type="text" class="form-control" asp-for="PayType" />
-            </div>
-            <div class="form-group">
-                <label asp-for="NoAgree"></label>
-                <input type="text" class="form-control" asp-for="NoAgree" />
+                <input type="text" class="form-control" asp-for="UrlReturn" value="http://*/lianlianpay/quickpayreturn" />
             </div>
             <div class="form-group">
                 <label asp-for="RiskItem"></label>
                 <input type="text" class="form-control" asp-for="RiskItem" value='{"frms_ware_category":"1999","user_info_full_name":"你好"}' />
             </div>
-            <div class="form-group">
-                <label asp-for="IdType"></label>
-                <input type="text" class="form-control" asp-for="IdType" />
-            </div>
-            <div class="form-group">
-                <label asp-for="IdNo"></label>
-                <input type="text" class="form-control" asp-for="IdNo" />
-            </div>
-            <div class="form-group">
-                <label asp-for="AcctName"></label>
-                <input type="text" class="form-control" asp-for="AcctName" />
-            </div>
-            <div class="form-group">
-                <label asp-for="CardNo"></label>
-                <input type="text" class="form-control" asp-for="CardNo" />
-            </div>
             <button type="submit" class="btn btn-primary">提交请求</button>
         </form>
     </div>

+ 0 - 15
samples/WebApplicationSample/Views/LianLianPay/WebQuickPayReturn.cshtml

@@ -1,15 +0,0 @@
-@{
-    ViewData["Title"] = "WEB快捷支付-同步跳转";
-}
-<nav aria-label="breadcrumb">
-    <ol class="breadcrumb">
-        <li class="breadcrumb-item"><a asp-controller="LianLianPay" asp-action="Index">连连支付</a></li>
-        <li class="breadcrumb-item active" aria-current="page">@ViewData["Title"]</li>
-    </ol>
-</nav>
-<br />
-<div class="card">
-    <div class="card-body">
-        @ViewData["response"]
-    </div>
-</div>