示例#1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        MojoCube.Web.Order.Log log = new MojoCube.Web.Order.Log();
        int index = 0;

        //删除
        if (e.CommandName == "_delete")
        {
            index = Convert.ToInt32(e.CommandArgument);
            log.DeleteData(int.Parse(((Label)GridView1.Rows[index].FindControl("lblID")).Text));
        }
        GridBind();
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string data = string.Empty;

            try
            {
                //接收并读取POST过来的XML文件流
                StreamReader reader  = new StreamReader(Request.InputStream);
                String       xmlData = reader.ReadToEnd();

                data = xmlData;
            }
            catch { }

            MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
            order.GetData(GetWxKeyValue(data, "out_trade_no"));

            if (order.pk_Order > 0)
            {
                ViewState["AppID"] = GetWxKeyValue(data, "appid");
                string responseTxt = GetWxKeyValue(data, "return_code");

                if (!IsAllow())
                {
                    return;
                }

                if (!MojoCube.Web.Sql.IsExist("Order_Log", "fk_Order", order.pk_Order, "TransStatus='" + responseTxt + "'"))
                {
                    bool isSuccess = false;

                    if (responseTxt == "SUCCESS")
                    {
                        isSuccess = true;
                    }

                    MojoCube.Web.Order.Log log = new MojoCube.Web.Order.Log();
                    log.Number      = MojoCube.Api.Text.Function.DateTimeString(true);
                    log.OrderNumber = order.OrderNumber;
                    log.fk_Order    = order.pk_Order;
                    log.fk_Member   = order.fk_Member;
                    log.TypeID      = 0;
                    log.StatusID    = 0;
                    log.Title       = string.Empty;
                    log.Description = order.Description;
                    log.Amount      = order.Amount;
                    log.AppID       = ViewState["AppID"].ToString();
                    log.TransStatus = responseTxt;
                    if (isSuccess)
                    {
                        log.TransName   = "支付成功";
                        log.ResponseMsg = "交易成功";
                    }
                    else
                    {
                        log.TransName   = "支付失败";
                        log.ResponseMsg = "交易失败";
                    }
                    log.ChannelType    = "微信支付";
                    log.ResponseCode   = responseTxt;
                    log.OrderStartTime = GetWxKeyValue(data, "time_end");
                    log.OrderAmt       = GetWxKeyValue(data, "total_fee");
                    log.OrderTimeOut   = "0";
                    log.OrderType      = "普通消费";
                    log.DeviceType     = GetWxKeyValue(data, "trade_type");
                    log.ResponseTime   = log.OrderStartTime;
                    log.CurrencyType   = GetWxKeyValue(data, "fee_type");
                    log.Result         = data;
                    log.CreateDate     = DateTime.Now.ToString();
                    log.InsertData();

                    //支付成功
                    if (isSuccess)
                    {
                        //修改订单状态
                        order.StatusID    = 1;
                        order.fk_Payment  = 3;
                        order.PaymentDate = DateTime.Now.ToString();
                        order.UpdateData(order.pk_Order);

                        //通知微信已收到通知
                        Response.Write(CreateMsg());
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ///当不知道https的时候,请使用http
        //string alipayNotifyURL = "https://www.alipay.com/cooperate/gateway.do?";
        string alipayNotifyURL = "http://notify.alipay.com/trade/notify_query.do?";

        MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
        payment.GetDataByType(0);

        string partner = payment.PartnerID; //partner
        string key     = payment.KeyCode;   //安全校验码

        //alipayNotifyURL = alipayNotifyURL + "service=notify_verify" + "&partner=" + partner + "&notify_id=" + Request.QueryString["notify_id"];
        alipayNotifyURL = alipayNotifyURL + "partner=" + partner + "&notify_id=" + Request.QueryString["notify_id"];

        string responseTxt = Get_Http(alipayNotifyURL, 120000);
        //*********************************************************************************************
        int i;
        NameValueCollection coll;

        //Load Form variables into NameValueCollection variable.
        coll = Request.QueryString;

        // Get names of all forms into a string array.
        String[] requestarr = coll.AllKeys;

        //进行排序;
        string[] Sortedstr = BubbleSort(requestarr);

        //构造待md5摘要字符串;

        StringBuilder prestr = new StringBuilder();

        for (i = 0; i < Sortedstr.Length; i++)
        {
            if (Sortedstr[i] != "sign" && Sortedstr[i] != "sign_type")
            {
                if (i == Sortedstr.Length - 1)
                {
                    prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]]);
                }
                else
                {
                    prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]] + "&");
                }
            }
        }
        prestr.Append(key);

        string mysign    = GetMD5(prestr.ToString());               //生成MD5摘要
        string sign      = Request.Form["sign"];                    //签名
        string business  = Request.Form["seller_email"].ToString(); //收款方帐号ok
        string item_name = Request.Form["subject"].ToString();      //商品名ok
        string ordersn   = Request.Form["out_trade_no"].ToString(); //订单号ok
        string username  = Request.Form["receive_name"].ToString();
        string ppPrice   = Request.Form["price"].ToString();        //金额ok

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(ordersn);

        if (order.pk_Order > 0)
        {
            if (mysign != sign)
            {
                return;
            }

            if (!MojoCube.Web.Sql.IsExist("Order_Log", "fk_Order", order.pk_Order, "TransStatus='" + responseTxt + "'"))
            {
                bool isSuccess = false;

                if (responseTxt == "true")
                {
                    isSuccess = true;
                }

                MojoCube.Web.Order.Log log = new MojoCube.Web.Order.Log();
                log.Number      = MojoCube.Api.Text.Function.DateTimeString(true);
                log.OrderNumber = order.OrderNumber;
                log.fk_Order    = order.pk_Order;
                log.fk_Member   = order.fk_Member;
                log.TypeID      = 0;
                log.StatusID    = 0;
                log.Title       = string.Empty;
                log.Description = order.Description;
                log.Amount      = order.Amount;
                log.AppID       = string.Empty;
                log.TransStatus = responseTxt;
                if (isSuccess)
                {
                    log.TransName   = "支付成功";
                    log.ResponseMsg = "交易成功";
                }
                else
                {
                    log.TransName   = "支付失败";
                    log.ResponseMsg = "交易失败";
                }
                log.ChannelType    = "支付宝";
                log.ResponseCode   = responseTxt;
                log.OrderStartTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                log.OrderAmt       = ppPrice;
                log.OrderTimeOut   = "0";
                log.OrderType      = "普通消费";
                log.DeviceType     = "Web";
                log.ResponseTime   = log.OrderStartTime;
                log.CurrencyType   = "RMB";
                log.Result         = sign + "|" + business + "|" + item_name + "|" + ordersn + "|" + username + "|" + ppPrice;
                log.CreateDate     = DateTime.Now.ToString();
                log.InsertData();

                //支付成功
                if (isSuccess)
                {
                    //修改订单状态
                    order.StatusID    = 1;
                    order.fk_Payment  = 1;
                    order.PaymentDate = DateTime.Now.ToString();
                    order.UpdateData(order.pk_Order);

                    Response.Write("支付成功!");     //返回给支付宝消息,成功
                    Response.Write("<br>------------------" + Request.Form["body"]);
                }
                else
                {
                    Response.Write("支付失败,请与商家联系!");
                    Response.Write("<br>------------------" + Request.Form["body"]);
                }
            }
        }
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
        payment.GetDataByType(1);

        string         strUrl = payment.Gateway;
        HttpWebRequest req    = (HttpWebRequest)WebRequest.Create(strUrl);

        // Set values for the request back
        req.Method      = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        byte[] param      = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
        string strRequest = Encoding.ASCII.GetString(param);

        strRequest       += "&cmd=_notify-validate";
        req.ContentLength = strRequest.Length;

        //for proxy
        //WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
        //req.Proxy = proxy;

        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);

        streamOut.Write(strRequest);
        streamOut.Close();
        StreamReader streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
        string       responseTxt = streamIn.ReadToEnd();

        streamIn.Close();

        string business  = GetString("business");                  //收款方帐号ok
        string item_name = GetString("item_name");                 //商品名ok
        string ordersn   = GetString("item_number");               //订单号ok
        string username  = GetString("username");
        string txnid     = GetString("txn_id").ToString();         //ok
        string ppStatus  = GetString("payment_status").ToString(); //状态 ok//成功返回:Completed
        string ppDate    = GetString("payment_date").ToString();   //paypal服务器支付时间ok
        string ppPrice   = GetString("mc_gross").ToString();       //金额ok

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(ordersn);

        if (order.pk_Order > 0)
        {
            if (responseTxt != "VERIFIED")
            {
                return;
            }

            if (!MojoCube.Web.Sql.IsExist("Order_Log", "fk_Order", order.pk_Order, "TransStatus='" + ppStatus + "'"))
            {
                bool isSuccess = false;

                if (ppStatus == "Completed")
                {
                    isSuccess = true;
                }

                MojoCube.Web.Order.Log log = new MojoCube.Web.Order.Log();
                log.Number      = MojoCube.Api.Text.Function.DateTimeString(true);
                log.OrderNumber = order.OrderNumber;
                log.fk_Order    = order.pk_Order;
                log.fk_Member   = order.fk_Member;
                log.TypeID      = 0;
                log.StatusID    = 0;
                log.Title       = string.Empty;
                log.Description = order.Description;
                log.Amount      = order.Amount;
                log.AppID       = string.Empty;
                log.TransStatus = ppStatus;
                if (isSuccess)
                {
                    log.TransName   = "支付成功";
                    log.ResponseMsg = "交易成功";
                }
                else
                {
                    log.TransName   = "支付失败";
                    log.ResponseMsg = "交易失败";
                }
                log.ChannelType    = "Paypal";
                log.ResponseCode   = responseTxt;
                log.OrderStartTime = ppDate;
                log.OrderAmt       = ppPrice;
                log.OrderTimeOut   = "0";
                log.OrderType      = "普通消费";
                log.DeviceType     = "Web";
                log.ResponseTime   = log.OrderStartTime;
                log.CurrencyType   = "RMB";
                log.Result         = business + "|" + item_name + "|" + ordersn + "|" + username + "|" + txnid + "|" + ppStatus + "|" + ppDate + "|" + ppPrice;
                log.CreateDate     = DateTime.Now.ToString();
                log.InsertData();

                //支付成功
                if (isSuccess)
                {
                    //修改订单状态
                    order.StatusID    = 1;
                    order.fk_Payment  = 2;
                    order.PaymentDate = DateTime.Now.ToString();
                    order.UpdateData(order.pk_Order);
                }
            }
        }
    }