/// <summary> /// 功能描述:汇通参数 /// </summary> /// <param name="parameter">参数</param> /// <param name="key">加密字段</param> /// <param name="type">类型</param> /// <returns></returns> public string ProcessingHT(Dictionary <string, string> parameter, string key, string type) { RulePayBehavior PayBehavior = new RulePayBehavior(); //得到加密方式 string SignMethod = parameter["SignMethod"].ToString(); string Amount = ""; if (type == "0") { Amount = "Amount"; } else { Amount = "Payment_amt"; } //金额乘以100 if (parameter.ContainsKey(Amount)) { parameter[Amount] = (decimal.Parse(parameter[Amount]) * 100).ToString("F0"); } //删除异步地址和同步地址 进行签名 parameter.Remove("SignMethod"); //排序 string paixu = PayBehavior.AsciiDesc(parameter).TrimEnd('&'); //排序后的字符串加上key paixu = paixu + key; //加密字符串 string sign = PayBehavior.EncryptionMd5(paixu, "x2"); //添加 加密方式和sign parameter.Add("SignMethod", SignMethod); parameter.Add("Signature", sign); //对特殊参数先进行Base64编码然后把其中的”+”替换为“%2b” String[] base64Keys = new String[] { "CodeUrl", "ImgUrl", "Token_Id", "PayInfo", "sPayUrl", "PayUrl", "NotifyUrl", "ReturnUrl" }; Dictionary <string, string> keyValuePairs = PayBehavior.stringtobase64(parameter, base64Keys); ////对所有的值进行encode string[] arrKeynew = keyValuePairs.Keys.ToArray(); for (int i = 0; i < arrKeynew.Length; i++) { keyValuePairs[arrKeynew[i].ToString()] = HttpUtility.UrlEncode(keyValuePairs[arrKeynew[i].ToString()], System.Text.Encoding.UTF8); } //string jsontext = PayBehavior.GetParamsStr(keyValuePairs); string jsontext = PayBehavior.GetParamsStr(keyValuePairs); //string jsontext = JsonHelper.SerializeObject(parameter); return(jsontext); }