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); } }
private JdPayDictionary GetEncryptDicContent <T>(IJdPayRequest <T> request, IDictionary <string, string> dic) where T : JdPayResponse { var key = Convert.FromBase64String(Options.DesKey); var signDic = new JdPayDictionary(dic) { { VERSION, request.GetApiVersion() }, { MERCHANT, Options.Merchant }, }; var sign = JdPaySignature.RSASign(signDic, RSAPrivateParameters); var encyptDic = new JdPayDictionary { { VERSION, request.GetApiVersion() }, { MERCHANT, Options.Merchant }, { SIGN, sign } }; foreach (var item in dic) { if (!string.IsNullOrEmpty(item.Value)) { encyptDic.Add(item.Key, DES3.EncryptECB(key, item.Value)); } } return(encyptDic); }