Exemple #1
0
        private void Get_TenPay()
        {
            PageAdmin.Conn  Myconn = new PageAdmin.Conn();
            string          constr = Myconn.Constr();
            string          sql    = "select * from pa_onlinepay where onlinepay_type='tenpay'";
            OleDbConnection conn   = new OleDbConnection(constr);

            conn.Open();
            OleDbCommand    comm = new OleDbCommand(sql, conn);
            OleDbDataReader dr   = comm.ExecuteReader();

            if (dr.Read())
            {
                bargainor_id = dr["onlinepay_mid"].ToString();  //商户号
                key          = dr["onlinepay_key"].ToString();  //密钥
                url          = dr["url"].ToString();
            }
            else
            {
                bargainor_id = "";
                key          = "";
                url          = "";
            }
            dr.Close();
            conn.Close();
        }
Exemple #2
0
    public string Get_ChinaBank_Key()
    {
        PageAdmin.Conn Myconn=new PageAdmin.Conn();
           string constr=Myconn.Constr();
           string sql="select * from onlinepay where onlinepay_type='chinabank'";
           OleDbConnection conn=new OleDbConnection(constr);
           conn.Open();
           string Val;
           OleDbCommand comm=new OleDbCommand(sql,conn);
           OleDbDataReader dr=comm.ExecuteReader();
           if(dr.Read())
        {
           Val=dr["onlinepay_key"].ToString();;
        }
          else
        {
          Val="";
          Response.Write("error");
          Response.End();
        }

           return Val;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Member_Valicate MCheck=new Member_Valicate();
           MCheck.Member_Check("cn");
         //***************************************************************
        string alipayNotifyURL = "https://www.alipay.com/cooperate/gateway.do?";
        string[] Alipay_Val=Get_Alipay().Split(',');
        string key = Alipay_Val[0]; //partner 的对应交易安全校验码(必须填写)
        string _input_charset = "utf-8";
        string partner = Alipay_Val[1]; 		//partner合作伙伴id(必须填写)

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

        //获取支付宝ATN返回结果,true是正确的订单信息,false 是无效的
        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);

           /* for (i = 0; i < Sortedstr.Length; i++)
           {
          Response.Write("Form: " + Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]] + "<br>");
           }*/

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

        StringBuilder prestr = new StringBuilder();

        for (i = 0; i < Sortedstr.Length; i++)
        {
            if (Request.Form[Sortedstr[i]] != "" && 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);
        //**********************************************************************
        //生成Md5摘要;
           // string mysign = GetMD5(prestr.ToString(), _input_charset);
        string mysign = GetMD5(prestr.ToString(), _input_charset);
        string sign = Request.QueryString["sign"];
        string trade_status = Request.QueryString["trade_status"];

        //Response.Write(prestr.ToString());  //打印返回通知消息,接收到的

        if (mysign == sign && responseTxt == "true" && trade_status == "TRADE_FINISHED")   //验证支付发过来的消息,签名是否正确
        {

            //更新自己数据库的订单语句,请自己填写一下
               string Pay_Amount=Request.QueryString["total_fee"];
               string v_oid=Request.QueryString["trade_no"];
               double Fnc_Amount=double.Parse(Pay_Amount);
               PageAdmin.Conn Myconn=new PageAdmin.Conn();
               string constr=Myconn.Constr();
               conn=new OleDbConnection(constr);
               conn.Open();
               if(!Fnc_rk(v_oid))
                {
                  Update_member_fnc(Fnc_Amount);
                  Update_fnc_list(Fnc_Amount,"支付宝",v_oid,"订单号:"+v_oid);
                  string M_body="支付方式:支付宝<br>订单号:"+v_oid+"<br>支付金额:"+Pay_Amount;
                  SendMail(M_body);
                }
               else
                {
                  Response.Write("<script>alert('此次支付已经成功转入到您的用户名下!')</script>");
                }
              conn.Close();
              Pay_Result="支付成功,金额已经转入您的会员名下";

            //Response.Write("success");     //返回给支付宝消息,成功(不用返回给支付宝)
        //**************************************************************************
            //打印出接收通知。计算结果
            //Response.Write("------------------------------------------");
            //Response.Write("<br>Result:responseTxt=" + responseTxt);
            //Response.Write("<br>Result:mysign=" + mysign);
            //Response.Write("<br>Result:sign=" + sign);

        }
        else
        {
          //**************************************************************************
            //打印出接收通知。计算结果
            Response.Write("-------------------error-----------------------");
            Response.Write("<br>Result:responseTxt=" + responseTxt);
            Response.Write("<br>Result:mysign=" + mysign);
            Response.Write("<br>Result:sign=" + sign);
            Response.End();
        }
    }
 public string Get_Alipay()
 {
     PageAdmin.Conn Myconn=new PageAdmin.Conn();
        string constr=Myconn.Constr();
        string sql="select top 1 * from onlinepay where onlinepay_type='alipay'";
        OleDbConnection conn=new OleDbConnection(constr);
        conn.Open();
        string Val;
        OleDbCommand comm=new OleDbCommand(sql,conn);
        OleDbDataReader dr=comm.ExecuteReader();
        if(dr.Read())
     {
        Val=dr["onlinepay_key"].ToString()+","+dr["onlinepay_partnerid"].ToString();
     }
       else
     {
       Val="";
       Response.Write("Error");
       Response.End();
     }
        conn.Close();
        return Val;
 }
Exemple #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Member_Valicate MCheck=new Member_Valicate();
           MCheck.Member_Check("cn");

        // MD5密钥要跟订单提交页相同,如Send.asp里的 key = "test" ,修改""号内 test 为您的密钥
        string key = Get_ChinaBank_Key();	// 如果您还没有设置MD5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/
        // 登陆后在上面的导航栏里可能找到“资料管理”,在资料管理的二级导航栏里有“MD5密钥设置”
        // 建议您设置一个16位以上的密钥或更高,密钥最多64位,但设置16位已经足够了

        v_oid = Request["v_oid"];
        v_pstatus = Request["v_pstatus"];
        v_pstring = Request["v_pstring"];
        v_pmode = Request["v_pmode"];
        v_md5str = Request["v_md5str"];
        v_amount = Request["v_amount"];
        v_moneytype = Request["v_moneytype"];
        remark1 = Request["remark1"];
        remark2 = Request["remark2"];

        string str = v_oid + v_pstatus + v_amount + v_moneytype + key;

        str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();

        if (str == v_md5str)
        {

            if (v_pstatus.Equals("20"))
            {

                //支付成功
                //在这里商户可以写上自己的业务逻辑
               status_msg="支付成功,金额已经转入您的会员名下";
               double Fnc_Amount=double.Parse(v_amount);
               PageAdmin.Conn Myconn=new PageAdmin.Conn();
               string constr=Myconn.Constr();
               conn=new OleDbConnection(constr);
               conn.Open();
               if(!Fnc_rk(v_oid))
                {
                  Update_member_fnc(Fnc_Amount);
                  Update_fnc_list(Fnc_Amount,"网银在线",v_oid,"订单号:"+v_oid);
                  string M_body="支付方式:网银在线<br>订单号:"+v_oid+"<br>支付金额:"+v_amount;
                  SendMail(M_body);
                }
               else
                {
                  Response.Write("<script>alert('此次支付已经成功转入到您的用户名下!')</script>");
                }
              conn.Close();
            }
        }
        else
        {
            Response.Write("校验失败,数据可疑!");
            Response.End();
        }
    }