string Pay(PayRequest req) { try { string result = string.Empty; #region 参数 Hashtable ht = new Hashtable(); ht.Add("appid", this.appid); ht.Add("timestamp", GetTimestamp().ToString()); ht.Add("once", req.once); ht.Add("attach", Base64Helper.Base64Encode(req.attach)); ht.Add("format", __format); ht.Add("method", __method); ht.Add("sign_type", __sign_type); //sign ht.Add("version", __version); ht.Add("data", req.data); ht.Add("key", this.secret_key); string sign = CreateSign(ht); ht.Add("sign", sign); #endregion #region 请求接口 string res = PostWebRequest(__request_url, CreateParams(ht), Encoding.UTF8); //string res = req.request_url+"?"+ CreateParams(ht); if (!string.IsNullOrEmpty(res)) { ResHaiBeiHu data = Newtonsoft.Json.JsonConvert.DeserializeObject <ResHaiBeiHu>(res); if (data != null) { ResHaiBeiHu_Result rere = Newtonsoft.Json.JsonConvert.DeserializeObject <ResHaiBeiHu_Result>(data.result); if (rere != null) { result = rere.payUrl; } } } #endregion return(result); } catch (Exception e) { throw (e); } }