public ActionResult Create() { /*ViewBag.silverTokens = db.Parameters.Find("S").Value; * ViewBag.goldTokens = db.Parameters.Find("G").Value; * ViewBag.platinumTokens = db.Parameters.Find("P").Value; * * float tokenPrice = float.Parse(db.Parameters.Find("T").Value, CultureInfo.InvariantCulture); * var currency = db.Parameters.Find("C").Value; * * ViewBag.silverPrice = tokenPrice * int.Parse(ViewBag.silverTokens); * ViewBag.goldPrice = tokenPrice * int.Parse(ViewBag.goldTokens); * ViewBag.platinumPrice = tokenPrice * int.Parse(ViewBag.platinumTokens); * * ViewBag.currency = currency;*/ using (var db = new Model1()) { /*if (User.Identity.IsAuthenticated) * { * TempData.Remove("Tokens"); * var id = User.Identity.GetUserId(); * var result = db.AspNetUsers.Where(u => u.Id == id).First(); * TempData.Add("Tokens", result.tokens); * }*/ Paymentwall_Base.setApiType(Paymentwall_Base.API_VC); Paymentwall_Base.setAppKey("b10c3555ee8a2076c998aff76d19b145"); Paymentwall_Base.setSecretKey("cb2964e08f83150add5d58c3dc93950d"); var userId = User.Identity.GetUserId(); var user = db.AspNetUsers.Find(userId); Dictionary <string, string> extraParams = new Dictionary <string, string>(); double unixtime = (TimeZoneInfo.ConvertTimeToUtc(new DateTime(2016, 11, 11, 3, 12, 1, 1, System.DateTimeKind.Utc)) - new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds; extraParams.Add("email", user.Email); extraParams.Add("registration_date", unixtime.ToString()); //extraParams.Add("ref", "123"); Paymentwall_Widget pww = new Paymentwall_Widget(User.Identity.GetUserId(), "p1_1", extraParams); ViewBag.widget = pww.getHtmlCode(); return(View()); } }
public ActionResult Pingback() { lock (Models.lockObjects.dblock) { //Response.Write("IM IN"); Paymentwall_Base.setApiType(Paymentwall_Base.API_VC); Paymentwall_Base.setAppKey("b10c3555ee8a2076c998aff76d19b145"); Paymentwall_Base.setSecretKey("cb2964e08f83150add5d58c3dc93950d"); Paymentwall_Pingback pp = new Paymentwall_Pingback(Request.Params, Request.UserHostAddress); //string uid = pp.getUserId(); //var hub = GlobalHost.ConnectionManager.GetHubContext<AuctionHub>(); //hub.Clients.All.notifyTokenChange(Request.Params.ToString()); try { if (!pp.validate()) { throw new Exception(pp.getErrorSummary()); } using (var db = new Model1()) { string uid = pp.getUserId(); if (pp.isDeliverable()) { Order o = new Order(); o.Id = Guid.NewGuid().ToString(); o.UserId = uid; o.Tokens = Int32.Parse(pp.getVirtualCurrencyAmount()); o.Status = 2; o.Price = o.Tokens * float.Parse(db.Parameters.Find("T").Value, CultureInfo.InvariantCulture); o.CurrencyId = db.Parameters.Find("C").Value; o.CreatedOn = DateTime.Now; db.Orders.Add(o); var user = db.AspNetUsers.Find(uid); user.Tokens += o.Tokens; db.Entry(user).State = System.Data.Entity.EntityState.Modified; var hub = GlobalHost.ConnectionManager.GetHubContext <SignalRHub>(); hub.Clients.User(user.Email).updateTokens(user.Tokens); db.SaveChanges(); } if (pp.isCancelable()) { Order o = new Order(); o.Id = Guid.NewGuid().ToString(); o.UserId = uid; o.Tokens = Int32.Parse(pp.getVirtualCurrencyAmount()); o.Status = 3; o.Price = o.Tokens * float.Parse(db.Parameters.Find("T").Value, CultureInfo.InvariantCulture); o.CurrencyId = db.Parameters.Find("C").Value; o.CreatedOn = DateTime.Now; db.Orders.Add(o); var user = db.AspNetUsers.Find(uid); /*user.tokens += o.Price; * db.Entry(user).State = System.Data.Entity.EntityState.Modified; * * var hub = GlobalHost.ConnectionManager.GetHubContext<SignalRHub>(); * hub.Clients.User(user.Email).updateTokens(user.Tokens);*/ db.SaveChanges(); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); } } catch (Exception e) { return(Content("I had an exception!")); } } }