コード例 #1
0
        /// <summary>
        /// APP支付
        /// </summary>
        /// <param name="cash"></param>
        /// <returns></returns>
        public JsonResult AppPay(decimal cash)
        {
            string body      = "订单描述";
            string notifyurl = "http://localhost:4040/WXPay/WXCall"; //微信后台通知的地址
            string Recordid  = UtilTool.GenerateOutTradeNo();
            string clientIp  = UtilTool.GetWebClientIp();            //本地测试时地址为::1会导致微信返回错误   要在服务器上部署  远程调用调试
            SortedDictionary <string, object> wxRes = PayHelper.AppPay(body, notifyurl, Recordid, "", cash, clientIp);

            if (wxRes != null)
            {
                Dictionary <string, object> data = new Dictionary <string, object>();
                foreach (var item in wxRes)                 //微信APP支付需要的参数
                {
                    data.Add(item.Key, item.Value);
                }

                data.Add("orderid", Recordid);        //如果APP要需要网站订单号则返回网站订单号
                data.Add("code", "SUCCESS");
                return(Json(data));
            }
            else
            {
                Dictionary <string, object> data = new Dictionary <string, object>();
                data.Add("code", "FAILD");
                return(Json(data));
            }
        }
コード例 #2
0
        [OutputCache(Location = OutputCacheLocation.None, NoStore = false)]   //清除缓存
        public ActionResult QRCodePay(decimal cash)
        {
            string body      = "账户充值";
            string Recordid  = UtilTool.GenerateOutTradeNo();
            string notifyurl = "http://*****:*****@"<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <title>Title</title>
    <style>
      *{
        margin: 0;
        padding: 0;
      }
      .layout-qrcode{
        width:100%;
      }
      .layout-qrcode .container{
        width:251px;
        margin:0 auto;
        border:1px solid #ddd;
        border-radius: 10px;
      }
      .layout-qrcode .content{
          padding:35px;
      }
      .layout-qrcode .qr-img{
        width:181px;
        height:181px;
      }
      .layout-qrcode .qr-txt{
          width:181px;
          margin: 15px auto 0;
      }
      .layout-qrcode .qr-txt img{
          width: 100%;
      }
    </style>
</head>
<body>
<div class='layout-qrcode'>
  <div class='container'>
    <div class='content'>
      <div class='qr-img'>
        <img src='" + pic + @"' height='181' width='181'/>
      </div>
      <div class='qr-txt'>
          <img src='/Content/wx/说明文字.png' alt=''>
      </div>
    </div>
  </div>
</div>
</body>
</html>";


            return(Content(html));
        }