public JsonResult Refund() { try { PaymentData payData = new PaymentData(); //原订单号 string OrderNo = "20306516"; //原订单金额1分 int OrderTotal = 1; //操作用户ID int CustomerId = 12; string WeChatTransaction_Id = ""; //商户自定义退款单号 string refund_no = _WeiXinConfig.GenerateOutTradeNo(); //微信生成的订单号,在支付通知中有返回 payData.SetValue("transaction_id", WeChatTransaction_Id); //商户侧传给微信的订单号,原支付的订单号, transaction_id、out_trade_no 二选一都行 payData.SetValue("out_trade_no", OrderNo); //商户自定义退款单号 payData.SetValue("out_refund_no", refund_no); //原订单总金额 payData.SetValue("total_fee", OrderTotal); //退款金额 payData.SetValue("refund_fee", OrderTotal);//退款1分 payData.SetValue("op_user_id", CustomerId); PaymentData returnData = _WeiXinConfig.Refund(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)); } }