예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="recharge"></param>
        public static void AddLog(ApiLog log)
        {
            if (log == null)
            {
                return;
            }
            String sql = String.Format("insert into log_api(orderid, apitype, type, url, datas) values('{0}','{1}','{2}','{3}','{4}')", log.orderid, log.apitype, log.type, log.url, log.datas);

            DBUtils.ExecuteNonQuery(sql);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            String writeString = "OK";

            if (IsPostBack)
            {
                Response.Write(writeString);
                Response.End();
                return;
            }

            ResponseHandler resHandler = new ResponseHandler(Context);

            FileLogUtils.Debug("PayNotify.aspx", resHandler.pairs.ToJsonString(), false);

            if (resHandler.pairs.Count == 0)
            {
                Response.Write(writeString);
                return;
            }

            NotifyResult requestParam = new NotifyResult();
            Result       sdkResult    = SDK.checkReturntParam(resHandler.pairs, ref requestParam);

            FileLogUtils.Info("PayNotify.aspx", sdkResult.ToJsonString());

            ApiLog log = new ApiLog();

            log.type    = 2;
            log.url     = "PayNotify.aspx";
            log.datas   = resHandler.pairs.ToJsonString();
            log.orderid = requestParam.out_trade_no;
            ApiLogUntils.AddLog(log);

            if (sdkResult.status != "1")
            {
                Response.Write(writeString);
                Response.End();
                return;
            }

            Recharge recharge = new Recharge();

            recharge.id          = requestParam.out_trade_no;
            recharge.pay_orderid = requestParam.trade_no;
            recharge.pay_money   = requestParam.resultMoney;
            if (recharge != null && !String.IsNullOrEmpty(recharge.id))
            {
                recharge.payStatus = 1;
                RechargeUtils.UpdateRechargeState(recharge);
            }
            Response.Write(writeString);
            Response.End();
        }
예제 #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="recharge"></param>
        /// <returns></returns>
        public static QueryResult QueryOrder(Recharge recharge)
        {
            QueryResult queryResult = new QueryResult();

            queryResult.code = "0";
            if (recharge == null || String.IsNullOrEmpty(recharge.id))
            {
                return(queryResult);
            }

            SortedDictionary <string, string> param = new SortedDictionary <string, string>();

            param.Add("act", "order");
            param.Add("pid", ConfigUtils.pid);      //商户号
            param.Add("key", ConfigUtils.key);
            param.Add("out_trade_no", recharge.id); //订单号

            List <String> queryParam = param.Select(A => String.Format("{0}={1}", A.Key, A.Value)).ToList();
            String        queryUrl   = ConfigUtils.queryurl;

            queryUrl = String.Format("{0}?{1}", queryUrl, String.Join("&", queryParam));

            FileLogUtils.TaskContent("requet begin:" + queryUrl);
            String requestResult = HttpClientProxy.GetRequestString(queryUrl);

            FileLogUtils.TaskContent("requet end:" + requestResult);
            if (String.IsNullOrEmpty(requestResult))
            {
                queryResult.code = "0";
                return(queryResult);
            }

            ApiLog log = new ApiLog();

            log.orderid = recharge.id;
            log.type    = 3;
            log.url     = queryUrl;
            log.datas   = requestResult;
            ApiLogUntils.AddLog(log);

            queryResult = JsonProxy.FromJsonString <QueryResult>(requestResult);
            if (queryResult == null)
            {
                queryResult = new QueryResult();
            }
            if (queryResult.code != "1" || queryResult.status != "1")
            {
                queryResult.code = "0";
                return(queryResult);
            }
            if (queryResult.pid.ToUpper() != ConfigUtils.pid.ToUpper()) //商户号不匹配
            {
                queryResult.code = "0";
                return(queryResult);
            }
            if (recharge.id != queryResult.out_trade_no) //商户订单号不匹配
            {
                queryResult.code = "0";
                return(queryResult);
            }

            Double pay_money = 0;

            if (!Double.TryParse(queryResult.money, out pay_money))
            {
                queryResult.code = "0";
                return(queryResult);
            }

            Recharge newRecharge = new Recharge();

            newRecharge.id          = recharge.id;
            newRecharge.pay_orderid = queryResult.trade_no;
            newRecharge.pay_money   = pay_money;
            newRecharge.payStatus   = 1;
            RechargeUtils.UpdateRechargeState(newRecharge);

            return(queryResult);
        }