/** 是否财付通签名,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 * @return boolean */ public virtual Boolean _isTenpaySign(ArrayList akeys) { StringBuilder sb = new StringBuilder(); foreach (String k in akeys) { String v = (String)parameters[k]; if (null != v && "".CompareTo(v) != 0 && "sign".CompareTo(k) != 0 && "key".CompareTo(k) != 0) { sb.Append(k + "=" + v + "&"); } } sb.Append("key=" + this.getKey()); String sign = MD5Util.GetMD5(sb.ToString(), getCharset()).ToLower(); //debug信息 this.setDebugInfo(sb.ToString() + " => sign:" + sign); return(getParameter("sign").ToLower().Equals(sign)); }
/** * 是否财付通签名 * @Override * @return boolean */ public override Boolean isTenpaySign() { //获取参数 String cmdno = getParameter("cmdno"); String pay_result = getParameter("pay_result"); String date = getParameter("date"); String transaction_id = getParameter("transaction_id"); String sp_billno = getParameter("sp_billno"); String total_fee = getParameter("total_fee"); String fee_type = getParameter("fee_type"); String attach = getParameter("attach"); String tenpaySign = getParameter("sign").ToUpper(); String key = this.getKey(); //组织签名串 StringBuilder sb = new StringBuilder(); sb.Append("cmdno=" + cmdno + "&"); sb.Append("pay_result=" + pay_result + "&"); sb.Append("date=" + date + "&"); sb.Append("transaction_id=" + transaction_id + "&"); sb.Append("sp_billno=" + sp_billno + "&"); sb.Append("total_fee=" + total_fee + "&"); sb.Append("fee_type=" + fee_type + "&"); sb.Append("attach=" + attach + "&"); sb.Append("key=" + key); //算出摘要 String sign = MD5Util.GetMD5(sb.ToString(), getCharset()); //debug信息 setDebugInfo(sb.ToString() + " => sign:" + sign + " tenpaySign:" + tenpaySign); return(sign.Equals(tenpaySign)); }