public ActionResult Receive(int invoice_id, string secret) { if (invoice_id < 1) { return new EmptyResult(); } using (var db = new DataAccess.PeymentContext()) { var entity = db.Orders.Find(invoice_id); if (entity.Secret != secret) { return new EmptyResult(); } entity.IsPayed = true; entity.Address = Request["address"]; entity.TransactionHash = Request["transaction_hash"]; entity.confirmations = Request["confirmations"]; entity.Value = Request["value"]; entity.PayOn = DateTime.Now; try { db.SaveChanges(); return Content("*ok*"); } catch { } } return new EmptyResult(); }
public ActionResult Payment(int id) { var model = new Models.Peyment(); using (var db = new DataAccess.PeymentContext()) { var entity = db.Orders.Find(id); if (entity == null) { return RedirectToAction("Index", "Home", null); } model.Total = entity.Total; model.OrderId = entity.Id; callback_url = string.Format(callback_url, model.OrderId, entity.Secret); callback_url = Uri.EscapeDataString(callback_url); BaseUrl = string.Format(BaseUrl, xpub, callback_url, key); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(BaseUrl); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); var value = new StreamReader(resStream).ReadToEnd(); Models.Response res = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Models.Response>(value); model.Adderess = res.address; } return View(model); }
public ActionResult Receive(int invoice_id, string secret) { if (invoice_id < 1) { return(new EmptyResult()); } using (var db = new DataAccess.PeymentContext()) { var entity = db.Orders.Find(invoice_id); if (entity.Secret != secret) { return(new EmptyResult()); } entity.IsPayed = true; entity.Address = Request["address"]; entity.TransactionHash = Request["transaction_hash"]; entity.confirmations = Request["confirmations"]; entity.Value = Request["value"]; entity.PayOn = DateTime.Now; try { db.SaveChanges(); return(Content("*ok*")); } catch { } } return(new EmptyResult()); }
public ActionResult Payment(int id) { var model = new Models.Peyment(); using (var db = new DataAccess.PeymentContext()) { var entity = db.Orders.Find(id); if (entity == null) { return(RedirectToAction("Index", "Home", null)); } model.Total = entity.Total; model.OrderId = entity.Id; callback_url = string.Format(callback_url, model.OrderId, entity.Secret); callback_url = Uri.EscapeDataString(callback_url); BaseUrl = string.Format(BaseUrl, xpub, callback_url, key); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(BaseUrl); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); var value = new StreamReader(resStream).ReadToEnd(); Models.Response res = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <Models.Response>(value); model.Adderess = res.address; } return(View(model)); }
public ActionResult refresh(int id) { using (var db = new DataAccess.PeymentContext()) { var entity = db.Orders.Find(id); callback_url = string.Format(callback_url, id, entity.Secret); callback_url = Uri.EscapeDataString(callback_url); BaseUrl = string.Format(BaseUrl, xpub, callback_url, key); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(BaseUrl); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); var value = new StreamReader(resStream).ReadToEnd(); Models.Response res = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Models.Response>(value); return Json(new { address = res.address }, JsonRequestBehavior.AllowGet); } }
public ActionResult refresh(int id) { using (var db = new DataAccess.PeymentContext()) { var entity = db.Orders.Find(id); callback_url = string.Format(callback_url, id, entity.Secret); callback_url = Uri.EscapeDataString(callback_url); BaseUrl = string.Format(BaseUrl, xpub, callback_url, key); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(BaseUrl); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); var value = new StreamReader(resStream).ReadToEnd(); Models.Response res = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <Models.Response>(value); return(Json(new { address = res.address }, JsonRequestBehavior.AllowGet)); } }
// // GET: /Orders/ public ActionResult Index() { var models = new List <OrderItem>(); using (var db = new DataAccess.PeymentContext()) { foreach (var item in db.Orders) { var model = new OrderItem(); model.Address = item.Address; model.confirmations = item.confirmations; model.CreatOn = item.CreatOn; model.Email = item.Email; model.Id = item.Id; model.IsPayed = item.IsPayed; model.PayOn = item.PayOn; model.Total = item.Total; model.Value = item.Value; models.Add(model); } } return(View(models)); }
// // GET: /Orders/ public ActionResult Index() { var models = new List<OrderItem>(); using (var db = new DataAccess.PeymentContext()) { foreach (var item in db.Orders) { var model = new OrderItem(); model.Address = item.Address; model.confirmations = item.confirmations; model.CreatOn = item.CreatOn; model.Email = item.Email; model.Id = item.Id; model.IsPayed = item.IsPayed; model.PayOn = item.PayOn; model.Total = item.Total; model.Value = item.Value; models.Add(model); } } return View(models); }
public ActionResult Index(Models.Order model) { if (model.Total <= 0) { ModelState.AddModelError("Total", "Upper 0 plz"); } if (ModelState.IsValid) { var response = Request["g-recaptcha-response"]; //secret that was generated in key value pair const string secret = "{reCAPTCHA secret key}"; var client = new WebClient(); var reply = client.DownloadString( string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, response)); var captchaResponse = JsonConvert.DeserializeObject <CaptchaResponse>(reply); //when response is false check for the error message if (!captchaResponse.Success) { if (captchaResponse.ErrorCodes.Count <= 0) { return(View()); } var error = captchaResponse.ErrorCodes[0].ToLower(); switch (error) { case ("missing-input-secret"): ViewBag.Message = "The secret parameter is missing."; break; case ("invalid-input-secret"): ViewBag.Message = "The secret parameter is invalid or malformed."; break; case ("missing-input-response"): ViewBag.Message = "The response parameter is missing."; break; case ("invalid-input-response"): ViewBag.Message = "The response parameter is invalid or malformed."; break; default: ViewBag.Message = "Error occured. Please try again"; break; } return(View(model)); } using (var db = new DataAccess.PeymentContext()) { var entity = new DataAccess.Entities.Order(); entity.Email = model.Email; entity.IsPayed = false; entity.Name = model.Name; entity.Total = model.Total; entity.UserName = model.UserName; entity.CreatOn = DateTime.Now; entity.Secret = Guid.NewGuid().ToString(); try { db.Orders.Add(entity); db.SaveChanges(); return(RedirectToAction("Payment", "Checkout", new { id = entity.Id })); } catch (Exception) { return(View(model)); } } } return(View(model)); }
public ActionResult Index(Models.Order model) { if (model.Total <= 0) { ModelState.AddModelError("Total", "Upper 0 plz"); } if (ModelState.IsValid) { var response = Request["g-recaptcha-response"]; //secret that was generated in key value pair const string secret = "{reCAPTCHA secret key}"; var client = new WebClient(); var reply = client.DownloadString( string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, response)); var captchaResponse = JsonConvert.DeserializeObject<CaptchaResponse>(reply); //when response is false check for the error message if (!captchaResponse.Success) { if (captchaResponse.ErrorCodes.Count <= 0) return View(); var error = captchaResponse.ErrorCodes[0].ToLower(); switch (error) { case ("missing-input-secret"): ViewBag.Message = "The secret parameter is missing."; break; case ("invalid-input-secret"): ViewBag.Message = "The secret parameter is invalid or malformed."; break; case ("missing-input-response"): ViewBag.Message = "The response parameter is missing."; break; case ("invalid-input-response"): ViewBag.Message = "The response parameter is invalid or malformed."; break; default: ViewBag.Message = "Error occured. Please try again"; break; } return View(model); } using (var db = new DataAccess.PeymentContext()) { var entity = new DataAccess.Entities.Order(); entity.Email = model.Email; entity.IsPayed = false; entity.Name = model.Name; entity.Total = model.Total; entity.UserName = model.UserName; entity.CreatOn = DateTime.Now; entity.Secret = Guid.NewGuid().ToString(); try { db.Orders.Add(entity); db.SaveChanges(); return RedirectToAction("Payment", "Checkout", new { id = entity.Id }); } catch (Exception) { return View(model); } } } return View(model); }