/// <summary> /// 易宝支付 /// </summary> /// <returns></returns> public string YBPaySendRequesWriter(YBRequestPara para, bool isMobile) { SortedDictionary <string, object> sd = new SortedDictionary <string, object>(); sd.Add("merchantaccount", Config.merchantAccount); sd.Add("amount", para.amount); sd.Add("currency", 156); sd.Add("identityid", "user_" + para.userId.DESDecrypt()); sd.Add("identitytype", 2); sd.Add("orderid", para.orderid); sd.Add("orderexpdate", 60); sd.Add("productcatalog", "48"); sd.Add("productdesc", "速库美味商品"); sd.Add("productname", "速库美味商品"); //DateTime t1 = DateTime.Now; //DateTime t2 = new DateTime(1970, 1, 1); //double t = t1.Subtract(t2).TotalSeconds; //int transtime = (int)t; sd.Add("transtime", para.orderTime.DateTimeConvertTimeStamp().ParseInt()); sd.Add("userip", "255.255.255.255"); sd.Add("terminaltype", 3); sd.Add("terminalid", "nothing"); sd.Add("callbackurl", APIURLConfig.callbackUrl); sd.Add("fcallbackurl", isMobile ? APIURLConfig.fcallbackUrl_Mobile : APIURLConfig.fcallbackUrl); sd.Add("userua", ""); sd.Add("paytypes", "1|2"); //生成RSA签名 string sign = EncryptUtil.handleRSA(sd, Config.merchantPrivatekey); sd.Add("sign", sign); //将网页支付对象转换为json字符串 string merchantAesKey = APIURLConfig.merchantAesKey; string wpinfo_json = Newtonsoft.Json.JsonConvert.SerializeObject(sd); string datastring = AES.Encrypt(wpinfo_json, merchantAesKey); string encryptkey = RSAFromPkcs8.encryptData(merchantAesKey, Config.yibaoPublickey, "UTF-8"); string postParams = "data=" + HttpUtility.UrlEncode(datastring) + "&encryptkey=" + HttpUtility.UrlEncode(encryptkey) + "&merchantaccount=" + Config.merchantAccount; string url = (!isMobile ? APIURLConfig.payWebPrefix : APIURLConfig.payMobilePrefix) + (!isMobile ? APIURLConfig.pcwebURI : APIURLConfig.webpayURI) + "?" + postParams; return(url); //return YBPAY.CreatePayByPostHTML(HttpUtility.UrlEncode(datastring), // HttpUtility.UrlEncode(encryptkey), // Config.merchantAccount,isMobile); }
/// <summary> /// 易宝支付 /// </summary> /// <returns></returns> public string YBPaySendRequesWriter(YBRequestPara para, bool isMobile) { SortedDictionary<string, object> sd = new SortedDictionary<string, object>(); sd.Add("merchantaccount", Config.merchantAccount); sd.Add("amount", para.amount); sd.Add("currency", 156); sd.Add("identityid", "user_" + para.userId.DESDecrypt()); sd.Add("identitytype", 2); sd.Add("orderid", para.orderid); sd.Add("orderexpdate", 60); sd.Add("productcatalog", "48"); sd.Add("productdesc", "速库美味商品"); sd.Add("productname", "速库美味商品"); //DateTime t1 = DateTime.Now; //DateTime t2 = new DateTime(1970, 1, 1); //double t = t1.Subtract(t2).TotalSeconds; //int transtime = (int)t; sd.Add("transtime", para.orderTime.DateTimeConvertTimeStamp().ParseInt()); sd.Add("userip", "255.255.255.255"); sd.Add("terminaltype", 3); sd.Add("terminalid", "nothing"); sd.Add("callbackurl", APIURLConfig.callbackUrl); sd.Add("fcallbackurl", isMobile ? APIURLConfig.fcallbackUrl_Mobile : APIURLConfig.fcallbackUrl); sd.Add("userua", ""); sd.Add("paytypes", "1|2"); //生成RSA签名 string sign = EncryptUtil.handleRSA(sd, Config.merchantPrivatekey); sd.Add("sign", sign); //将网页支付对象转换为json字符串 string merchantAesKey = APIURLConfig.merchantAesKey; string wpinfo_json = Newtonsoft.Json.JsonConvert.SerializeObject(sd); string datastring = AES.Encrypt(wpinfo_json, merchantAesKey); string encryptkey = RSAFromPkcs8.encryptData(merchantAesKey, Config.yibaoPublickey, "UTF-8"); string postParams = "data=" + HttpUtility.UrlEncode(datastring) + "&encryptkey=" + HttpUtility.UrlEncode(encryptkey) + "&merchantaccount=" + Config.merchantAccount; string url = (!isMobile ? APIURLConfig.payWebPrefix : APIURLConfig.payMobilePrefix) + (!isMobile ? APIURLConfig.pcwebURI : APIURLConfig.webpayURI) + "?" + postParams; return url; //return YBPAY.CreatePayByPostHTML(HttpUtility.UrlEncode(datastring), // HttpUtility.UrlEncode(encryptkey), // Config.merchantAccount,isMobile); }