Exemplo 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());
            }
        }
Exemplo n.º 2
0
        public static Charge StripePaymentsForm(Models.PersonalInformation PersonalInformation, string Price)
        {
            var customerService = new Stripe.CustomerService();
            var chargeService   = new Stripe.ChargeService();
            var priceConverted  = decimal.Parse(Price) * 100;
            var customer        = customerService.Create(new Stripe.CustomerCreateOptions
            {
                Email  = PersonalInformation.Email,
                Source = PersonalInformation.stripeToken,
            });

            return(chargeService.Create(new Stripe.ChargeCreateOptions
            {
                Amount = (long)priceConverted,
                Description = "Spartan Boosting",
                Currency = "EUR",
                Customer = customer.Id
            }));
        }
        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());
            }
        }