Beispiel #1
0
 [MethodImpl(MethodImplOptions.Synchronized)] //方法的同步属性
 static public wxOrderTmpMgr instance()
 {
     if (null == uniCounter)
     {
         uniCounter = new wxOrderTmpMgr();
     }
     return(uniCounter);
 }
Beispiel #2
0
 public static wxOrderTmpMgr instance()
 {
     if (null == uniCounter)
     {
         uniCounter = new wxOrderTmpMgr();
     }
     return uniCounter;
 }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //int wid = MyCommFun.RequestWid();
            int wid = 0;

            BLL.wx_logs logBll = new  BLL.wx_logs();
            logBll.AddLog("【微支付】微信预定", "notify_url Page_Load", "从微支付返回到notify_url.aspx页面", 1);
            BLL.wx_payment_wxpay payBll = new BLL.wx_payment_wxpay();



            ResponseHandler resHandler = new ResponseHandler(Context);

            resHandler.init();
            //取wid
            string attach = resHandler.getParameter("attach");

            string[] attachArr = attach.Split('|');
            wid = MyCommFun.Str2Int(attachArr[0]);
            int otid = MyCommFun.Str2Int(attachArr[1]);

            Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(wid);
            logBll.AddLog(wid, "【微支付】微信预定", "notify_url Page_Load", "取到wid=" + wid, 1);
            resHandler.setKey(paymentInfo.partnerKey, paymentInfo.paySignKey);// TenpayUtil.key, TenpayUtil.appkey);
            //resHandler.setKey("huyuxianghuyuxianghuyuxiang12345", "nwRmqgvSG08pe3vU5qzBLb7Bvih0WOABGzUPvqgFqE0iSkJlJ8wh7JlLYy2cXFgFA3v1bM8eTDm1y1UcyeW9IGq2py2qei7J5xDoVR9lfO3cS6fMjFbMQeeqBRit0bKp");
            //判断签名
            if (resHandler.isTenpaySign())
            {
                logBll.AddLog(wid, "【微支付】微信预定", "notify_url Page_Load", "resHandler.isTenpaySign()", 1);
                if (resHandler.isWXsign())
                {
                    //商户在收到后台通知后根据通知ID向财付通发起验证确认,采用后台系统调用交互模式
                    string notify_id = resHandler.getParameter("notify_id");
                    //取结果参数做业务处理
                    string out_trade_no = resHandler.getParameter("out_trade_no");
                    //财付通订单号
                    string transaction_id = resHandler.getParameter("transaction_id");
                    //金额,以分为单位
                    string total_fee = resHandler.getParameter("total_fee");
                    //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
                    string discount = resHandler.getParameter("discount");
                    //支付结果
                    string trade_state = resHandler.getParameter("trade_state");


                    string pay_info = resHandler.getParameter("pay_info");


                    logBll.AddLog(wid, "【微支付】微信预定", "notify_url Page_Load", "notify_id=" + notify_id + " out_trade_no=" + out_trade_no + " transaction_id=" + transaction_id + " total_fee=" + total_fee + " trade_state=" + trade_state + " orderid=" + otid + " wid=" + wid + "  pay_info=" + pay_info, 1);

                    //即时到账,支付成功
                    if ("0".Equals(trade_state))
                    {
                        logBll.AddLog(wid, "【微支付】微信预定", "notify_url Page_Load", "支付成功了", 1);
                        //------------------------------
                        //处理业务开始
                        //------------------------------
                        wxOrderTmpMgr Totbll = wxOrderTmpMgr.instance();
                        string        ret    = Totbll.ProcessPaySuccess_wx("notify_url", notify_id, out_trade_no, transaction_id, pay_info, MyCommFun.Str2Int(total_fee), otid, wid);
                        ret = ret == "" ? "处理数据同步发送成功" : ret;
                        logBll.AddLog(wid, "微信预定", "【微支付】notify_url Page_Load", ret, 1);
                        //处理数据库逻辑
                        //注意交易单不要重复处理
                        //注意判断返回金额


                        //------------------------------
                        //处理业务完毕
                        //------------------------------

                        //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知
                        Response.Write("success");
                    }
                    else
                    {
                        logBll.AddLog(wid, "【微支付】微信预定", "notify_url Page_Load", "支付失败", 1);
                        Response.Write("支付失败");
                    }
                    //回复服务器处理成功
                    Response.Write("success");
                }

                else
                {//SHA1签名失败
                    logBll.AddLog("微信预定", "【微支付】notify_url Page_Load", "fail -SHA1 failed", 0);
                    Response.Write("fail -SHA1 failed");
                    Response.Write(resHandler.getDebugInfo());
                }
            }
            else
            {//md5签名失败
                logBll.AddLog(wid, "微信预定", "【微支付】notify_url Page_Load", "fail -md5 failed", 0);
                Response.Write("fail -md5 failed");
                Response.Write(resHandler.getDebugInfo());
            }
        }
Beispiel #4
0
        /// <summary>
        /// 处理回调的页面
        /// </summary>
        private void ProcessNotify()
        {
            //int wid = MyCommFun.RequestWid();
            int wid = 0;

            logBll.AddLog("【微支付】微信预定", "notify_url ProcessNotify", "从微支付返回到notify_url.aspx页面", 1);

            byte[] byts = new byte[Request.InputStream.Length];
            Request.InputStream.Read(byts, 0, byts.Length);
            string req = System.Text.Encoding.Default.GetString(byts);

            req = Server.UrlDecode(req);
            logBll.AddLog("【微支付】微信预定", "notify_url ProcessNotify", "req:" + req, 1);

            //返回的状态码
            string return_code = ReadXmlValue(req, "xml/return_code");

            logBll.AddLog("【微支付】微信预定", "notify_url ProcessNotify", "返回的状态码return_code:" + return_code, 1);

            if (return_code.Trim().ToLower() == "fail")
            {
                string return_msg = ReadXmlValue(req, "xml/return_msg");
                logBll.AddLog("【微支付】微信预定", "notify_url ProcessNotify", "订单处理错误:" + return_msg, 0);
                WriteContent("fail", "订单处理错误:" + return_msg);
                return;
            }


            string attach = ReadXmlValue(req, "xml/attach");

            string[] attachArr = attach.Split('|');
            wid = MyCommFun.Str2Int(attachArr[0]);
            int otid = MyCommFun.Str2Int(attachArr[1]);

            BLL.wx_payment_wxpay   payBll      = new BLL.wx_payment_wxpay();
            Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(wid);
            logBll.AddLog(wid, "【微支付】微信预定", "notify_url ProcessNotify", "取到wid=" + wid, 1);



            string appId = ReadXmlValue(req, "xml/appid");             //公众账号id
            string mchId = ReadXmlValue(req, "xml/mch_id");            //商户号

            string result_code = ReadXmlValue(req, "xml/result_code"); //业务结果

            if (result_code.Trim().ToLower() == "fail")
            {
                //支付失败
                string err_code     = ReadXmlValue(req, "xml/err_code");
                string err_code_des = ReadXmlValue(req, "xml/err_code_des");
                logBll.AddLog(wid, "【微支付】微信预定", "notify_url ProcessNotify", "业务结果处理错误err_code:" + err_code + "[err_code_des]:" + err_code_des, 0);
                WriteContent("fail", "业务结果处理错误err_code:" + err_code + "[err_code_des]:" + err_code_des);
                return;
            }
            //支付成功
            string openid = ReadXmlValue(req, "xml/openid");
            //金额,以分为单位
            string total_fee = ReadXmlValue(req, "xml/total_fee");

            string out_trade_no = ReadXmlValue(req, "xml/out_trade_no");

            string transaction_id = ReadXmlValue(req, "xml/transaction_id");

            logBll.AddLog(wid, "【微支付】微信预定", "notify_url ProcessNotify", "支付成功了:openid=" + openid + " out_trade_no=" + out_trade_no + " transaction_id=" + transaction_id + " total_fee(分)=" + total_fee + " result_code=" + result_code + " orderid=" + otid + " wid=" + wid, 1);
            //------------------------------
            //处理业务开始
            //处理数据库逻辑
            //注意交易单不要重复处理
            //注意判断返回金额
            //------------------------------
            wxOrderTmpMgr Totbll = wxOrderTmpMgr.instance();
            string        ret    = Totbll.ProcessPaySuccess_wx("notify_url", out_trade_no, transaction_id, result_code, MyCommFun.Str2Int(total_fee), otid, wid);

            ret = ret == "" ? "处理数据同步发送成功" : ret;

            logBll.AddLog(wid, "微信预定", "【微支付】notify_url ProcessNotify", ret, 1);

            //------------------------------
            //处理业务完毕
            //------------------------------
            //回复服务器处理成功
            WriteContent("success");
        }