public ActionResult Pay(PayInfo payInfo) { var context = new AppContext() { UserId = new Guid("0D321367-C97F-46B0-81B7-4EDC5D7A2829"), UserName = "******" }; var bs = new ZzBS(context); var wx = new WXBS(context); var s = this.Request.InputStream; var count = 0; var buffer = new byte[1024]; var builder = new StringBuilder(); while ((count = s.Read(buffer, 0, 1024)) > 0) { builder.Append(Encoding.UTF8.GetString(buffer, 0, count)); } s.Flush(); s.Close(); s.Dispose(); var xml = builder.ToString(); payInfo = Utility.Deserialize <PayInfo>(xml); var result = wx.ConfirmPayment(payInfo); bs.ConfirmPayment(payInfo); return(Content(result ? "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>" : "<xml><return_code><![CDATA[FAILED]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>")); }
public ActionResult LoginCallback(string code, string state) { var wxHelper = WxApiHelper.Instance; string requestData = string.Format("appid={0}&secret={1}&code={2}&grant_type=authorization_code", WxConfig.Appid , WxConfig.Secret , code); string url = "https://api.weixin.qq.com/sns/oauth2/access_token"; var res = wxHelper.GetJosnData <AccessTokenResponse>(requestData, url); if (res != null && !string.IsNullOrEmpty(res.openid)) { var bs = new WXBS(new AppContext() { UserId = Guid.NewGuid(), UserName = res.openid }); bs.UpsertCustomer(res); var redirectUrl = string.Format("{0}/{1}", WxConfig.WebClientUrl, res.openid); return(Redirect(redirectUrl)); } else { return(RedirectToAction("WX404")); } }
public ActionResult GetUserInfo(string openId) { var user = new WXBS().GetWXUserInfo(openId); return(new JsonResult() { Data = new{ user.UserName, user.Avatar, user.OpenId }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }