示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            String radom = CommonUntils.CreateRandomCode(CodeCount);

            HttpContext.Current.Session["CheckCode"] = radom;
            ResponseHandler.AddCookie(this.Page, "CheckCode", radom);

            CreateCodeImg(radom, HttpContext.Current);
        }
示例#2
0
        public Newtonsoft.Json.Linq.JObject getPostParam([FromBody] RequestParam login)
        {
            FileLogUtils.Debug("getPostParam", login.ToJsonString(), false);

            if (login == null)
            {
                login = new RequestParam();
            }
            Newtonsoft.Json.Linq.JObject jobject = null;
            try
            {
                String sessionCode = "";
                if (HttpContext.Current.Session != null && HttpContext.Current.Session["CheckCode"] != null)
                {
                    sessionCode = HttpContext.Current.Session["CheckCode"].ToString();
                }

                login.uip = ResponseHandler.GetIPAddress();
                Result1 result = SDK.getPostParam(login, sessionCode);
                if (result.status == "1")
                {
                    String newSessionId = MD5Untils.GetMd5(TimeUntils.GetNow() + CommonUntils.CreateRandomCode(5)).ToUpper();
                    HttpContext.Current.Session[newSessionId] = result.message;
                    result.message = newSessionId;
                }

                String jsonString = result.ToJsonString();
                FileLogUtils.Debug("getPostParam", jsonString, true);
                jobject = jsonString.ConvertJObject();
            }
            catch (Exception ex)
            {
                FileLogUtils.Error("getPostParam", ex.Message);
            }
            return(jobject);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            ResponseHandler resHandler = new ResponseHandler(Context);
            RequestParam    param      = CommonUntils.DictionaryToClass <RequestParam>(resHandler.pairs);

            if (param == null)
            {
                param = new RequestParam();
            }
            if (String.IsNullOrEmpty(param.postMessage))
            {
                Response.Redirect("message.html?m=提交数据异常,请稍候再试.");
                return;
            }

            String postMessage = "";

            if (HttpContext.Current.Session != null && HttpContext.Current.Session[param.postMessage] != null)
            {
                postMessage = HttpContext.Current.Session[param.postMessage].ToString();
            }
            if (String.IsNullOrEmpty(postMessage))
            {
                Response.Redirect("message.html?m=提交数据异常,请稍候再试.");
                return;
            }
            postMessage = Base64.Decode(postMessage);
            if (String.IsNullOrEmpty(postMessage))
            {
                Response.Redirect("message.html?m=提交数据异常,请稍候再试.");
                return;
            }
            Dictionary <string, string> pay_params = postMessage.FromJsonString <Dictionary <string, string> >();

            if (pay_params == null || pay_params.Count == 0)
            {
                Response.Redirect("message.html?m=提交数据异常,请稍候再试.");
                return;
            }

            String dicKey = "remark";
            String mark   = "";

            if (pay_params.ContainsKey(dicKey))
            {
                mark = pay_params[dicKey];
                mark = Base64.Decode(mark);
            }
            Recharge recharge = mark.FromJsonString <Recharge>();

            if (recharge != null)
            {
                recharge.payStatus = 0;
                RechargeUtils.AddHistoryRecharge(recharge);
            }
            pay_params.Remove(dicKey);

            NameValueCollection data = new NameValueCollection();

            foreach (var item in pay_params)
            {
                data.Add(item.Key, item.Value);
            }

            String apiUrl        = ConfigUtils.payurl;
            String joinPostParam = String.Join("&", pay_params.Select(A => String.Format("{0}={1}", A.Key, A.Value)).ToList());

            FileLogUtils.Debug("RedirectAndPOST  Url", String.Format("{0}?{1}", apiUrl, joinPostParam), true);

            ApiLog log = new ApiLog();

            log.orderid = recharge.id;
            log.type    = 1;
            log.url     = apiUrl;
            log.datas   = pay_params.ToJsonString();
            ApiLogUntils.AddLog(log);

            HttpHelper.RedirectAndPOST(this.Page, apiUrl, data);
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            String localHost = ResponseHandler.GetRequestUrl(this.Page);

            ResponseHandler.AddCookie(this.Page, "LocalUrl", localHost);

            ResponseHandler resHandler = new ResponseHandler(Context);

            if (CommonUntils.IsFromMobile(Context.Request.UserAgent))
            {
                ColumnCount = 2;

                this.divBody.Style.Remove("width");
                this.divBody.Style.Remove("margin-top");
                this.divBody.Style.Add("width", "380px");
                this.divBody.Style.Add("margin-top", "10px");
            }

            //判断游戏账号
            String key      = "accounts".ToUpper();
            String accounts = "";

            if (resHandler.upperPairs.ContainsKey(key))
            {
                accounts = resHandler.upperPairs[key];
            }
            if (String.IsNullOrWhiteSpace(accounts))
            {
                Response.Redirect("Message.aspx?message=充值账号不能为空.");
                return;
            }

            UserAccount userAccount = AccountUntils.GetInfo(accounts);

            if (userAccount == null)
            {
                Response.Redirect("Message.aspx?message=充值账号不存在, 请先注册账号.");
                return;
            }
            this.accounts.Text = accounts;

            //判断客户区组
            key = "group".ToUpper();
            String group = "";

            if (resHandler.upperPairs.ContainsKey(key))
            {
                group = resHandler.upperPairs[key];
            }
            if (String.IsNullOrWhiteSpace(group))
            {
                Response.Redirect("Message.aspx?message=客户区组不能为空.");
                return;
            }
            this.group.Text = group;

            InitOrderNO();
            InitPayTypes();
            InitPayMoneys();
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static Result1 getPostParam(RequestParam param, String sessionCode)
        {
            Result1 result = new Result1();

            try
            {
                Decimal doubleMoney = 0;
                if (!Decimal.TryParse(param.pay_amount, out doubleMoney))
                {
                    result.status  = "failed";
                    result.message = "支付金额出现异常,请稍候再试.";
                    return(result);
                }
                if (doubleMoney <= 0)
                {
                    result.status  = "failed";
                    result.message = "支付金额出现异常,请稍候再试.";
                    return(result);
                }

                if (String.IsNullOrEmpty(sessionCode) ||
                    String.IsNullOrEmpty(param.code) ||
                    sessionCode.ToUpper() != param.code.ToUpper())
                {
                    result.status  = "failed";
                    result.message = "验证码错误,请重新输入.";
                    return(result);
                }
                if (String.IsNullOrWhiteSpace(param.pay_orderid) ||
                    String.IsNullOrWhiteSpace(param.pay_amount) ||
                    String.IsNullOrWhiteSpace(param.group) ||
                    String.IsNullOrWhiteSpace(param.pay_bankcode) ||
                    String.IsNullOrWhiteSpace(param.code))
                {
                    result.status  = "failed";
                    result.message = "提交数据出现异常,请稍候再试.";
                    return(result);
                }

                PayType payType = ConfigUtils.PayTypes.FirstOrDefault(A => A.Key == param.pay_bankcode);
                if (payType == null)
                {
                    result.status  = "failed";
                    result.message = "不支持该支付类型,请重新提交.";
                    return(result);
                }

                UserAccount userAccount = AccountUntils.GetInfo(param.accounts);
                if (userAccount == null)
                {
                    result.status  = "failed";
                    result.message = "充值账号不存在,请重新提交.";
                    return(result);
                }
                //if (String.IsNullOrEmpty(userAccount.agent))
                //{
                //    result.status = "failed";
                //    result.message = "代理不存在,无法充值.";
                //    return result;
                //}
                if (String.IsNullOrEmpty(userAccount.agent))
                {
                    userAccount.agent = "";
                }

                //写入历史订单表
                Recharge recharge = new Recharge();
                recharge.id        = param.pay_orderid;
                recharge.group     = param.group;
                recharge.accounts  = param.accounts;
                recharge.agent     = userAccount.agent;
                recharge.money     = Double.Parse(doubleMoney.ToString());
                recharge.time      = TimeUntils.GetNow();
                recharge.payStatus = 0;
                recharge.payType   = param.pay_bankcode;

                //Post参数
                SortedDictionary <string, string> pay_params = new SortedDictionary <string, string>();
                pay_params.Add("pid", ConfigUtils.pid);
                pay_params.Add("type", recharge.payType);            //平台分配商户号
                pay_params.Add("out_trade_no", recharge.id);         //订单号
                pay_params.Add("notify_url", ConfigUtils.notifyurl); //服务端返回地址(POST返回数据)
                pay_params.Add("return_url", ConfigUtils.returnurl); //页面跳转返回地址(POST返回数据)
                pay_params.Add("name", "充值");
                pay_params.Add("money", doubleMoney.ToString("F2")); //支付金额
                pay_params.Add("sitename", ConfigUtils.sitename);

                String sign = CommonUntils.getSign(pay_params);
                pay_params.Add("sign", sign);
                pay_params.Add("sign_type", "MD5");
                pay_params.Add("remark", Base64.Encode(recharge.ToJsonString()));

                String postMessage = pay_params.ToJsonString();
                postMessage = Base64.Encode(postMessage);

                result.status  = "1";
                result.postUrl = "PayNet.aspx";
                result.message = postMessage;
                return(result);
            }
            catch (Exception ex)
            {
                FileLogUtils.Error("getPostParam", ex.StackTrace);
                result.status  = "failed";
                result.message = "服务器出现异常,请稍候再试.";
                return(result);
            }
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="param"></param>
        /// <param name="sessionCode"></param>
        /// <returns></returns>
        public static Result checkReturntParam(Dictionary <string, string> pairs, ref NotifyResult requestParam)
        {
            Result result = new Result();

            try
            {
                requestParam = CommonUntils.DictionaryToClass <NotifyResult>(pairs);
                if (requestParam == null)
                {
                    result.message = "数据解析异常.";
                    return(result);
                }
                result.data = requestParam.ToJsonString();

                if (String.IsNullOrEmpty(requestParam.pid) ||
                    String.IsNullOrEmpty(requestParam.trade_no) ||
                    String.IsNullOrEmpty(requestParam.out_trade_no) ||
                    String.IsNullOrEmpty(requestParam.money) ||
                    String.IsNullOrEmpty(requestParam.sign))
                {
                    result.message = "数据解析异常.";
                    return(result);
                }

                if (requestParam.pid.ToUpper() != ConfigUtils.pid.ToUpper())
                {
                    result.message = "商户号不匹配.";
                    return(result);
                }
                if (requestParam.trade_status.ToUpper() != "TRADE_SUCCESS")
                {
                    result.status  = "failed";
                    result.message = "支付失败.";
                    return(result);
                }

                double doubleMoney = 0;
                if (!double.TryParse(requestParam.money, out doubleMoney))
                {
                    result.status  = "failed";
                    result.message = "支付金额出现异常,请稍候再试.";
                    return(result);
                }
                if (doubleMoney <= 0)
                {
                    result.status  = "failed";
                    result.message = "支付金额出现异常,请稍候再试.";
                    return(result);
                }
                requestParam.resultMoney = doubleMoney;

                SortedDictionary <string, string> dicMap = new SortedDictionary <string, string>();
                dicMap.Add("pid", requestParam.pid);
                dicMap.Add("trade_no", requestParam.trade_no);
                dicMap.Add("out_trade_no", requestParam.out_trade_no);
                dicMap.Add("type", requestParam.type);
                dicMap.Add("name", requestParam.name);
                dicMap.Add("money", requestParam.money);
                dicMap.Add("trade_status", requestParam.trade_status);

                Boolean flag = CommonUntils.verifySign(dicMap, requestParam.sign);
                if (!flag)
                {
                    result.message = "身份校验异常.";
                    return(result);
                }

                result.status  = "1";
                result.message = "";
                return(result);
            }
            catch (Exception ex)
            {
                FileLogUtils.Error("getPostParam", ex.StackTrace);
                result.status  = "failed";
                result.message = "服务器出现异常,请稍候再试.";
                return(result);
            }
        }