Beispiel #1
0
        /// <summary>
        /// 获取响应结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="contentStr"></param>
        /// <param name="checkSign">是否检查返回签名,个别接口没有</param>
        /// <returns></returns>
        protected T GetRespResult <T>(string contentStr, bool checkSign = true) where T : WxPayBaseResp, new()
        {
            XmlDocument resultXml = null;
            var         dics      = SysUtil.ChangXmlToDir(contentStr, ref resultXml);

            var t = new T {
                RespXml = resultXml
            };

            t.FromResContent(dics);


            if (t.return_code.ToUpper() != "SUCCESS" ||
                t.result_code.ToUpper() != "SUCCESS")
            {
                t.ret = (int)ResultTypes.ObjectStateError;
                t.msg = string.Concat(t.return_msg, t.err_code_des);
                return(t);
            }

            if (checkSign)
            {
                var sign = dics["sign"]?.ToString();
                if (string.IsNullOrEmpty(sign) || sign != GetSign(GetSignContent(dics)))
                {
                    t.ret = (int)ResultTypes.ParaError;
                    t.msg = "返回签名信息校验不正确!";
                }
            }
            return(t);
        }
Beispiel #2
0
        /// <summary>
        /// 获取响应结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="contentStr"></param>
        /// <returns></returns>
        protected T GetRespResult <T>(string contentStr) where T : WxPayBaseResp, new()
        {
            XmlDocument resultXml = null;
            var         dics      = SysUtil.ChangXmlToDir(contentStr, ref resultXml);

            if (!dics.ContainsKey("sign"))
            {
                return new T {
                           ret = (int)ResultTypes.ParaError, msg = "当前结果签名信息不存在!"
                }
            }
            ;

            var t = new T {
                RespXml = resultXml
            };

            t.FromResContent(dics);

            var signStr = GetSign(GetSignContent(dics));

            if (signStr == t.sign)
            {
                return(t);
            }

            t.ret = (int)ResultTypes.ParaError;
            t.msg = "返回的结果签名(sign)不匹配";

            return(t);
        }
Beispiel #3
0
        /// <summary>
        /// 获取响应结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="contentStr"></param>
        /// <param name="checkSign">是否检查返回签名,个别接口没有</param>
        /// <returns></returns>
        protected T GetRespResult <T>(string contentStr, bool checkSign = true) where T : WxPayBaseResp, new()
        {
            XmlDocument resultXml = null;
            var         dics      = SysUtil.ChangXmlToDir(contentStr, ref resultXml);

            var t = new T {
                RespXml = resultXml
            };

            if (checkSign)
            {
                if (!dics.ContainsKey("sign"))
                {
                    return new T {
                               ret = (int)ResultTypes.ParaError, msg = "当前结果签名信息不存在!"
                    }
                }
                ;

                var signN = GetSign(GetSignContent(dics));
                if (signN != dics["sign"].ToString())
                {
                    return new T {
                               ret = (int)ResultTypes.ParaError, msg = "返回签名出现错误!"
                    }
                }
                ;
            }

            t.FromResContent(dics);
            return(t);
        }
Beispiel #4
0
        /// <summary>
        /// 获取响应结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="contentStr"></param>
        /// <returns></returns>
        protected T GetRespResult <T>(string contentStr) where T : WxPayBaseResp, new()
        {
            XmlDocument resultXml = null;
            var         dics      = SysUtil.ChangXmlToDir(contentStr, ref resultXml);

            var t = new T {
                RespXml = resultXml
            };

            t.FromResContent(dics);

            if (dics.ContainsKey("sign"))
            {
                var signStr = GetSign(GetSignContent(dics));

                if (signStr != t.sign)
                {
                    t.ret = (int)ResultTypes.ParaError;
                    t.msg = "返回的结果签名(sign)不匹配";
                }
            }

            if (t.return_code.ToUpper() != "SUCCESS")
            {
                //通信结果处理,这个微信做的其实没意义,脱裤子放屁
                t.ret = -1;
                t.msg = t.return_msg;
            }
            else if (!t.IsSuccess())
            {
                //  请求数据结果处理
                t.msg = GetErrMsg(t.err_code?.ToUpper());
            }

            return(t);
        }