Exemplo n.º 1
0
        public ActionResult OrderSummary(CheckoutModel model, CreditCardModel cardModel)
        {
            ModelState.Clear();
            this.ViewBag.DisplayTax = DomainService.GetSettingsValueAsBool(SettingsKey.useTax, this.DomainID);

            bool isDirect = DomainService.GetSettingsValue(SettingsKey.sagePayMethod, this.DomainID).ToLowerInvariant()
                .Equals(SagePayPaymentType.Direct.ToString().ToLowerInvariant());
            this.ViewBag.PaymentTypes = ECommerceService.GetAllPaymentDomainAsSelectList(this.DomainID, true);
            this.ViewBag.SagePay = PaymentType.SagePay.ToString().ToLowerInvariant();
            this.ViewBag.IsDirect = isDirect;
            if (isDirect)
                this.ViewBag.CardTypes = Enum.GetValues(typeof(CardType)).Cast<CardType>()
                    .Select(c => new SelectListItem { Text = c.ToString(), Value = ((int)c).ToString() }).ToList();

            tbl_Basket basket = FindBasket();
            if (basket == null)
            {
                ModelState.AddModelError("", "There is no basket assigned to you.");
                return View();
            }

            model.CopyValuesFromBasket(basket);

            if (!model.TermsAndConditionsConfirmed)
            {
                ModelState.AddModelError("TermsAndConditionsConfirmed", "Please agree to our terms and conditions.");
                return View(model);
            }

            var selectedPaymentType = ECommerceService.GetPaymentDomainByID(model.PaymentDomainID);
            if (selectedPaymentType == null)
            {
                ModelState.AddModelError("PaymentDomainID", "Please select payment type.");
                return View(model);
            }

            if (selectedPaymentType.tbl_PaymentType.PT_Code == PaymentType.SagePay.ToString() && isDirect &&
                (cardModel == null || !TryValidateModel(cardModel)))
            {
                ModelState.AddModelError("", "There was a problem saving card details.");
                return View(model);
            }
            if (!ECommerceService.IsEnoughOnStock(basket.tbl_BasketContent))
            {
                ModelState.AddModelError("", "Quantity of order oversize current stock ammount");
                return View(model);
            }

            if (TryValidateModel(model))
            {
                //int customerID = Request.IsAuthenticated && !AdminUser.IsAdmn ? AdminUser.UserID : 0;
                tbl_Orders order = ECommerceService.SaveOrder(0, model.PaymentDomainID, (int?)null, basket.BasketID);
                if (order == null)
                {
                    ModelState.AddModelError("", "There was a problem saving new order.");
                    return View(model);
                }

                if (!String.IsNullOrEmpty(model.DonationAmount))
                {
                    decimal donationAmount = 0;
                    bool parsed = Decimal.TryParse(model.DonationAmount.ChangeDecimalSeparator(), out donationAmount);
                    if (parsed && donationAmount > 0)
                    {
                        if (model.BillingAddressTheSame && model.IsDeliverable)
                            ECommerceService.SaveOrderForDonation(0, this.DomainID, model.DeliveryAddress1, model.DeliveryAddress2,
                                model.DeliveryAddress3, model.DeliveryCity, model.DeliveryCountryID, model.DeliveryFirstName,
                                model.DeliveryPhone, model.DeliveryPostcode, model.DeliveryState, model.DeliverySurname, model.Email,
                                order.CustomerID, donationAmount, model.GiftAid, selectedPaymentType.PaymentDomainID,
                                DonationType.Single, order.OrderID);
                        else
                            ECommerceService.SaveOrderForDonation(0, this.DomainID, model.BillingAddress1, model.BillingAddress2,
                                model.BillingAddress3, model.BillingCity, model.BillingCountryID.Value, model.BillingFirstName,
                                model.BillingPhone, model.BillingPostcode, model.BillingState, model.BillingSurname, model.Email,
                                order.CustomerID, donationAmount, model.GiftAid, selectedPaymentType.PaymentDomainID,
                                DonationType.Single, order.OrderID);
                    }
                }

                PaymentType key = (PaymentType)Enum.Parse(typeof(PaymentType), selectedPaymentType.tbl_PaymentType.PT_Code);
                switch (key)
                {
                    case PaymentType.SagePay:
                        if (isDirect)
                            SessionManager.CreditCard = cardModel;

                        return RedirectToRoute("SagePay", new { action = "Payment", orderID = order.OrderID });

                    case PaymentType.PayPal:
                        return RedirectToRoute("PayPal", new { action = "Payment", orderID = order.OrderID });

                    case PaymentType.SecureTrading:
                        return RedirectToRoute("SecureTrading", new { action = "Payment", orderID = order.OrderID });

                    case PaymentType.Stripe:
                        return RedirectToRoute("Stripe", new { action = "Payment", orderID = order.OrderID });
                    default:
                        return View(model);
                }
            }
            ModelState.AddModelError("", "Some of the values are incorrect.");
            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult OrderSummaryWithIFrame(string md, string pareq, string vendorTxCode, string ACSURL)
        {
            this.ViewBag.MD = md;
            this.ViewBag.PaReq = pareq;
            this.ViewBag.VendorTxCode = vendorTxCode;
            this.ViewBag.ACSURL = ACSURL;
            this.ViewBag.SagePay3DSecure = true;

            bool isDirect = DomainService.GetSettingsValue(SettingsKey.sagePayMethod, this.DomainID).ToLowerInvariant()
                .Equals(SagePayPaymentType.Direct.ToString().ToLowerInvariant());
            this.ViewBag.DisplayTax = DomainService.GetSettingsValueAsBool(SettingsKey.useTax, this.DomainID);
            this.ViewBag.PaymentTypes = ECommerceService.GetAllPaymentDomainAsSelectList(this.DomainID, true);
            this.ViewBag.SagePay = ECommerceService.GetPaymentDomainIDByCode(this.DomainID, PaymentType.SagePay);
            this.ViewBag.IsDirect = isDirect;
            if (isDirect)
                this.ViewBag.CardTypes = Enum.GetValues(typeof(CardType)).Cast<CardType>()
                    .Select(c => new SelectListItem { Text = c.ToString(), Value = ((int)c).ToString() }).ToList();

            tbl_Orders order = null;
            if (!String.IsNullOrWhiteSpace(vendorTxCode))
                order = ECommerceService.GetOrderByVendorCode(vendorTxCode, DomainID);
            if (order == null)
                return View("OrderSummary", null);

            CheckoutModel model = new CheckoutModel(FindBasket()) { IsCheckoutStep = false };
            var dCountry = ECommerceService.GetCountry(model.DeliveryCountryID);
            model.DeliveryCountry = (dCountry != null) ? dCountry.C_Country : model.DeliveryCountry;
            var bCountry = ECommerceService.GetCountry(model.BillingCountryID.GetValueOrDefault(0));
            model.BillingCountry = (bCountry != null) ? bCountry.C_Country : model.BillingCountry;
            model.DonationAmount = order.DependentOrders.Select(o => o.TotalAmountToPay).Sum().ToString();
            model.PaymentDomainID = order.O_PaymentDomainID.GetValueOrDefault(0);
            model.TermsAndConditionsConfirmed = true;
            model.GiftAid = order.DependentOrders.Count > 0 ? order.DependentOrders.First().GiftAid.GetValueOrDefault(false) : false;

            return View("OrderSummary", model);
        }
Exemplo n.º 3
0
        public ActionResult Checkout(CheckoutModel model)
        {
            tbl_Basket basket = FindBasket();

            if (ModelState.IsValid)
            {
                int customerID = Request.IsAuthenticated && !AdminUser.IsAdmn ? AdminUser.UserID : 0;
                if (model.BillingAddressTheSame)
                {
                    basket = ECommerceService.UpdateBasket(model.DeliveryAddress1, model.DeliveryAddress2, model.DeliveryAddress3, model.DeliveryCity, model.DeliveryCountryID,
                        model.DeliveryTitle, model.DeliveryFirstName, model.DeliveryPhone, model.DeliveryPostcode, model.DeliveryState, model.DeliverySurname,
                        model.DeliveryAddress1, model.DeliveryAddress2, model.DeliveryAddress3, model.DeliveryCity, model.DeliveryCountry, model.DeliveryCountryID,
                        model.DeliveryTitle, model.DeliveryFirstName, model.DeliveryPhone, model.DeliveryPostcode, model.DeliveryState, model.DeliverySurname,
                        model.Instructions, model.Email, customerID, model.BillingAddressTheSame, model.Subscription, model.Permission, model.BasketID);
                }
                else
                {
                    basket = ECommerceService.UpdateBasket(model.BillingAddress1, model.BillingAddress2, model.BillingAddress3, model.BillingCity, model.BillingCountryID.GetValueOrDefault(0),
                        model.BillingTitle, model.BillingFirstName, model.BillingPhone, model.BillingPostcode, model.BillingState, model.BillingSurname,
                        model.DeliveryAddress1, model.DeliveryAddress2, model.DeliveryAddress3, model.DeliveryCity, model.DeliveryCountry, model.DeliveryCountryID,
                        model.DeliveryTitle, model.DeliveryFirstName, model.DeliveryPhone, model.DeliveryPostcode, model.DeliveryState, model.DeliverySurname,
                        model.Instructions, model.Email, customerID, model.BillingAddressTheSame, model.Subscription, model.Permission, model.BasketID);
                }
                return RedirectToRoute("orderSummary");
            }

            if (basket == null)
                return RedirectToAction("Content");

            this.ViewBag.Countries = ECommerceService.GetAllCountriesAsSelectList(DomainID);
            var country = ECommerceService.GetCountry(model.DeliveryCountryID);
            this.ViewBag.SelectedCountry = country != null ? country.C_Country : String.Empty;
            return View(model);
        }
Exemplo n.º 4
0
        public ActionResult OrderSummary()
        {
            // TODO: view refactor using knockout and ajax without reloading page everytime, get discount info using ajax

            this.ViewBag.SagePay3DSecure = false;

            bool isDirect = DomainService.GetSettingsValue(SettingsKey.sagePayMethod, this.DomainID).ToLowerInvariant()
                .Equals(SagePayPaymentType.Direct.ToString().ToLowerInvariant());
            this.ViewBag.DisplayTax = DomainService.GetSettingsValueAsBool(SettingsKey.useTax, this.DomainID);
            this.ViewBag.PaymentTypes = ECommerceService.GetAllPaymentDomainAsSelectList(this.DomainID, true);
            this.ViewBag.SagePay = ECommerceService.GetPaymentDomainIDByCode(this.DomainID, PaymentType.SagePay);
            this.ViewBag.IsDirect = isDirect;
            if (isDirect)
                this.ViewBag.CardTypes = Enum.GetValues(typeof(CardType)).Cast<CardType>()
                    .Select(c => new SelectListItem { Text = c.ToString(), Value = ((int)c).ToString() }).ToList();

            CheckoutModel model = new CheckoutModel(FindBasket()) { IsCheckoutStep = false };

            var dCountry = ECommerceService.GetCountry(model.DeliveryCountryID);
            model.DeliveryCountry = (dCountry != null) ? dCountry.C_Country : model.DeliveryCountry;
            var bCountry = ECommerceService.GetCountry(model.BillingCountryID.GetValueOrDefault(0));
            model.BillingCountry = (bCountry != null) ? bCountry.C_Country : model.BillingCountry;

            return View(model);
        }
Exemplo n.º 5
0
        public ActionResult Checkout()
        {
            var basket = FindBasket();
            if (basket == null)
                return RedirectToAction("Content");

            var model = new CheckoutModel(basket);
            var country = ECommerceService.GetCountry(model.DeliveryCountryID);
            this.ViewBag.SelectedCountry = (country != null) ? country.C_Country : String.Empty;
            this.ViewBag.Countries = ECommerceService.GetAllCountriesAsSelectList(DomainID);

            return View(model);
        }