/// <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)); } }