public ActionResult OrderDownload(int?id) { Service serv = db.Services.Find(id); if (serv != null) { OrderDownloadViewModel odvm = new OrderDownloadViewModel() { ServiceId = serv.Id, FirstName = serv.FirstName, LastName = serv.LastName }; return(View(odvm)); } return(View("NotFound")); }
public ActionResult StripeResult(string stripeToken, int?serviceId, string firstName, string lastName, string stripeEmail) { OrderDownloadViewModel odvm = new OrderDownloadViewModel() { FirstName = firstName, LastName = lastName }; if (serviceId != null) { odvm.ServiceId = (int)serviceId; var charge = new StripeChargeCreateOptions { Amount = 999, Currency = "usd", Description = "Midwest Streams Funeral Download", SourceTokenOrExistingSourceId = stripeToken }; var chargeService = new StripeChargeService(); var stripeCharge = chargeService.Create(charge); if (stripeCharge.Status == "succeeded") { Email.sendAdminMessage("An order was succefully placed! Email: " + stripeEmail + " First Name: " + firstName + " Last Name: " + lastName + " ServiceId: " + serviceId, "An order was sucesfully placed!"); string downloadCode = ConfigurationManager.AppSettings["portalPath"] + Url.Action("Download", "Services", new { id = serviceId, bought = true, stripeId = stripeCharge.Id }); string emailTemplateHtml = EmailHelper.GetOrderConfirmationEmailHTML(firstName, lastName, downloadCode); Email.sendHtmlMail("*****@*****.**", stripeEmail, "Order Confirmation: Video Download", emailTemplateHtml); odvm.StripeId = stripeCharge.Id; return(View("OrderConfirmed", odvm)); } else { odvm.Errors = stripeCharge.FailureMessage; Email.sendAdminMessage("An ordered was placed and stripe failed. Error Message:" + stripeCharge.FailureMessage + " Email: " + stripeEmail + " First Name: " + firstName + " Last Name: " + lastName + " ServiceId: " + serviceId, "Download Order Failed:"); return(View("OrderDownload", odvm)); } } odvm.Errors = "Unable to find service Id"; return(View("OrderDownload", odvm)); }