public IActionResult CreateCoaching(Models.CoachingModel CoachingModel, Models.PersonalInformation PersonalInformation) { var Pricing = CoachingModel.CoachingPrices[int.Parse(CoachingModel.CoachingPackage) - 1].Price; if (PersonalInformation.PaymentMethod == "Paypal") { var paypalResult = PayPalV2.createOrder(Pricing); TempData["purchaseFormlData"] = JsonConvert.SerializeObject(Models.CoachingModel.CoachingModelToPurchaseForm(CoachingModel, Pricing, PersonalInformation, paypalResult.ApprovalURL, paypalResult.CaptureURL)); return(Redirect(paypalResult.ApprovalURL)); } else { try { var result = StripePayments.StripePaymentsForm(PersonalInformation, Pricing); if (result.Status == "succeeded" && result.Paid) { TempData["purchaseFormlData"] = JsonConvert.SerializeObject(Models.CoachingModel.CoachingModelToPurchaseForm(CoachingModel, Pricing, PersonalInformation)); return(RedirectToAction("PurchaseQuote", "Quote")); } } catch (Exception e) { TempData["StripePayment"] = "Stripe Payment has failed, please check your details and try again"; return(RedirectToAction("Coaching", "Coaching")); } //something went wrong return(View()); } }
public async Task <IActionResult> CreateInvoice(PurchaseForm purchaseForm) { purchaseForm.PersonalInformation.Email = User.Identity.IsAuthenticated ? User.Identity.Name : purchaseForm.PersonalInformation.Email; purchaseForm = LolModelExtenstion.AssignModel(purchaseForm, TempData["OrderModel"].ToString()); //recheck price because they could edit the request PricingResponse Pricing = ValidatePricing(purchaseForm); purchaseForm.Pricing = Pricing.Price.ToString(); purchaseForm.Discount = Pricing.DiscountModel; if (User.Identity.IsAuthenticated) { var user = await _userManager.FindByEmailAsync(User.Identity.Name); purchaseForm.ClientAssignedTo = user; } //validation string validationResult = ValidatePaymentInformation(purchaseForm); if (!string.IsNullOrEmpty(validationResult)) { TempData.Put("purchaseForm", purchaseForm); TempData["validationResult"] = validationResult; return(RedirectToAction("Details", "Invoice", new { data = EncryptionHelper.Encrypt(purchaseForm.PurchaseType.ToString()), dest = EncryptionHelper.Encrypt("LolBoosting") })); } if (purchaseForm.PersonalInformation.PaymentMethod == "Paypal") { var paypalResult = PayPalV2.createOrder(Pricing.Price.ToString()); purchaseForm.PayPalApproval = paypalResult.ApprovalURL; purchaseForm.PayPalCapture = paypalResult.CaptureURL; TempData.Put("purchaseForm", purchaseForm); return(Redirect(paypalResult.ApprovalURL)); } else { try { var result = StripePayments.StripePaymentsForm(purchaseForm.PersonalInformation.Email, purchaseForm.PersonalInformation.stripeToken, Pricing.Price.ToString()); if (result.Status == "succeeded" && result.Paid) { TempData.Put("purchaseForm", purchaseForm); return(RedirectToAction("InvoiceComplete", "Invoice")); } } catch (Exception e) { TempData["StripePayment"] = "Stripe Payment has failed, please check your details and try again"; return(RedirectToAction("soloboosting", "lolboosting")); } //something went wrong return(View()); } }
public IActionResult CreateLolOrder(PurchaseForm purchaseForm) { //recheck price because they could edit the request PricingResponse Pricing = JsonConvert.DeserializeObject <PricingResponse>(JsonConvert.SerializeObject(PricingController.SoloPricing(purchaseForm).Value)); purchaseForm.Pricing = Pricing.Price.ToString(); purchaseForm.Discount = Pricing.DiscountModel; if (purchaseForm.PersonalInformation.PaymentMethod == "Paypal") { var paypalResult = PayPalV2.createOrder(Pricing.Price.ToString()); purchaseForm.PayPalApproval = paypalResult.ApprovalURL; purchaseForm.PayPalCapture = paypalResult.CaptureURL; TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(Redirect(paypalResult.ApprovalURL)); } else { try { string email = string.Empty; if (User.Identity.IsAuthenticated) { email = User.Identity.Name; } else { email = purchaseForm.PersonalInformation.Email; } var result = StripePayments.StripePaymentsForm(email, purchaseForm.PersonalInformation.stripeToken, Pricing.Price.ToString()); if (result.Status == "succeeded" && result.Paid) { TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(RedirectToAction("PurchaseQuote", "Quote")); } } catch (Exception e) { TempData["StripePayment"] = "Stripe Payment has failed, please check your details and try again"; return(RedirectToAction("soloboosting", "lolboosting")); } //something went wrong return(View()); } }
public IActionResult CreateDuo(Models.BoostingModel BoostingModel, Models.PersonalInformation PersonalInformation) { PurchaseForm purchaseForm = new PurchaseForm { BoostingModel = BoostingModel, PersonalInformation = PersonalInformation }; PricingResponse Pricing = JsonConvert.DeserializeObject <PricingResponse>(JsonConvert.SerializeObject(PricingController.DuoPricing(purchaseForm).Value)); purchaseForm.Pricing = Pricing.Price; purchaseForm.Discount = Pricing.DiscountModel; purchaseForm.PurchaseType = PurchaseType.DuoBoosting; if (PersonalInformation.PaymentMethod == "Paypal") { var paypalResult = PayPalV2.createOrder(Pricing.Price.ToString()); purchaseForm.PayPalApproval = paypalResult.ApprovalURL; purchaseForm.PayPalCapture = paypalResult.CaptureURL; TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(Redirect(paypalResult.ApprovalURL)); } else { try { var result = StripePayments.StripePaymentsForm(PersonalInformation, Pricing.Price.ToString()); if (result.Status == "succeeded" && result.Paid) { TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(RedirectToAction("PurchaseQuote", "Quote")); } } catch (Exception e) { TempData["StripePayment"] = "Stripe Payment has failed, please check your details and try again"; return(RedirectToAction("duoboosting", "lolboosting")); } //something went wrong return(View()); } }
public IActionResult InvoiceComplete() { try { PurchaseForm purchaseForm = JsonConvert.DeserializeObject <PurchaseForm>(TempData["purchaseForm"].ToString()); EmailSender email = new EmailSender(_smtpSettings); if (purchaseForm.PersonalInformation.PaymentMethod == "Paypal") { PayPalV2.captureOrder(purchaseForm.PayPalCapture); } purchaseForm = PurchaseOrderRepository.Add(purchaseForm); if (purchaseForm.Discount != null && purchaseForm.Discount.SingleUse) { DiscountModelRepository.SetNotInUse(purchaseForm.Discount); } var bot = new DiscordBot(); bot.RunAsync(purchaseForm).GetAwaiter().GetResult(); string emailbody = string.Empty; switch (purchaseForm.PurchaseType) { case PurchaseTypeEnum.PurchaseType.SoloBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderSoloEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.DuoBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderDuoEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.WinBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderWinBoostEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.PlacementMatches: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderPlacementMatchesEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.TFTPlacement: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderTFTPlacementMatchesEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.TFTBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderTFTSoloBoostEmail", purchaseForm).Result; break; default: emailbody = JsonConvert.SerializeObject(purchaseForm); break; } email.SendEmailAsync(purchaseForm.PersonalInformation.Email, $"Purchase Order", emailbody); if (User.Identity.IsAuthenticated) { return(RedirectToAction("OrderDetails", "ClientArea", new { hash = EncryptionHelper.Encrypt(purchaseForm.Id) })); } else { TempData.Put("completePurchaseForm", purchaseForm); return(RedirectToAction("InvoiceDetails", "Invoice")); } } catch (Exception e) { } return(View()); }
public IActionResult PurchaseQuote() { try { PurchaseForm purchaseForm = JsonConvert.DeserializeObject <PurchaseForm>(TempData["purchaseFormlData"].ToString()); EmailSender email = new EmailSender(_smtpSettings); if (purchaseForm.PersonalInformation.PaymentMethod == "Paypal") { PayPalV2.captureOrder(purchaseForm.PayPalCapture); } PurchaseOrderRepository.Add(purchaseForm); if (purchaseForm.Discount != null && purchaseForm.Discount.SingleUse) { DiscountModelRepository.SetNotInUse(purchaseForm.Discount); } var bot = new DiscordBot(); bot.RunAsync(purchaseForm).GetAwaiter().GetResult(); string emailbody = string.Empty; switch (purchaseForm.PurchaseType) { case PurchaseTypeEnum.PurchaseType.SoloBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderSoloEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.DuoBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderDuoEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.WinBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderWinBoostEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.PlacementMatches: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderPlacementMatchesEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.TFTPlacement: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderTFTPlacementMatchesEmail", purchaseForm).Result; break; case PurchaseTypeEnum.PurchaseType.TFTBoosting: emailbody = RenderPartialViewToString("EmailTemplates/PurchaseOrderTFTSoloBoostEmail", purchaseForm).Result; break; default: emailbody = JsonConvert.SerializeObject(purchaseForm); break; } email.SendEmailAsync(purchaseForm.PersonalInformation.Email, $"Purchase Order", emailbody); } catch (Exception e) { } return(View()); }