Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Vincent._Weixin.WeixinPay weixinpay = new Vincent._Weixin.WeixinPay("sAppID", "sAppSecret", "sPartner", "sPartnerKey", "sReturnUrl");
                openid = Vincent._Weixin.WeixinUtility.GetOpendId();

                Vincent._Log.SaveMessage("test.aspx获取openid=" + openid);
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var userid    = Vincent._Request.GetString("userid");
            var user_name = Vincent._Request.GetString("user_name");

            string          openid     = "";
            SybWxPayService sybService = new SybWxPayService();

            Vincent._Weixin.WeixinPay weixinpay = new Vincent._Weixin.WeixinPay("sAppID", "sAppSecret", "sPartner", "sPartnerKey", "sReturnUrl");
            openid = Vincent._Weixin.WeixinUtility.GetOpendId();

            if (openid != "" && Vincent._Convert.ToInt(userid) > 0)
            {
                BLL.users   bll   = new BLL.users();
                Model.users model = bll.GetModel(Vincent._Convert.ToInt(userid));

                model.safe_question = openid;
                if (bll.Update(model))
                {
                    Vincent._Log.SaveMessage("alinpay.aspx----->openid写入数据库成功userid=" + userid + "  ------> openid=" + openid);
                }
            }

            Vincent._Log.SaveMessage("test.aspx获取openid=" + openid);

            long pro_price = Vincent._Convert.ToInt64(Vincent._WebConfig.GetAppSettingsString("pro_price"), 1);

            try
            {
                Random ran = new Random();
                var    num = ran.Next(1000);

                Dictionary <String, String> rsp = sybService.pay(pro_price, user_name + "_" + num, "W02", "VIP会员一年有效期", "门川家居", openid, "", "http://shop.mc-house.com/WeixinPay/return_url.aspx", "");
                printRsp(rsp);
            }
            catch (Exception ex)
            {
                Vincent._Log.SaveMessage("收银宝支付异常:" + ex.Message);
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string openid = "";

            string IsTestPay = Vincent._WebConfig.GetAppSettingsString("IsTestPay");


            if (IsTestPay == "1")
            {
            }
            else
            {
                Vincent._Weixin.WeixinPay weixinpay = new Vincent._Weixin.WeixinPay("sAppID", "sAppSecret", "sPartner", "sPartnerKey", "sReturnUrl");
                openid = Vincent._Weixin.WeixinUtility.GetOpendId();

                Vincent._Log.SaveMessage("login.aspx获取openid=" + openid);

                if (openid != "")
                {
                    BLL.users   bll   = new BLL.users();
                    Model.users model = bll.GetModelByOpenId(openid);

                    if (model != null && model.id > 0)
                    {
                        hMobile.Value = model.user_name;
                        hVip.Value    = model.IsBuwei.ToString();
                    }

                    //model.avatar = openid;
                    //if (bll.Update(model))
                    //{
                    //    Vincent._Log.SaveMessage("openid写入数据库成功userid=" + userid + "  ------> openid=" + openid);
                    //}
                }
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Vincent._Log.SaveMessage("进来页面");

            if (!IsPostBack)
            {
                try
                {
                    Vincent._Weixin.WeixinPay weixinpay = new Vincent._Weixin.WeixinPay("sAppID", "sAppSecret", "sPartner", "sPartnerKey", "sReturnUrl");

                    string strBillNo = Vincent._Weixin.WeixinPay.getTimestamp();
                    var    userid    = Vincent._Request.GetString("userid");
                    var    user_name = Vincent._Request.GetString("user_name");


                    var orid  = userid + "_" + strBillNo;
                    var money = Vincent._Convert.ToInt64(Vincent._WebConfig.GetAppSettingsString("pro_price"), 1);


                    //decimal money = (decimal)_Request.GetFloat("money");
                    string strWeixin_OpenID = "";
                    string strCode          = Request["code"] == null ? "" : Request["code"];

                    Vincent._Log.SaveMessage("第一步,获取code:" + strCode);

                    if (string.IsNullOrEmpty(strCode))
                    {
                        //参数需要自己处理
                        string _OAuth_Url = Vincent._Weixin.WeixinPay.OAuth2_GetUrl_Pay(Request.Url.ToString());

                        Response.Redirect(_OAuth_Url);
                        return;
                    }
                    else
                    {
                        Vincent._Weixin.ReturnValue retValue = Vincent._Weixin.WeixinPay.OAuth2_Access_Token(strCode);

                        if (retValue.HasError)
                        {
                            Vincent._Log.SaveMessage("获取code失败:" + retValue.Message);

                            //Response.Write("获取code失败:" + retValue.Message);
                            //return;
                        }
                        strWeixin_OpenID = retValue.GetStringValue("Weixin_OpenID");
                        string strWeixin_Token = retValue.GetStringValue("Weixin_Token");

                        if (string.IsNullOrEmpty(strWeixin_OpenID))
                        {
                            Vincent._Log.SaveMessage("openid出错:" + strWeixin_OpenID);

                            //Response.Write("openid出错");
                            //return;
                        }
                    }

                    string _Pay_Package = "";

                    string IsTestPay = Vincent._WebConfig.GetAppSettingsString("IsTestPay");


                    if (IsTestPay == "1")
                    {
                        _Pay_Package = weixinpay.Get_RequestHtml(strWeixin_OpenID, orid, 0.1M, "门川家居", "hb_store");
                    }
                    else
                    {
                        _Pay_Package = weixinpay.Get_RequestHtml(strWeixin_OpenID, orid, money, "门川家居", "hb_store");
                    }
                    //string _Pay_Package = Interface_WxPay.Get_RequestHtml(strWeixin_OpenID, id, money, "宇航龙商城", "hb_store");


                    Vincent._Log.SaveMessage("第三步 结束:" + _Pay_Package);


                    //微信jspai支付
                    if (_Pay_Package.Length > 0)
                    {
                        wx_packageValue = _Pay_Package;
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Vincent._Weixin.WeixinPay weixinpay = new Vincent._Weixin.WeixinPay("sAppID", "sAppSecret", "sPartner", "sPartnerKey", "sReturnUrl");

            string strWeixin_OpenID = "";
            string strCode          = Request["code"] == null ? "" : Request["code"];

            Vincent._Log.SaveMessage("分享,第一步,获取code:" + strCode);

            if (string.IsNullOrEmpty(strCode))
            {
                //参数需要自己处理
                string _OAuth_Url = Vincent._Weixin.WeixinPay.OAuth2_GetUrl_Pay(Request.Url.ToString());

                Response.Redirect(_OAuth_Url);
                return;
            }
            else
            {
                Vincent._Weixin.ReturnValue retValue = Vincent._Weixin.WeixinPay.OAuth2_Access_Token(strCode);

                if (retValue.HasError)
                {
                    Vincent._Log.SaveMessage("分享,获取code失败:" + retValue.Message);

                    //Response.Write("获取code失败:" + retValue.Message);
                    //return;
                }
                strWeixin_OpenID = retValue.GetStringValue("Weixin_OpenID");
                string strWeixin_Token = retValue.GetStringValue("Weixin_Token");

                if (string.IsNullOrEmpty(strWeixin_OpenID))
                {
                    Vincent._Log.SaveMessage("openid出错:" + strWeixin_OpenID);

                    //Response.Write("openid出错");
                    //return;
                }

                if (strWeixin_OpenID != "")
                {
                    var user_id = Vincent._Request.GetInt("userid", 0);
                    Vincent._Log.SaveMessage("分享页面user_id:" + user_id);

                    BLL.users   bll   = new BLL.users();
                    Model.users model = bll.GetModel(user_id);

                    model.safe_question = strWeixin_OpenID;
                    if (bll.Update(model))
                    {
                        Vincent._Log.SaveMessage("index.aspx---->openid写入数据库成功userid=" + user_id + "  ------> openid=" + strWeixin_OpenID);
                    }

                    Vincent._Weixin.WeixinUtility weixin = new Vincent._Weixin.WeixinUtility("sAppID", "sAppSecret");
                    var userinfo = weixin.GetWeixinUserInfo(strWeixin_OpenID);

                    // 更新客户图象信息

                    if (user_id > 0 && userinfo.headimgurl != "" && userinfo.headimgurl != null)
                    {
                        divLogo.InnerHtml      = "<img src=\"" + userinfo.headimgurl + "\" />";
                        spanRealName.InnerText = userinfo.nickname;

                        var outmsgId = new BLL.users().UpdateHeadImageUrl(user_id, userinfo.headimgurl);
                        Vincent._Log.SaveMessage("更新会员(会员id=" + user_id + ")头像," + outmsgId);
                    }

                    Vincent._Log.SaveMessage("图象地址:" + userinfo.headimgurl);
                }
            }



            //var userid = Vincent._Request.GetString("userid");
            //string openid = "";

            //Vincent._Weixin.WeixinPay weixinpay = new Vincent._Weixin.WeixinPay("sAppID", "sAppSecret", "sPartner", "sPartnerKey", "sReturnUrl");
            //openid = Vincent._Weixin.WeixinUtility.GetOpendId();

            //if (openid != "" && Vincent._Convert.ToInt(userid) > 0)
            //{
            //    BLL.users bll = new BLL.users();
            //    Model.users model = bll.GetModel(Vincent._Convert.ToInt(userid));

            //    model.safe_question = openid;
            //    if (bll.Update(model))
            //    {
            //        Vincent._Log.SaveMessage("index.aspx---->openid写入数据库成功userid=" + userid + "  ------> openid=" + openid);
            //    }


            //    Vincent._Weixin.WeixinUtility weixin = new Vincent._Weixin.WeixinUtility("sAppID", "sAppSecret");
            //    var userinfo = weixin.GetWeixinUserInfo(openid);

            //    // 更新客户图象信息
            //    var user_id = Vincent._Request.GetInt("userid", 0);
            //    Vincent._Log.SaveMessage("分享页面user_id:" + user_id);

            //    if (user_id > 0 && userinfo.headimgurl != "" && userinfo.headimgurl != null)
            //    {
            //        divLogo.InnerHtml = "<img src=\"" + userinfo.headimgurl + "\" />";
            //        spanRealName.InnerText = userinfo.nickname;

            //        var outmsgId = new BLL.users().UpdateHeadImageUrl(user_id, userinfo.headimgurl);
            //        Vincent._Log.SaveMessage("更新会员(会员id=" + user_id + ")头像," + outmsgId);
            //    }
            //    //SummitLocalStorage.LocalStorage.get({ key: "summit" });

            //    Vincent._Log.SaveMessage("图象地址:" + userinfo.headimgurl);
            //    //hOpenID.Value = strWeixin_OpenID;

            //}
        }