Exemple #1
0
        /// <summary>
        /// 验证消息是否是支付宝发出的合法消息
        /// </summary>
        /// <param name="notifyId">通知验证ID</param>
        /// <param name="sign">支付宝生成的签名结果</param>
        /// <returns>验证结果</returns>
        public bool Verify(string notifyId, string sign)
        {
            //获取返回时的签名验证结果
            bool isSign = GetSignVerify(sign);
            //获取是否是支付宝服务器发来的请求的验证结果
            string responseText = "true";

            if (!string.IsNullOrEmpty(notifyId))
            {
                responseText = GetResponseText(notifyId);
            }

            //写日志记录(若要调试,请取消下面两行注释)
            //string word = "responseTxt=" + responseText + "\n isSign=" + isSign + "\n 返回回来的参数:" + GetPreSignStr() + "\n ";
            //AlipayCore.LogResult(word);

            //判断responseText是否为true,isSign是否为true
            //responseText的结果不是true,与服务器设置问题、合作身份者ID,notify_id一分钟失效有关
            //isSign不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
            bool isVerify = responseText == "true" && isSign;

            if (isVerify)
            {
                NotifyInfo = new AlipayNotifyInfo(_paras);
            }
            return(isVerify);
        }
Exemple #2
0
        /// <summary>
        /// 验证消息是否是支付宝发出的合法消息
        /// </summary>
        /// <param name="notifyId">通知验证ID</param>
        /// <param name="sign">支付宝生成的签名结果</param>
        /// <returns>验证结果</returns>
        public bool Verify(string notifyId, string sign)
        {
            //获取返回时的签名验证结果
            bool isSign = GetSignVerify(sign);
            //获取是否是支付宝服务器发来的请求的验证结果
            string responseText = "true";
            if (!string.IsNullOrEmpty(notifyId))
            {
                responseText = GetResponseText(notifyId);
            }

            //写日志记录(若要调试,请取消下面两行注释)
            //string word = "responseTxt=" + responseText + "\n isSign=" + isSign + "\n 返回回来的参数:" + GetPreSignStr() + "\n ";
            //AlipayCore.LogResult(word);

            //判断responseText是否为true,isSign是否为true
            //responseText的结果不是true,与服务器设置问题、合作身份者ID,notify_id一分钟失效有关
            //isSign不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
            bool isVerify = responseText == "true" && isSign;
            if (isVerify)
            {
                NotifyInfo = new AlipayNotifyInfo(_paras);
            }
            return isVerify;
        }