Пример #1
0
        public string  wxNotify()
        {
            String post = this.GetPostData();

            LogHelper.Info <apiController>("wxNotify接受到支付通知结果:");


            System.Web.HttpContext.Current.Application.Lock();

            try
            {
                PayResultNotify myPayResultNotify = new PayResultNotify(post);

                Models.OrderDTO payrec = new Models.OrderDTO();
                payrec = _iOrderService.Get(myPayResultNotify.out_trade_no);

                string sign = myPayResultNotify.CountSign(2);

                LogHelper.Info <apiController>("wxNotify对比myPayResultNotify.sign:" + myPayResultNotify.sign);
                LogHelper.Info <apiController>("wxNotify对比myPayResultNotify.CountSign():" + sign);

                if (myPayResultNotify.sign.ToLower() == sign.ToLower())
                {
                    if (myPayResultNotify.return_code.ToUpper() == "SUCCESS".ToUpper() && myPayResultNotify.result_code.ToUpper() == "SUCCESS".ToUpper())
                    {
                        try
                        {
                            //payrec.p = DateTime.Now;
                            payrec.Price_h = Decimal.Parse(myPayResultNotify.total_fee) / 100;
                            //payrec.Status = 20;
                            _iOrderService.ChangeStatus(payrec, "付款成功");
                        }
                        catch (Exception er)
                        {
                            LogHelper.Error <apiController>(er, "wxNotify改变支付状态:" + er.ToString());
                        }
                        LogHelper.Info <apiController>("wxNotify改变支付状态:");

                        //处理业务逻辑
                    }

                    Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>");
                }
                else
                {
                    LogHelper.Info <MainController>("wxNotify接受到支付通知结果:" + post);
                    LogHelper.Info <MainController>("wxNotify传入的加密参数:" + myPayResultNotify.sign);
                    LogHelper.Info <MainController>("wxNotify计算的加密参数:" + sign);
                    Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[sign error!]]></return_msg></xml>");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info <MainController>("wxNotify接收支付结果通知失败:" + ex);
            }
            System.Web.HttpContext.Current.Application.UnLock();
            return("");
        }
Пример #2
0
        /// <summary>
        /// 创建异步通知对象
        /// </summary>
        /// <param name="dic"></param>
        /// <returns></returns>
        PayResultNotify GetPayResultNotify(SortedDictionary <string, string> dic)
        {
            //把数据对dic中取出转成PayResultNotify对象
            var payResultNotify = new PayResultNotify();

            foreach (var pro in payResultNotify.GetType().GetProperties())
            {
                if (dic.ContainsKey(pro.Name.ToLower()))
                {
                    var value = Convert.ChangeType(dic[pro.Name.ToLower()], pro.PropertyType);
                    pro.SetValue(payResultNotify, value, null);
                }
            }
            return(payResultNotify);
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PayResultNotify notify = new PayResultNotify(this.Page);

            notify.ProcessNotify();
        }