protected void submit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(transaction_id.Text) && string.IsNullOrEmpty(out_trade_no.Text)) { Response.Write("<script LANGUAGE='javascript'>alert('微信订单号和商户订单号至少填一个!');</script>"); return; } if (string.IsNullOrEmpty(total_fee.Text)) { Response.Write("<script LANGUAGE='javascript'>alert('订单总金额必填!');</script>"); return; } if (string.IsNullOrEmpty(refund_fee.Text)) { Response.Write("<script LANGUAGE='javascript'>alert('退款金额必填!');</script>"); return; } //调用订单退款接口,如果内部出现异常则在页面上显示异常原因 try { string result = WxPayApiBiz.Refund(transaction_id.Text, out_trade_no.Text, total_fee.Text, refund_fee.Text); Response.Write("<span style='color:#00CD00;font-size:20px'>" + result + "</span>"); } catch (WxPayException ex) { Response.Write("<span style='color:#FF0000;font-size:20px'>" + ex.ToString() + "</span>"); } catch (Exception ex) { Response.Write("<span style='color:#FF0000;font-size:20px'>" + ex.ToString() + "</span>"); } }
public ActionResult RefundPage(string transaction_id, string out_trade_no, string total_fee, string refund_fee) { var alertMsg = new AlertMsg(true); if (string.IsNullOrEmpty(transaction_id) && string.IsNullOrEmpty(out_trade_no)) { alertMsg.IsSuccess = false; alertMsg.Message += "微信订单号和商户订单号至少填一个!\n"; } if (string.IsNullOrEmpty(total_fee)) { alertMsg.IsSuccess = false; alertMsg.Message += "订单总金额必填!\n"; } if (string.IsNullOrEmpty(refund_fee)) { alertMsg.IsSuccess = false; alertMsg.Message += "退款金额必填!\n"; } if (!alertMsg.IsSuccess) { return(Json(alertMsg)); } //调用订单退款接口,如果内部出现异常则在页面上显示异常原因 try { string result = WxPayApiBiz.Refund(transaction_id, out_trade_no, total_fee, refund_fee); alertMsg.Message = result; } catch (WxPayException ex) { alertMsg.IsSuccess = false; alertMsg.Message = ex.Message; } catch (Exception ex) { alertMsg.IsSuccess = false; alertMsg.Message = ex.Message; } return(Json(alertMsg)); }