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); } }
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); } }