private CommonRecive CallbackData(Dictionary <string, string> queryvalues, string billNo) { CommonRecive model = new CommonRecive(); int UserID = queryvalues.ContainsKey("UserID") ? Convert.ToInt32(queryvalues["UserID"].ToString()) : 0; int Type = queryvalues.ContainsKey("Type") ? Convert.ToInt32(queryvalues["Type"].ToString()) : 1; decimal Money = queryvalues.ContainsKey("Money") ? Convert.ToDecimal(queryvalues["Money"].ToString()) : 0; string ProductID = queryvalues.ContainsKey("ProductID") ? queryvalues["ProductID"].ToString() : ""; double Discounted = queryvalues.ContainsKey("Discounted") ? Convert.ToDouble(queryvalues["Discounted"].ToString()) : 0; string URL = queryvalues.ContainsKey("URL") ? queryvalues["URL"].ToString() : ""; model.Appid = "1103881749"; model.Amt = (int)(((int)Money * 100) * Discounted * 0.1); model.Sign = "123"; model.URL = ""; model.Payitem = billNo + "*" + Money + "*1"; model.Billno = billNo; model.URL = monicallbackUrl + "/" + URL; Role r = RoleBLL.GetModelByID(new Role() { ID = UserID }); model.Openid = r.OpenID; return(model); }
public ActionResult CommonPay(Dictionary <string, string> queryvalues) { #region 组装数据 生成订单 string billNO = Utils.GenerateOutTradeNo(queryvalues["Name"]); AddNo(queryvalues, billNO); CommonRecive rec = CallbackData(queryvalues, billNO); #endregion #region 发货 string callbackurl = rec.URL + @" amt=" + rec.Amt + @"&" + @" appid=" + rec.Appid + @"&" + @" billno=" + billNO + @"&" + @" ibazinga=1&" + @" openid=" + rec.Openid + @"&" + @" payamt_coins=0&" + @" paychannel=qdqb&" + @" paychannelsubid=1&" + @" payitem=" + rec.Payitem + @"&" + @" providetype=0&" + @" pubacct_payamt_coins=&" + @" token=" + Guid.NewGuid().ToString() + @"&" + @" ts=1460310868&version=v3&" + @" zoneid=0&" + @" trade_status=1&" + @" sig=123&" + @" out_trade_no=" + billNO + @"&" + @" sign=123" + @" "; callbackurl = callbackurl.Replace("\r", "").Replace("\n", ""); System.Net.WebRequest cwReq = System.Net.WebRequest.Create(callbackurl); System.Net.WebResponse cResp = cwReq.GetResponse(); System.IO.Stream crespStream = cResp.GetResponseStream(); // Dim reader As StreamReader = New StreamReader(respStream) string cs = ""; using (System.IO.StreamReader creader = new System.IO.StreamReader(crespStream)) { cs = creader.ReadToEnd(); } return(Content(cs)); #endregion }