/// <summary> /// 微信企业付款 /// </summary> /// <returns></returns> //[Authorize] public JsonResult Transfers() { try { //付款金额1元,最少1元 int Amount = 100; //自定义交易订单号 string TradeNo = _WeiXinConfig.GenerateOutTradeNo(); //用户OpenId string OpenId = Request.RequestContext.HttpContext.User.Identity.Name; //校验用户姓名选项 NO_CHECK:不校验真实姓名 FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账) OPTION_CHECK:针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功) string check_name = "NO_CHECK"; //企业付款描述信息 string desc = "微信转账"; //收款用户真实姓名。 如果check_name设置为FORCE_CHECK或OPTION_CHECK,则必填用户真实姓名 string re_user_name = "张三"; PaymentData payData = new PaymentData(); payData.SetValue("amount", Amount); payData.SetValue("partner_trade_no", TradeNo); payData.SetValue("openid", OpenId); payData.SetValue("check_name", check_name); payData.SetValue("desc", desc); payData.SetValue("re_user_name", re_user_name); PaymentData returnData = _WeiXinConfig.Transfers(payData); string return_code = returnData.GetValue("return_code").ToString(); if (return_code.ToUpper().Equals("FAIL")) { return(Json(new { Success = false, ErrorMessage = returnData.GetValue("return_msg").ToString() }, JsonRequestBehavior.AllowGet)); } else { string result_code = returnData.GetValue("result_code").ToString(); if (result_code.ToUpper().Equals("FAIL")) { return(Json(new { Success = false, ErrorMessage = returnData.GetValue("err_code_des").ToString() }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, ErrorMessage = "", Data = returnData }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Success = false, ErrorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }