public PaymentInfo ProcessReturn(System.Web.HttpRequestBase context) { Dictionary <string, string> dicReturn = new Dictionary <string, string>(); context.Form.AllKeys.ToList().ForEach(item => { dicReturn.Add(item.ToString(), context.Form[item.ToString()]); }); CUConfig = Utility <ChinaUnionConfig> .GetConfig(WorkDirectory); string validateCertdir = WorkDirectory + "\\Cert\\"; try { bool isValidate = SignUtil.Validate(dicReturn, System.Text.ASCIIEncoding.GetEncoding(CUConfig.encoding), validateCertdir); if (!isValidate) { throw new PluginException("验签失败!"); } PaymentInfo payInfo = new PaymentInfo(); if (context.Form.AllKeys.Contains("orderId")) { var orderids = context.Form["orderId"].ToString().Replace("/", ","); payInfo.OrderIds = orderids.Split(',').Select(item => long.Parse(item)); } if (context.Form.AllKeys.Contains("queryId")) { payInfo.TradNo = context.Form["queryId"].ToString(); } payInfo.TradeTime = DateTime.Now; payInfo.ResponseContentWhenFinished = string.Empty; return(payInfo); } catch (Exception ex) { throw new PluginException("后台通知验签异常:" + ex.Message); } }
public PaymentInfo ProcessReturn(HttpRequestBase context) { PaymentInfo paymentInfo; Dictionary <string, string> strs = new Dictionary <string, string>(); context.Form.AllKeys.ToList().ForEach((string item) => strs.Add(item.ToString(), context.Form[item.ToString()])); string str = string.Concat(base.WorkDirectory, "\\Cert\\"); try { if (!SignUtil.Validate(strs, Encoding.GetEncoding(ChemCloud.Plugin.Payment.UnionPay.UnionPay.CUConfig.encoding), str)) { throw new PluginException("验签失败!"); } PaymentInfo paymentInfo1 = new PaymentInfo(); if (context.Form.AllKeys.Contains <string>("orderId")) { string str1 = context.Form["orderId"].ToString().Replace("/", ","); PaymentInfo paymentInfo2 = paymentInfo1; char[] chrArray = new char[] { ',' }; paymentInfo2.OrderIds = ( from item in str1.Split(chrArray) select long.Parse(item)); } if (context.Form.AllKeys.Contains <string>("queryId")) { paymentInfo1.TradNo = (context.Form["queryId"].ToString()); } paymentInfo1.TradeTime = (new DateTime?(DateTime.Now)); paymentInfo1.ResponseContentWhenFinished = (string.Empty); paymentInfo = paymentInfo1; } catch (Exception exception) { throw new PluginException(string.Concat("后台通知验签异常:", exception.Message)); } return(paymentInfo); }