Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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());
            }
        }