コード例 #1
0
        public override UnicomPayData CheckNotify()
        {
            Log.Info("CheckNotifyData():", "before");
            UnicomPayData notifyData = CheckNotifyData();

            Log.Info("CheckNotifyData():after return_code", notifyData.GetValue("return_code").ToString());
            if (notifyData.GetValue("return_code").ToString() == "FAIL")
            {
                return(notifyData);
            }

            return(notifyData);
        }
コード例 #2
0
ファイル: UnicomPay.cs プロジェクト: singlag888/NewWeb
        public UnicomPayData CheckNotifyData()
        {
            //接收从微信后台POST过来的数据
            System.IO.Stream s = page.Request.InputStream;
            Log.Info("接收从微信后台POST过来的数据", "");
            int count = 0;

            byte[]        buffer  = new byte[1024];
            StringBuilder builder = new StringBuilder();

            while ((count = s.Read(buffer, 0, 1024)) > 0)
            {
                builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
            }
            s.Flush();
            s.Close();
            s.Dispose();

            Log.Info(this.GetType().ToString(), "Receive data from Unicom : " + builder.ToString());


            UnicomPayData data = new UnicomPayData();

            try
            {
                data.FromXml(builder.ToString());
            }
            catch (Exception ex)
            {
                //若签名错误,则立即返回结果给微信支付后台
                UnicomPayData res = new UnicomPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", ex.Message);
                Log.Error(this.GetType().ToString(), "Sign check error : " + res.ToXml());
                return(res);
            }

            Log.Info(this.GetType().ToString(), "Check sign success");


            data.SetValue("return_code", "SUCCESS");
            return(data);
        }
コード例 #3
0
        public override UnicomPayData ProcessNotify()
        {
            UnicomPayData notifyData = GetNotifyData();

            if (notifyData.GetValue("return_code").ToString() == "FAIL")
            {
                return(notifyData);
            }

            //检查支付结果中transaction_id是否存在
            //if (!notifyData.IsSet("hRet"))
            //{
            //    //若transaction_id不存在,则立即返回结果给微信支付后台
            //    UnicomPayData res = new UnicomPayData();
            //    res.SetValue("return_code", "FAIL");
            //    res.SetValue("return_msg", "支付结果中微信订单号不存在");
            //    Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
            //    return res;
            //}

            //string transaction_id = notifyData.GetValue("transaction_id").ToString();

            return(notifyData);
        }