Пример #1
0
        private async Task OrderNowAsync(IDialogContext context)
        {
            var authUser = await identityService.GetAuthUserAsync(context);

            var basket = orderingService.MapOrderToBasket(order);
            await basketService.Checkout(basket, authUser.AccessToken);
        }
Пример #2
0
        public async Task <IActionResult> Checkout(Registration registration)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var viewModel = new RegistrationViewModel(registration);
                    await basketService.Checkout(GetUserId(), viewModel);

                    return(RedirectToAction("Checkout"));
                }
                return(RedirectToAction("Index", "Registration"));
            }
            catch (BrokenCircuitException e)
            {
                logger.LogError(e, e.Message);
                HandleBrokenCircuitException(basketService);
            }
            catch (Exception e)
            {
                logger.LogError(e, e.Message);
                HandleException();
            }
            return(View());
        }
Пример #3
0
        public IHttpActionResult Checkout([FromBody] CheckoutRequest request)
        {
            if (Request.Headers.Authorization == null)
            {
                return(Unauthorized());
            }

            if (request.DeliveryType == null)
            {
                return(BadRequest());
            }

            var deliveryType = DeliveryTypeHelper.From(request.DeliveryType);

            if (deliveryType == DeliveryType.Unknown)
            {
                return(BadRequest());
            }

            var basketCheckoutResponse = _basketService.Checkout(deliveryType, request.Voucher, Encoding.UTF8.GetString(Convert.FromBase64String(Request.Headers.Authorization.Parameter)), OrderStatus.Complete);

            if (!basketCheckoutResponse.HasError)
            {
                return(Ok());
            }

            if (basketCheckoutResponse.Error.Code == ErrorCodes.UserNotLoggedIn)
            {
                return(Ok(basketCheckoutResponse));
            }

            return(Ok());
        }
Пример #4
0
        public async Task <IActionResult> Checkout()
        {
            var basket = await GetBasketViewModelAsync();

            await _basketService.Checkout(basket.Id);

            return(View("Checkout"));
        }
 public IActionResult Checkout(CheckoutRequest model)
 {
     if (model.Basket.Count > 1)
     {
         _log.LogError("Unexpected error - too many items in basket.");
         return(BadRequest("Unexpected error occured."));
     }
     _log.LogInformation("Checking out basket.");
     return(Ok(_basketService.Checkout()));
 }
        public async Task <IActionResult> Checkout([FromBody] BasketCheckout basketCheckout)
        {
            var checkoutSuccessfull = await _basketService.Checkout(basketCheckout);

            if (checkoutSuccessfull)
            {
                return(Ok());
            }

            return(BadRequest());
        }
Пример #7
0
        public async Task <IActionResult> Checkout([FromQuery] string basketId, [FromBody] MoneyDataContract total)
        {
            if (!await basketService.Exists(basketId))
            {
                return(NotFound());
            }

            await basketService.Checkout(basketId, total.Units, total.CurrencyCode);

            return(NoContent());
        }
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Checkout(BasketCheckoutViewModel basketCheckoutViewModel)
        {
            try
            {
                var basketId = Request.Cookies.GetCurrentBasketId(_settings);
                if (ModelState.IsValid)
                {
                    var basketForCheckout = new BasketForCheckout
                    {
                        FirstName      = basketCheckoutViewModel.FirstName,
                        LastName       = basketCheckoutViewModel.LastName,
                        Email          = basketCheckoutViewModel.Email,
                        Address        = basketCheckoutViewModel.Address,
                        Address2       = basketCheckoutViewModel.Address2,
                        City           = basketCheckoutViewModel.City,
                        State          = basketCheckoutViewModel.State,
                        ZipCode        = basketCheckoutViewModel.ZipCode,
                        Country        = basketCheckoutViewModel.Country,
                        CardNumber     = basketCheckoutViewModel.CardNumber,
                        CardName       = basketCheckoutViewModel.CardName,
                        CardExpiration = basketCheckoutViewModel.CardExpiration,
                        CvvCode        = basketCheckoutViewModel.CvvCode,
                        BasketId       = basketId,
                        UserId         = _settings.UserId
                                         //UserId =
                    };

                    await _basketService.Checkout(basketId, basketForCheckout);

                    // clear the basket Id, as it's been removed from the cache on checkout
                    Response.Cookies.Delete(_settings.BasketIdCookieName);

                    return(RedirectToAction("CheckoutComplete"));
                }

                return(View(basketCheckoutViewModel));
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = e.Message;
                return(View(basketCheckoutViewModel));
            }
        }
Пример #9
0
        public async Task <IActionResult> Checkout(Order model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user   = _appUserParser.Parse(HttpContext.User);
                    var basket = _orderSvc.MapOrderToBasket(model);

                    await _basketSvc.Checkout(basket);

                    //Redirect to historic list.
                    return(RedirectToAction("Index"));
                }
            }
            catch (BrokenCircuitException)
            {
                ModelState.AddModelError("Error", "It was not possible to create a new order, please try later on. (Business Msg Due to Circuit-Breaker)");
            }
            return(View(model));
        }
Пример #10
0
        public async Task <IActionResult> Checkout(Order model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user   = _appUserParser.Parse(HttpContext.User);
                    var basket = _orderSvc.MapOrderToBasket(model);
                    await _basketSvc.Checkout(basket);

                    //Redirect to historic list.
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", $"It was not possible to create a new order, please try later on ({ex.GetType().Name} - {ex.Message})");
            }

            return(View("Create", model));
        }
Пример #11
0
        public ActionResult Checkout(DeliveryType delivery, string voucher)
        {
            if (Session["UserId"] == null)
            {
                return(Redirect("/Basket"));
            }

            var basketCheckoutResponse =
                _basketService.Checkout(delivery, voucher, Session["UserId"]?.ToString(), OrderStatus.Complete);

            if (!basketCheckoutResponse.HasError)
            {
                return(Redirect("/Basket/Summary"));
            }

            if (basketCheckoutResponse.Error.Code == ErrorCodes.UserNotLoggedIn)
            {
                return(Redirect("/Login"));
            }

            return(Redirect("/Basket"));
        }