Пример #1
0
        private void CheckResponseSign(QPayResponse response, QPayOptions options)
        {
            if (string.IsNullOrEmpty(response.ResponseBody))
            {
                throw new QPayException("sign check fail: Body is Empty!");
            }

            if (response.ResponseParameters.Count == 0)
            {
                throw new QPayException("sign check fail: Parameters is Empty!");
            }

            if (response.ResponseParameters["return_code"] == "SUCCESS")
            {
                if (!response.ResponseParameters.TryGetValue("sign", out var sign))
                {
                    throw new QPayException("sign check fail: sign is Empty!");
                }

                var cal_sign = QPaySignature.SignWithKey(response.ResponseParameters, options.Key);
                if (cal_sign != sign)
                {
                    throw new QPayException("sign check fail: check Sign and Data Fail!");
                }
            }
        }
Пример #2
0
        private void CheckResponseSign(QPayResponse response)
        {
            if (string.IsNullOrEmpty(response.Body))
            {
                throw new Exception("sign check fail: Body is Empty!");
            }

            var sign = response?.Sign;

            if (!response.IsError && !string.IsNullOrEmpty(sign))
            {
                var cal_sign = QPaySignature.SignWithKey(response.Parameters, Options.Key);
                if (cal_sign != sign)
                {
                    throw new Exception("sign check fail: check Sign and Data Fail!");
                }
            }
        }
Пример #3
0
        private void CheckResponseSign(QPayResponse response)
        {
            if (string.IsNullOrEmpty(response.Body) || response?.Parameters == null)
            {
                throw new Exception("sign check fail: Body is Empty!");
            }

            if (response.Parameters.TryGetValue("sign", out var sign))
            {
                if (response.Parameters["return_code"] == "SUCCESS" && !string.IsNullOrEmpty(sign))
                {
                    var cal_sign = QPaySignature.SignWithKey(response.Parameters, Options.Key);
                    if (cal_sign != sign)
                    {
                        throw new Exception("sign check fail: check Sign and Data Fail!");
                    }
                }
            }
        }