Exemplo n.º 1
0
        /// <summary>
        /// 验证签名
        /// </summary>
        /// <param name="param">待验证签名参数</param>
        /// <returns></returns>
        public bool VerifySign(PaymentParam param)
        {
            var sign = param.GetString("sign");

            param = param.Remove("sign");//移除不参与签名的参数
            return(sign.ToUpper().Equals(CreateSign(param)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 验证签名
        /// </summary>
        /// <param name="param">待验证签名参数</param>
        /// <returns></returns>
        public bool VerifySign(PaymentParam param)
        {
            var sign = param.GetString("sign");        //获取返回时的签名验证结果

            param = param.Remove("sign", "sign_type"); //移除不参与签名的参数

            var isValid = RSA.Verify(CreateSign(param), sign, Platform.PublicKey, Charset);

            //验证是否是支付宝服务器发来的请求
            var notifyId = param.GetString("notify_id");

            if (isValid && !string.IsNullOrEmpty(notifyId))
            {
                var reqParam = new PaymentParam();
                reqParam.Add("service", "notify_verify");
                reqParam.Add("partner", Platform.MerchantId);
                reqParam.Add("notify_id", notifyId);
                var url         = reqParam.ToQueryString(true, true);
                var responseTxt = Client.GetStringAsync(url).Result;
                return(responseTxt.ToLower() == "true");
            }
            return(false);
        }