public async Task <T> ExecuteAsync <T>(HttpRequest request) where T : JdPayResponse
        {
            var body = await new StreamReader(request.Body).ReadToEndAsync();
            var rsp  = DecryptResponseXml <T>(JdPayUtil.FotmatXmlString(body));

            return(rsp);
        }
Beispiel #2
0
        public async Task <T> ExecuteAsync <T>(HttpRequest request) where T : JdPayNotifyResponse
        {
            if (request.ContentType == "application/x-www-form-urlencoded")
            {
                var key     = Convert.FromBase64String(Options.DesKey);
                var signDic = new JdPayDictionary();
                foreach (var item in request.Form)
                {
                    if (!string.IsNullOrEmpty(item.Value))
                    {
                        if (item.Key == "sign")
                        {
                            signDic.Add(item.Key, item.Value);
                        }
                        else
                        {
                            signDic.Add(item.Key, DES3.DecryptECB(key, item.Value));
                        }
                    }
                }

                var parser = new JdPayDictionaryParser <T>();
                var rsp    = parser.Parse(signDic);

                CheckNotifySign(signDic, RSAPrivateParameters);
                return(rsp);
            }
            else
            {
                var body = await new StreamReader(request.Body).ReadToEndAsync();
                var rsp  = DecryptResponseXml <T>(JdPayUtil.FotmatXmlString(body));
                return(rsp);
            }
        }
Beispiel #3
0
        public async Task <T> ExecuteAsync <T>(IJdPayRequest <T> request) where T : JdPayResponse
        {
            // 字典排序
            var sortedTxtParams = new JdPayDictionary(request.GetParameters());
            var xml             = BuildEncryptXml(request, sortedTxtParams);
            var body            = await Client.DoPostAsync(request.GetRequestUrl(), xml);

            return(DecryptResponseXml <T>(JdPayUtil.FotmatXmlString(body)));
        }
Beispiel #4
0
        public async Task <T> ExecuteAsync <T>(IJdPayRequest <T> request) where T : JdPayResponse
        {
            // 字典排序
            var sortedTxtParams = new JdPayDictionary(request.GetParameters());

            var content = GetEncryptXmlContent(request, sortedTxtParams);

            Logger.LogInformation(0, "Request Content:{content}", content);

            var rspContent = await Client.DoPostAsync(request.GetRequestUrl(), content);

            Logger.LogInformation(1, "Response Content:{content}", rspContent);

            var formatStr = JdPayUtil.FotmatXmlString(rspContent);

            return(DecryptResponseXmlContent <T>(formatStr));
        }
Beispiel #5
0
        public async Task <T> ExecuteAsync <T>(IJdPayRequest <T> request) where T : JdPayResponse
        {
            // 字典排序
            var sortedTxtParams = new JdPayDictionary(request.GetParameters());

            var reqContent = GetEncryptXmlContent(request, sortedTxtParams);

            var rspContent = await Client.DoPostAsync(request.GetRequestUrl(), reqContent);

            if (string.IsNullOrEmpty(rspContent))
            {
                throw new Exception("rspContent is Empty!");
            }

            var formatStr = JdPayUtil.FotmatXmlString(rspContent);

            return(DecryptResponseXmlContent <T>(formatStr));
        }
Beispiel #6
0
        public async Task <T> ExecuteAsync <T>(HttpRequest request) where T : JdPayNotifyResponse
        {
            if (request.ContentType == "application/x-www-form-urlencoded")
            {
                var dic = new JdPayDictionary();
                foreach (var item in request.Form)
                {
                    if (!string.IsNullOrEmpty(item.Value))
                    {
                        if (item.Key == "sign")
                        {
                            dic.Add(item.Key, item.Value);
                        }
                        else
                        {
                            dic.Add(item.Key, DES3.DecryptECB(DesKey, item.Value));
                        }
                    }
                }

                var query = HttpClientEx.BuildQuery(dic);
                Logger.LogInformation(1, "Request Content:{query}", query);

                var parser = new JdPayDictionaryParser <T>();
                var rsp    = parser.Parse(dic);

                CheckNotifySign(dic, RSAPrivateParameters);
                return(rsp);
            }
            else
            {
                var body = await new StreamReader(request.Body).ReadToEndAsync();
                Logger.LogInformation(1, "Request Content:{body}", body);

                var rsp = DecryptResponseXml <T>(JdPayUtil.FotmatXmlString(body));
                return(rsp);
            }
        }