Exemplo n.º 1
0
        public ActionResult PayNotifyUrl()
        {
            try
            {
                string[] strs   = Request.RawUrl.ToString().Split("/".ToCharArray());
                string   userID = strs[strs.Length - 1];
                LogerHelper.DefaultInfo(strs[strs.Length - 1]);
                NotifyHandler resHandler = new NotifyHandler(Request.InputStream);
                Hashtable     table      = resHandler.Parameters;
                ArrayList     akeys      = new ArrayList(table.Keys);
                akeys.Sort();
                foreach (string k in akeys)
                {
                    string v = (string)table[k];
                    LogerHelper.DefaultInfo(v);
                }
                string openid       = resHandler.GetParameter("openid");
                string total_fee    = resHandler.GetParameter("total_fee");
                string out_trade_no = resHandler.GetParameter("out_trade_no");
                LogerHelper.DefaultInfo("total_fee:    " + total_fee);
                LogerHelper.DefaultInfo("out_trade_no:    " + out_trade_no);
                resHandler.SetKey(Mch_Id);
                //验证请求是否从微信发过来(安全)
                //  if (resHandler.IsTenpaySign())
                // {
                //正确的订单处理
                LogerHelper.DefaultInfo("nofify     ok");
                //此处userid是回调url最后一个参数
                if (paymentbll.chargePayment(userID, Convert.ToInt32(total_fee), out_trade_no, (int)Commons.PayType.RECHARGE))
                {
                    LogerHelper.debug("微信支付成功!");
                }
                // WebHelper.Post(LocalContext.platformUrl + "/Pay/Recharge", "UserID=" + (Common.GlobalMap[openid] as UserInformation).userid + "Amount=" + total_fee + "PayOrderID=" + out_trade_no + "Type=1");
                //  }
                // else
                // {
                //错误的订单处理
                // LogerHelper.DefaultInfo("nofify     no");
                //  }
            }
            catch (Exception ex)
            {
                LogerHelper.DefaultInfo("ex:    " + ex.ToString());
            }

            return(Content("success"));
        }