??????????????????asp.net(C#)????????????<???>
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了??????????????????asp.net(C#)????????????<???>相关的知识,希望对你有一定的参考价值。
?????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????
???????????????http://www.cnblogs.com/valu/p/4339939.html
?????????????????????
[HttpPost] public ActionResult index(decimal amount) { //????????????10?????????????????????????????????????????????????????????????????????????????????????????? string order_no = DateTime.Now.ToString("yyyyMMddHHmmss") + TenpayUtil.BuildRandomStr(4); //??????????????????????????????????????? ViewData["weixin_pay_qr_code"] = string.Format("/get_qrcode?product_id={0}", order_no); return View(); }
??????????????????
public void get_qrcode(string product_id) { WxPayHelper helper = new WxPayHelper(); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("appid", config_util.mp_weixin_appid); dic.Add("mch_id", config_util.weixin_mch_id); dic.Add("nonce_str", TenpayUtil.getNoncestr()); dic.Add("product_id", product_id); dic.Add("time_stamp", TenpayUtil.getTimestamp()); dic.Add("sign", helper.GetSign(dic)); string url = WxPayHelper.FormatBizQueryParaMap(dic, false);//????????????url?????? string code = "weixin://wxpay/bizpayurl?" + url; var qrc = Create_ImgCode(code, 6); System.IO.MemoryStream ms = new System.IO.MemoryStream(); qrc.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); byte[] bytes = ms.GetBuffer(); //byte[] bytes= ms.ToArray(); ?????????????????????????????????????????????????????? ms.Close(); Response.BinaryWrite(bytes); return; }
?????????????????????????????????
public ContentResult index() { if (Request.RequestType == "POST") { try { WxPayHelper helper = new WxPayHelper(); StreamReader reader = new StreamReader(Request.InputStream); String xmlData = reader.ReadToEnd(); helper.ReceivePostXmlData(xmlData); common_util.WriteLog("??????post??????xmlData=" + xmlData); if (helper.CheckSign()) { common_util.WriteLog("??????????????????"); string product_id = helper.GetProductId(); common_util.WriteLog("??????id=" + product_id); string order_no = product_id;if (??????ID??????) { #region ???????????? helper.SetParameter("body", "???????????????????????????" + item.user_id); helper.SetParameter("out_trade_no", order_no); helper.SetParameter("total_fee", (item.amount * 100).ToString("#"));//?????????????????? helper.SetParameter("notify_url", "http//www.openweixin.com.cn/notify"); helper.SetParameter("trade_type", "NATIVE"); string prepay_id = helper.GetPrepayId(); common_util.WriteLog("prepay_id=" + prepay_id); if (!string.IsNullOrEmpty(prepay_id)) { helper.SetReturnParameter("return_code", "SUCCESS"); helper.SetReturnParameter("result_code", "SUCCESS"); helper.SetReturnParameter("prepay_id", prepay_id); helper.SetReturnParameter("appid", helper.GetAppId); helper.SetReturnParameter("mch_id", helper.GetMch_Id); helper.SetReturnParameter("nonce_str", TenpayUtil.getNoncestr()); } else { helper.SetReturnParameter("return_code", "SUCCESS");//??????????????? helper.SetReturnParameter("result_code", "FAIL");//???????????? helper.SetReturnParameter("err_code_des", "?????????????????????"); } #endregion } else { helper.SetReturnParameter("return_code", "SUCCESS");//??????????????? helper.SetReturnParameter("result_code", "FAIL");//???????????? helper.SetReturnParameter("err_code_des", "???????????????");//???????????? } } else { helper.SetReturnParameter("return_code", "FAIL"); helper.SetReturnParameter("return_msg", "????????????"); common_util.WriteLog("????????????????????????"); } string xmlStr = helper.GetReturnXml(); common_util.WriteLog("??????xml=" + xmlStr); Response.ContentType = "text/xml"; Response.Clear(); Response.Write(xmlStr); Response.End(); } catch (Exception ex) { common_util.WriteLog("?????????" + ex); } } return Content("OK"); }
???????????????????????????
if (Request.RequestType == "POST") { try { WxPayHelper helper = new WxPayHelper(); StreamReader reader = new StreamReader(Request.InputStream); String xmlData = reader.ReadToEnd(); helper.ReceivePostXmlData(xmlData); common_util.WriteLog("Notify_??????post??????xmlData=" + xmlData); if (helper.CheckSign()) { Dictionary<string, string> dicBack = helper.GetParameter();//?????????????????? if (dicBack != null && dicBack.Keys.Contains("return_code")) { if (dicBack["return_code"] == "SUCCESS") { common_util.WriteLog("return_code=SUCCESS"); if (dicBack["result_code"] == "SUCCESS") { common_util.WriteLog("result_code=SUCCESS"); string out_trade_no = dicBack["out_trade_no"];//??????????????? common_util.WriteLog("out_trade_no=" + out_trade_no); //1.???????????????????????????????????? //2.?????????????????????????????????????????? //????????????out_trade_no ?????????????????? //???????????????????????? common_util.WriteLog("Notify_??????????????????"); helper.SetReturnParameter("return_code", "SUCCESS"); helper.SetReturnParameter("return_msg", ""); } } if (dicBack["return_code"] == "FAIL") { common_util.WriteLog("Notify_??????????????????"); helper.SetReturnParameter("return_code", "SUCCESS"); helper.SetReturnParameter("return_msg", dicBack["return_msg"]); } } } else { common_util.WriteLog("Notify_??????????????????"); helper.SetReturnParameter("return_code", "FAIL"); helper.SetReturnParameter("return_msg", "????????????"); } string xmlStr = helper.GetReturnXml(); common_util.WriteLog("Notify_??????xml=" + xmlStr); Response.ContentType = "text/xml"; Response.Clear(); Response.Write(xmlStr); Response.End(); } catch (Exception ex) { common_util.WriteLog("Notify_?????????" + ex); } } return Content("OK");
以上是关于??????????????????asp.net(C#)????????????<???>的主要内容,如果未能解决你的问题,请参考以下文章