示例#1
0
        public ActionResult WXPay(string OrderId)
        {
            var    orderModel = DB.ShopOrder.FindEntity(OrderId);
            H5Pay  h5Pay      = new H5Pay();
            var    wxConfig   = WxPayConfig.GetConfig();
            string clientIP   = wxConfig.GetIp();                                                                                           //获取客户端真实IP
            string url        = h5Pay.GetPayUrl(clientIP, orderModel.OrderCode, (orderModel.RealAmount + orderModel.Postage.Value) * 100M); //通过统一下单接口进行H5支付

            //Response.Redirect(url);//跳转到微信支付中间页
            ViewBag.body = url;
            return(View());
        }
示例#2
0
        protected void btnVxPay_Click(object sender, EventArgs e)
        {
            if (hidhospital.Value != "" && this.UserId > 0)
            {
                pa1.Visible = false;
                pa2.Visible = true;
                //绑定支付条目
                string    sql = "select * from lists where listname='SeekPetPayItem' order by sortorder";
                DataTable da  = SqlDataProvider.SqlDataProvider.GetSQLTable(sql);
                rePayList.DataSource = da;
                rePayList.DataBind();
                //int sumprice = 100;
                //int sumprice = int.Parse((float.Parse(da.Compute("sum([cast([value] as float)])", "1=1").ToString()) * 100).ToString());
                var p = (from DataRow record in da.Rows
                         select double.Parse(record["value"].ToString())).Sum();
                int sumprice = Convert.ToInt32(p * 100);
                lblSumPrice.Text = p.ToString();

                int    hospitalid = int.Parse(hidhospital.Value);
                string returnurl  = SuccessURL;
                //订单号
                string tradeno = "XP" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                returnurl += "?tradeno=" + tradeno;

                int cost = sumprice;
                //插入订单支付数据,生成订单
                See_Pay pay = new See_Pay();
                pay.UserID     = this.UserId;
                pay.UserSign   = "";
                pay.IsPay      = false;
                pay.TradeNo    = tradeno;
                pay.HospitalID = hospitalid;
                pay.CostMoney  = cost;
                pay.CreateTime = DateTime.Now;
                pay.IsVerify   = false;
                SqlDataProvider.SqlDataProvider.InsertSee_Pay(pay);
                //支付链接
                H5Pay h5pay = new H5Pay(Page);
                h5pay.total_fee = pay.CostMoney;
                WxPayData data = h5pay.GetUnifiedOrderResult(pay.TradeNo);
                lblresult.Text          = data.ToPrintStr();
                hyFinishPay.NavigateUrl = returnurl;
                btnsubmit.NavigateUrl   = data.GetValue("mweb_url").ToString() + "&redirect_url=" + Server.UrlEncode(returnurl);
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "resultTip", "<script>alert('支付出错!');</script>");
            }
        }
示例#3
0
        protected bool IsSuccess(string tradeno)
        {
            #region 测试,直接成功
            //return true;
            #endregion
            bool issuccess = false;
            //根据订单查询是否支付成功
            int       succCode = 0;
            WxPayData result   = H5Pay.Query(tradeno, out succCode);


            if (succCode == 1)
            {
                issuccess = true;
            }
            else
            {
                issuccess = false;
            }
            return(issuccess);
        }
示例#4
0
        /// <summary>
        /// 确认付款操作
        /// </summary>
        /// <returns></returns>
        public ActionResult DoPay(int addressid, string paytype, string remark, bool isziti, string payPwd)
        {
            JsonHelp json = new JsonHelp(true);

            try
            {
                Xml_Site    config     = DB.XmlConfig.XmlSite;
                Xml_Shop    shopConfig = DB.XmlConfig.XmlShop;
                Member_Info curUser    = User_Shop.GetMember_Info();
                //获取订单信息
                string        orderlist = CookieHelper.GetCookieValue("orderlist");
                List <string> orderList = orderlist.JsonDeserializer <List <string> >();
                if (orderList == null)
                {
                    throw new Exception("订单支付异常");
                }
                if (orderList.Count <= 0)
                {
                    throw new Exception("获取订单信息失败");
                }
                var orderid = orderList.First();
                var query   = DB.ShopOrder.Where(q => q.GUID == orderid).FirstOrDefault();
                if (query.State != 1)
                {
                    throw new Exception("订单不是待支付订单不可支付");
                }

                DB.ShopOrder.UpdateOrderInfo(orderList, addressid, remark, isziti, paytype);

                if (paytype == "余额")
                {
                    //计算处理
                    DB.ShopOrder.Calcute(curUser, orderList.First(), payPwd);
                    CookieHelper.ClearCookie("orderlist");
                }
                else if (paytype == "支付宝")
                {
                    json.ReUrl = "/Member_Mall/Pay/Pay?OrderId=" + orderList.First();//http://tjyy.fabeisha.cn
                    //r.ReUrl = "http://tjyy.fabeisha.cn/Member_Mall/Pay/Pay?BillId=" + r.BillId;//http://www.738600.cn
                }
                else if (paytype == "微信")
                {
                    var    orderModel = DB.ShopOrder.FindEntity(orderList.First());
                    H5Pay  h5Pay      = new H5Pay();
                    var    wxConfig   = WxPayConfig.GetConfig();
                    string clientIP   = wxConfig.GetIp();                                                                                           //获取客户端真实IP
                    var    url        = h5Pay.GetPayUrl(clientIP, orderModel.OrderCode, (orderModel.RealAmount + orderModel.Postage.Value) * 100M); //通过统一下单接口进行H5支付
                                                                                                                                                    //Response.Redirect(url);//跳转到微信支付中间页
                    json.ReUrl = url;
                    //json.ReUrl = "/Member_Mall/Pay/WXPay?OrderId=" + orderList.First();//http://tjyy.fabeisha.cn
                    //r.ReUrl = "/Member_Mall/Pay/WXPay?BillId=" + r.BillId;//http://tjyy.fabeisha.cn
                }

                //3.清空cookie
                CookieHelper.ClearCookie("cart");
                CookieHelper.ClearCookie("total");

                CookieHelper.ClearCookie("traceno");
            }
            catch (Exception ex)
            {
                StringBuilder str   = new StringBuilder();
                Exception     inner = ex;
                while (inner != null)
                {
                    str.AppendLine(inner.Message);
                    inner = inner.InnerException;
                }
                json.IsSuccess = false;
                json.Msg       = str.ToString();

                str.AppendLine("跟踪:" + ex.StackTrace);
                LogHelper.Debug(str.ToString());
            }

            return(Json(json));
        }