public void VerifyReturn(int timeout, string configXml) { XmlDocument document = new XmlDocument(); document.LoadXml(configXml); Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (string str in this.parameters.AllKeys) { if (((str != "sign") && (str != "sign_type")) && (str.ToLower() != "higw")) { dict.Add(str, this.parameters[str]); } } string prestr = BuildQuery(dict, false) + document.FirstChild.SelectSingleNode("Key").InnerText; string sign = Function.Sign(prestr, "MD5", "utf-8"); string str4 = (this.parameters["sign"] == null) ? "" : this.parameters["sign"].ToLower(); if (sign != str4) { PayLog.writeLog_Collection(this.parameters, sign, "", "验签失败Return---" + document.FirstChild.SelectSingleNode("Key").InnerText + "---" + prestr, LogType.WS_WapPay); this.OnNotifyVerifyFaild(); } else if (this.trade_status.ToLower() != "success") { PayLog.writeLog_Collection(this.parameters, sign, "", "通知结果不为成功---" + prestr, LogType.WS_WapPay); this.OnNotifyVerifyFaild(); } else { this.OnFinished(false); } }
public override void VerifyNotify(int timeout, string configXml) { bool flag; XmlDocument document = new XmlDocument(); document.LoadXml(configXml); try { flag = bool.Parse(this.GetResponse(this.CreateUrl(document.FirstChild), timeout)); } catch (Exception exception) { PayLog.writeLog_Collection(this.parameters, this.GetResponse(this.CreateUrl(document.FirstChild), timeout) + "-" + this.CreateUrl(document.FirstChild), HttpContext.Current.Request.Url.ToString(), exception.Message, LogType.Alipay_Direct); flag = false; } this.parameters.Remove("HIGW"); string[] strArray2 = Globals.BubbleSort(this.parameters.AllKeys); string s = ""; for (int i = 0; i < strArray2.Length; i++) { if ((!string.IsNullOrEmpty(this.parameters[strArray2[i]]) && (strArray2[i] != "sign")) && (strArray2[i] != "sign_type")) { if (i == (strArray2.Length - 1)) { s = s + strArray2[i] + "=" + this.parameters[strArray2[i]]; } else { s = s + strArray2[i] + "=" + this.parameters[strArray2[i]] + "&"; } } } s = s + document.FirstChild.SelectSingleNode("Key").InnerText; flag = flag && this.parameters["sign"].Equals(Globals.GetMD5(s, "utf-8")); string str2 = this.parameters["trade_status"]; if (flag && ((str2 == "TRADE_SUCCESS") || (str2 == "TRADE_FINISHED"))) { this.OnFinished(false); } else { PayLog.AppendLog_Collection(this.parameters, this.parameters["sign"], Globals.GetMD5(s, "utf-8"), "签名验证失败", LogType.Alipay_Direct); this.OnNotifyVerifyFaild(); } }
public override void VerifyNotify(int timeout, string configXml) { if (!this.IsNotify) { this.VerifyReturn(timeout, configXml); } else { XmlDocument document = new XmlDocument(); document.LoadXml(configXml); this.parameters.Remove("HIGW"); string[] allKeys = this.parameters.AllKeys; Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (string str in this.parameters.AllKeys) { if ((str != "sign") && (str != "sign_type")) { dictionary.Add(str, this.parameters[str]); } } string prestr = "service=" + this.parameters["service"] + "&v=" + this.parameters["v"] + "&sec_id=" + this.parameters["sec_id"] + "¬ify_data=" + this.parameters["notify_data"] + document.FirstChild.SelectSingleNode("Key").InnerText.Trim(); string sign = Function.Sign(prestr, "MD5", "utf-8"); string str4 = (this.parameters["sign"] == null) ? "" : this.parameters["sign"].ToLower(); if (!(str4 == sign)) { PayLog.writeLog_Collection(this.parameters, sign, "", "验签失败Return---" + document.FirstChild.SelectSingleNode("Key").InnerText + "---" + prestr, LogType.WS_WapPay); this.OnNotifyVerifyFaild(); } else if (this.trade_status.ToLower() != "trade_success") { PayLog.writeLog_Collection(this.parameters, sign, "", "通知结果不为成功---" + prestr, LogType.WS_WapPay); this.OnNotifyVerifyFaild(); } else { this.OnFinished(false); } } }
public void LoadNotifydata(string notifydata) { try { XmlDocument document = new XmlDocument(); document.LoadXml(notifydata); XmlNode node = document.SelectSingleNode("notify/trade_no"); if (node != null) { this.trade_no = node.InnerText; } node = document.SelectSingleNode("notify/out_trade_no"); if (node != null) { this.out_trade_no = node.InnerText; } node = document.SelectSingleNode("notify/seller_email"); if (node != null) { this.seller_email = node.InnerText; } node = document.SelectSingleNode("notify/quantity"); if (node != null) { int.TryParse(node.InnerText, out this.quantity); } node = document.SelectSingleNode("notify/price"); if (node != null) { decimal.TryParse(node.InnerText, out this.price); } node = document.SelectSingleNode("notify/total_fee"); if (node != null) { decimal.TryParse(node.InnerText, out this.total_fee); } node = document.SelectSingleNode("notify/trade_status"); if (node != null) { this.trade_status = node.InnerText; } node = document.SelectSingleNode("notify/buyer_email"); if (node != null) { this.buyer_email = node.InnerText; } node = document.SelectSingleNode("notify/seller_email"); if (node != null) { this.seller_email = node.InnerText; } node = document.SelectSingleNode("notify/buyer_id"); if (node != null) { this.buyer_id = node.InnerText; } } catch (Exception exception) { PayLog.writeLog_Collection(this.parameters, "", "", "加载notifyData错误:" + exception.Message, LogType.WS_WapPay); } }