示例#1
0
        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 RefundQueryPage(string refund_id, string out_refund_no, string transaction_id, string out_trade_no)
        {
            if (string.IsNullOrEmpty(refund_id) && string.IsNullOrEmpty(out_refund_no) &&
                string.IsNullOrEmpty(transaction_id) && string.IsNullOrEmpty(out_trade_no))
            {
                return(Json(new AlertMsg("微信订单号、商户订单号、商户退款单号、微信退款单号选填至少一个,微信退款单号优先!")));
            }

            var alertMsg = new AlertMsg();

            //调用退款查询接口,如果内部出现异常则在页面上显示异常原因
            try
            {
                string result = WxPayApiBiz.RefundQuery(refund_id, out_refund_no, transaction_id, out_trade_no);
                alertMsg.IsSuccess = true;
                alertMsg.Message   = result;
            }
            catch (WxPayException ex)
            {
                alertMsg.Message = ex.Message;
            }
            catch (Exception ex)
            {
                alertMsg.Message = ex.Message;
            }
            return(Json(alertMsg));
        }
示例#3
0
 protected void submit_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(auth_code.Text))
     {
         Response.Write("<script LANGUAGE='javascript'>alert('请输入授权码!');</script>");
         return;
     }
     if (string.IsNullOrEmpty(body.Text))
     {
         Response.Write("<script LANGUAGE='javascript'>alert('请输入商品描述!');</script>");
         return;
     }
     if (string.IsNullOrEmpty(fee.Text))
     {
         Response.Write("<script LANGUAGE='javascript'>alert('请输入商品总金额!');</script>");
         return;
     }
     //调用刷卡支付,如果内部出现异常则在页面上显示异常原因
     try
     {
         string result = WxPayApiBiz.MicroPay(body.Text, fee.Text, auth_code.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 OrderQueryPage(string transaction_id, string out_trade_no)
        {
            if (string.IsNullOrEmpty(transaction_id) && string.IsNullOrEmpty(out_trade_no))
            {
                return(Json(new AlertMsg("微信订单号和商户订单号至少填写一个,微信订单号优先!")));
            }

            var alertMsg = new AlertMsg();

            //调用订单查询接口,如果内部出现异常则在页面上显示异常原因
            try
            {
                string result = WxPayApiBiz.OrderQuery(transaction_id, out_trade_no);//调用订单查询业务逻辑
                alertMsg.IsSuccess = true;
                alertMsg.Message   = result;
            }
            catch (WxPayException ex)
            {
                alertMsg.Message = ex.Message;
            }
            catch (Exception ex)
            {
                alertMsg.Message = ex.Message;
            }
            return(Json(alertMsg));
        }
        public ActionResult NativePay()
        {
            WxPayLog.Info(this.GetType().ToString(), "page load");

            //生成扫码支付模式一url
            ViewBag.QRCode1 = WxPayApiBiz.GetNativePrePayUrl("123456789");

            //生成扫码支付模式二url
            ViewBag.QRCode2 = WxPayApiBiz.GetNativePayUrl("123456789");

            return(View());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            WxPayLog.Info(this.GetType().ToString(), "page load");

            //生成扫码支付模式一url
            string url1 = WxPayApiBiz.GetNativePrePayUrl("123456789");

            //生成扫码支付模式二url
            string url2 = WxPayApiBiz.GetNativePayUrl("123456789");

            //将url生成二维码图片
            Image1.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url1);
            Image2.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url2);
        }
        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));
        }
        public ActionResult MicroPayPage(string auth_code, string body, string fee)
        {
            var alertMsg = new AlertMsg(true);

            if (string.IsNullOrEmpty(auth_code))
            {
                alertMsg.IsSuccess = false;
                alertMsg.Message  += "请输入授权码!\n";
            }
            if (string.IsNullOrEmpty(body))
            {
                alertMsg.IsSuccess = false;
                alertMsg.Message  += "请输入商品描述!\n";
            }
            if (string.IsNullOrEmpty(fee))
            {
                alertMsg.IsSuccess = false;
                alertMsg.Message  += "请输入商品总金额!\n";
            }
            if (!alertMsg.IsSuccess)
            {
                return(Json(alertMsg));
            }
            //调用刷卡支付,如果内部出现异常则在页面上显示异常原因
            try
            {
                alertMsg.Message = WxPayApiBiz.MicroPay(body, fee, auth_code);
            }
            catch (WxPayException ex)
            {
                alertMsg.IsSuccess = false;
                alertMsg.Message   = ex.ToString();
            }
            catch (Exception ex)
            {
                alertMsg.IsSuccess = false;
                alertMsg.Message   = ex.ToString();
            }
            return(Json(alertMsg));
        }
        public ActionResult DownloadBillPage(string bill_type, DateTime?bill_date)
        {
            var dateStr  = (bill_date.HasValue ? bill_date.Value : DateTime.Now).ToString("yyyyMMdd");
            var alertMsg = new AlertMsg();

            //调用下载对账单接口,如果内部出现异常则在页面上显示异常原因
            try
            {
                string result = WxPayApiBiz.DownloadBill(dateStr, bill_type);
                alertMsg.IsSuccess = true;
                alertMsg.Message   = result;
            }
            catch (WxPayException ex)
            {
                alertMsg.Message = ex.Message;
            }
            catch (Exception ex)
            {
                alertMsg.Message = ex.Message;
            }
            return(Json(alertMsg));
        }
        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;
            }

            //调用订单查询接口,如果内部出现异常则在页面上显示异常原因
            try
            {
                string result = WxPayApiBiz.OrderQuery(transaction_id.Text, out_trade_no.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>");
            }
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(bill_date.Text))
            {
                Response.Write("<script LANGUAGE='javascript'>alert('请输入对账单日期!');</script>");
                return;
            }

            //调用下载对账单接口,如果内部出现异常则在页面上显示异常原因
            try
            {
                string result = WxPayApiBiz.DownloadBill(bill_date.Text, bill_type.SelectedValue);
                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>");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     WxPayApiBiz.ProcessResultNotify(this);
 }
 public ActionResult ResultNotify()
 {
     WxPayApiBiz.ProcessResultNotify(HttpContext);
     return(View());
 }