public ContentResult getDecode(string openid, string city) { var pay = new JsApiPay(this.Request); var bus = new Bus(this.DataSource); string mch_id = WxPayConfig.getMCHID(city); var card = bus.GetCard(openid, WxPayConfig.APPID(city), mch_id); //乐清的订阅号appid pay.GetAccessToken("wx8a8f4c94ea99c3c6", "d08019f391fc2a7113e5efea6fc4c9dc", this.DataSource); return(Content(bus.DeCardCode(pay.access_token, card.CardId, card.CardCode))); }
/// <summary> /// 费率变动 /// </summary> /// <param name="list"></param> /// <param name="openId"></param> public void WXNTAgentFeeRate(List <SFee> list, string openId) { var accessToken = JsApiPay.GetAccessToken(); if (block.IndexOf(openId) > -1) { return; } PPInviteCodeNT notice = new PPInviteCodeNT(accessToken, list, openId); notice.Push(); }
public void WXNTPayTellAdmin(string openId) { var accessToken = JsApiPay.GetAccessToken(); EOrderInfo order = null; using (IQBContent db = new IQBContent()) { order = db.DBOrder.Where(a => a.OrderType == OrderType.WX).FirstOrDefault(); } PaySuccessTellAdminNT notice = new PaySuccessTellAdminNT(accessToken, openId, order); notice.Push(); }
public ContentResult createMenu(string city = "乐清市") { var pay = new JsApiPay(this.Request); //乐清的订阅号appid pay.GetAccessToken("wx8a8f4c94ea99c3c6", "d08019f391fc2a7113e5efea6fc4c9dc", this.DataSource); var bus = new Bus(this.DataSource); string path = Server.MapPath("~/business") + "\\yqmenu.js"; string json = bus.ReadJson(path); string result = bus.CreateMenu(pay.access_token, json); return(Content(result)); }
public ContentResult createCard(string city = "乐清市") { var pay = new JsApiPay(this.Request); pay.GetAccessToken("wxc20b289e21d1b606", "10711737c1c6b58b029f70c624bbb7e2", this.DataSource); var bus = new Bus(this.DataSource); string path = Server.MapPath("~/business") + "\\fuzhou.json"; string json = bus.ReadJson(path); //json = json.Replace("1397577600", WxPayApi.GenerateTimeStamp()).Replace("1472724261", WxPayApi.GenerateTimeStampy(50)); string result = bus.CreateCard(pay.access_token, json); //string wxurl = "https://api.weixin.qq.com/card/create?access_token=" + pay.access_token; //string result = HttpService.UploadMultimedia(wxurl, path); return(Content(result)); }
// // GET: /WeChat/ //public ActionResult Index() //{ // string pubkey = RSAKeyConvert.RSAPublicKeyDotNet2Java("<RSAKeyValue><Modulus>zZ2rr5JTmZAQWp6SGNTHj8j7Np6/hxBKr3tcWw2v/hOM8HEmVO6h3uKknAm/QfYBIJYAsDEUHMObvZKrZGbw3w==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"); // return Json(new {publickey=pubkey},JsonRequestBehavior.AllowGet); //} public ContentResult uploadPhoto(string photo = "vo") { string result = string.Empty; if (!string.IsNullOrEmpty(photo) && photo != "vo") { var pay = new JsApiPay(this.Request); //乐清"wx8a8f4c94ea99c3c6", "d08019f391fc2a7113e5efea6fc4c9dc" pay.GetAccessToken("wxc20b289e21d1b606", "10711737c1c6b58b029f70c624bbb7e2", this.DataSource); var bus = new Bus(this.DataSource); string filepath = Server.MapPath("~/Images") + "\\" + photo; result = bus.uploadPhoto(pay.access_token, filepath); return(Content(result)); } else { return(Content("请输入图片name!")); } }
/// <summary> /// 添加卡 /// </summary> /// <param name="openid"></param> /// <param name="city"></param> /// <returns></returns> public JsonResult addUserCard(string openid, string city) { var pay = new JsApiPay(this.Request); string appid = string.Empty, appSecret = string.Empty, card_id = string.Empty; switch (city) { case "乐清市": appid = "wx8a8f4c94ea99c3c6"; appSecret = "d08019f391fc2a7113e5efea6fc4c9dc"; card_id = "pszDVt2lJKXxOYA3alLVdbezrLTY"; break; case "常熟市": appid = "wx48a67a2aaf02f77a"; appSecret = "d788725d971438371f8a0b8c39221b2a"; card_id = "p__l8t2MvHkqBTDdGtiazSI_hSR0"; break; case "福州市": appid = "wxc20b289e21d1b606"; appSecret = "10711737c1c6b58b029f70c624bbb7e2"; card_id = "p4erJ0oPLrLMDhWcKZPLwF2Psdr8"; break; } //乐清的订阅号appid pay.GetAccessToken(appid, appSecret, this.DataSource); var bus = new Bus(this.DataSource); string mch_id = WxPayConfig.getMCHID(city); var Entrustinfo = bus.GetEntrustinfo(openid, WxPayConfig.APPID(city), mch_id); var card = bus.GetCard(openid, WxPayConfig.APPID(city), mch_id); string result = string.Empty; bool hasCard = !string.IsNullOrEmpty(card.CardCode) && card.IsRemove == 0; /* * if (!string.IsNullOrEmpty(card.CardCode)&&card.OperateTime.AddMinutes(10).CompareTo(DateTime.Now)<0) * { * string cardstate= bus.DeCardCode(pay.access_token, card.CardId, card.CardCode); * if (cardstate.ToLower().IndexOf("\"user_card_status\": \"NORMAL\"") == -1) * { * card.DataDriver = this.DataSource; * card.IsRemove = 1; * card.Store(); * hasCard = false; * } * } */ if (!hasCard) { if (Entrustinfo != null) { WxPayData inputObj = new WxPayData(city); inputObj.SetValue("appid", WxPayConfig.APPID(city)); inputObj.SetValue("mch_id", mch_id); inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr()); inputObj.SetValue("contract_id", Entrustinfo.FldContractId); inputObj.SetValue("sign_type", "MD5"); inputObj.SetValue("card_id", card_id); inputObj.SetValue("openid", openid); inputObj.SetValue("sign", inputObj.MakeSign()); string url = "https://api.mch.weixin.qq.com/transit/card/addcard"; string xml = inputObj.ToXml(); result = HttpService.Post(xml, url, false, 10); WxPayData data = new WxPayData(); data.FromXml(result); card.Remark = result; card.DataDriver = this.DataSource; if (data.GetValue("return_code").ToString().iEquals("success") && data.GetValue("result_code").ToString().iEquals("success")) { card.CardId = data.GetValue("card_id").ToString(); card.CardCode = data.GetValue("card_code").ToString(); card.OperateTime = DateTime.Now; card.IsRemove = 0; } card.Store(); } string signature = "", timestamp = WxPayApi.GenerateTimeStamp(); WxPayData exdata = new WxPayData(city); exdata.SetValue("code", card.CardCode); exdata.SetValue("openid", openid); exdata.SetValue("timestamp", timestamp); //exdata.SetValue("nonce_str", WxPayApi.GenerateNonceStr()); string ticket = bus.getTicket(appid, pay.access_token); string sign = string.Empty; string[] ArrTmp = { card.CardCode, openid, timestamp, appSecret }; //ticket Array.Sort(ArrTmp); //字典排序 string tmpStr = string.Join("", ArrTmp); sign = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1"); exdata.SetValue("signature", sign);//exdata.sha1() var cardList = new List <Card>(); var card1 = new Card(); card1.cardId = card.CardId; card1.cardExt = exdata.ToJson(); cardList.Add(card1); return(Json(new { hasCard = false, ticket = ticket, cardList = cardList, addcardCallback = result }, JsonRequestBehavior.AllowGet)); } else { //var pay = new JsApiPay(this.Request); ////乐清的订阅号appid //pay.GetAccessToken("wx8a8f4c94ea99c3c6", "d08019f391fc2a7113e5efea6fc4c9dc"); //bus.DeCardCode(pay.access_token, card.CardId, card.CardCode); } var cardList2 = new List <Cardv>(); var card2 = new Cardv(); card2.cardId = card.CardId; card2.code = card.CardCode; cardList2.Add(card2); return(Json(new { hasCard = true, cardList = cardList2 }, JsonRequestBehavior.AllowGet)); }