public void SetUp()
        {
            var parkingDate = new DateTime(2013, 10, 06, 12, 0, 0);
            var parkingReceipt = ParkingReceipt.Create(parkingDate);

            DateTime checkoutTime = parkingDate.AddHours(5).AddMinutes(30);

            var priceCalculator = new PriceCalculator(new List<IParkingPriceRule>
                {
                    new OneHourPriceRule(),
                    new TwoHourPriceRule(),
                    new ThreeOrMoreHoursPriceRule()
                });

            var checkoutService = new CheckoutService(new TestableTimeService(checkoutTime), priceCalculator);
            _invoice = checkoutService.Checkout(parkingReceipt);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CartService" /> class.
        /// </summary>
        /// <param name="cartRepository">The cart repository.</param>
        /// <param name="mapper">The mapper.</param>
        /// <param name="eventDispatcher">The event dispatcher.</param>
        /// <param name="checkoutDomainService">The checkout domain service.</param>
        /// <param name="customerRepository">The customer repository.</param>
        /// <param name="productRepository">The product repository.</param>
        /// <param name="unitOfWork">The unit of work.</param>
        public CartService(ICartRepository cartRepository, IMapper mapper, IEventDispatcher eventDispatcher, CheckoutService checkoutDomainService,
                           ICustomerRepository customerRepository, IProductRepository productRepository, IUnitOfWork unitOfWork)
        {
            _cartRepository        = cartRepository;
            _mapper                = mapper;
            _eventDispatcher       = eventDispatcher;
            _checkoutDomainService = checkoutDomainService;
            _customerRepository    = customerRepository;
            _productRepository     = productRepository;
            _unitOfWork            = unitOfWork;

            MessageType = GetType().Name;
        }
Пример #3
0
        public CheckoutController(IConfiguration configuration)
        {
            var connectionString = configuration.GetConnectionString("ConnectionString");

            this.checkoutService = new CheckoutService(new CustomerRepository(connectionString), new OrderItemsRepository(connectionString));
        }
 public override void UpdateProductDiscount(Product product)
 {
     base.UpdateProductDiscount(product);
     Total.Text = string.Format(CultureInfo.GetCultureInfo("pt-BR"), "{0:C}", CheckoutService.TotalProduct(product));
 }
Пример #5
0
 public CheckoutServiceTests()
 {
     this.checkoutService = new CheckoutService();
 }
Пример #6
0
 public StoreController(IShoppingContext shoppingContext, CheckoutService checkoutService)
 {
     _shoppingContext = shoppingContext;
     _checkoutService = checkoutService;
 }
Пример #7
0
 public CheckoutServiceTests()
 {
     repositoryMock = new Mock <IProductRepository>();
     sut            = new CheckoutService(repositoryMock.Object);
 }
Пример #8
0
        public override Template GetTemplate(IResultResponse response)
        {
            var template = new Template
            {
                TemplateName = Config.TemplateEnum.GeneralError
            };

            try
            {
                if (this.OverrideBlockXDocumentConversion) // JSON
                {
                    if (this.OverrideStopAutoRedirects)
                    {
                        if (response.ResponseHeaders != null)
                        {
                            var location = string.Empty;
                            if (response.ResponseHeaders.TryGetValue("Location", out location) && location.Contains(".paypal."))
                            {
                                var service = new CheckoutService(Core);
                                template = new Template
                                {
                                    TemplateName = Config.TemplateEnum.PayPalRedirect,
                                    Service      = service,
                                    Method       = service.ParsePayPalRedirect
                                };
                            }
                            if (string.IsNullOrWhiteSpace(location))
                            {
                                if (response.RawData.Contains(".paypal."))
                                {
                                    var startIndex = response.RawData.IndexOf("url=");
                                    var endIndex   = response.RawData.IndexOf("><meta http-equiv=\"Robots\"");
                                    location = response.RawData.Substring(startIndex, endIndex - startIndex).Replace("url=", "").Replace("\"", "").Trim();
                                    var service = new CheckoutService(Core);
                                    template = new Template
                                    {
                                        TemplateName = Config.TemplateEnum.PayPalRedirect,
                                        Service      = service,
                                        Method       = service.ParsePayPalRedirect
                                    };
                                }
                            }
                        }
                    }
                }
                else if (response.XDocument != null) // HTML and XML
                {
                    var xDoc = response.XDocument;
                    _ns = xDoc.Root.GetDefaultNamespace();

                    // Regular HTML Pages
                    var title = xDoc.Descendants(_ns + "title")
                                .FirstOrNewXElement()
                                .ElementValue();

                    if (title.IndexOf("****", StringComparison.InvariantCultureIgnoreCase) > -1 ||
                        string.IsNullOrEmpty(title))
                    {
                        if (xDoc.Descendants(_ns + "span")
                            .FirstOrNewXElement()
                            .AttributeValue("class")
                            .Equals("shopping-bag"))
                        {
                            var service = new CartService(Core);
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CartMini,
                                Service      = service,
                                Method       = service.ParseCartMini
                            };
                        }
                        else if (xDoc.Descendants(_ns + "legend")
                                 .FirstOrNewXElement()
                                 .ElementValue()
                                 .IndexOf("Select Shipping Method", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            var service = new CheckoutService(Core);
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutShipping,
                                Service      = service,
                                Method       = service.ParseShippingOptions
                            };
                        }
                        else if (xDoc.ToString().IndexOf("shoebox", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            var service = new HomeService(Core);
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.FindMyPerfectShoe,
                                Service      = service,
                                Method       = service.ParseFindMyPerfectShoe
                            };
                        }
                    }
                    else if (title.IndexOf("My Payless Bag", StringComparison.InvariantCultureIgnoreCase) > -1)
                    {
                        var service = new CartService(Core);
                        template = new Template
                        {
                            TemplateName = Config.TemplateEnum.CartDetail,
                            Service      = service,
                            Method       = service.ParseCart
                        };
                    }
                    else if (title.IndexOf("Account Login", StringComparison.InvariantCultureIgnoreCase) > -1)
                    {
                        var header = ParsingHelper.GetTemplateHeader(xDoc, _ns);

                        if (header.IndexOf("Account Login", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            var service = new AccountService(Core);
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.Login,
                                Service      = service,
                                Method       = service.ParseLogin
                            };
                        }
                        else
                        {
                            var service = new CheckoutService(Core);
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutBegin,
                                Service      = service,
                                Method       = service.ParseCheckoutBegin
                            };
                        }
                    }
                    else if (title.IndexOf("My Order History", StringComparison.InvariantCultureIgnoreCase) > -1)
                    {
                        var service = new AccountService(Core);
                        template = new Template
                        {
                            TemplateName = Config.TemplateEnum.OrderHistory,
                            Service      = service,
                            Method       = service.ParseAccountOrderHistory
                        };
                    }
                    else if (title.IndexOf("Sites-payless-Site", StringComparison.InvariantCultureIgnoreCase) > -1)
                    {
                        var service = new AccountService(Core);
                        template = new Template
                        {
                            TemplateName = Config.TemplateEnum.OrderDetail,
                            Service      = service,
                            Method       = service.ParseAccountOrderDetail
                        };
                    }
                    else if (title.IndexOf("My Account", StringComparison.InvariantCultureIgnoreCase) > -1)
                    {
                        template = new Template
                        {
                            TemplateName = Config.TemplateEnum.AccountDashboard
                        };
                    }
                    else if (title.IndexOf("Checkout", StringComparison.InvariantCultureIgnoreCase) > -1)
                    {
                        var checkoutService = new CheckoutService(Core);
                        var step            = xDoc.Descendants(_ns + "div")
                                              .WhereAttributeContains("class", "step-")
                                              .WhereAttributeContains("class", " active")
                                              .FirstOrNewXElement()
                                              .ElementValue();

                        var breadCrumb = xDoc.Descendants(_ns + "div")
                                         .WhereAttributeEquals("class", "breadcrumb")
                                         .FirstOrNewXElement()
                                         .ElementValue();


                        var csrfToken = ParsingHelper.GetCheckout_CsrfToken(xDoc);
                        if (!string.IsNullOrEmpty(csrfToken))
                        {
                            var strCsrfToken = csrfToken.Split('=').GetValue(1).ToString();
                            if (_session == null)
                            {
                                _session = new PaylessSession(Core);
                            }
                            var checkout = _session.GetCheckout();
                            checkout.CsrfToken = strCsrfToken;
                            _session.SetCheckout(checkout);
                        }

                        if (step.IndexOf("Shipping", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutShipping,
                                Service      = checkoutService,
                                Method       = checkoutService.ParseShipping
                            };
                        }
                        else if (step.IndexOf("Billing", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutBilling,
                                Service      = checkoutService,
                                Method       = checkoutService.ParseBilling
                            };
                        }
                        else if (step.IndexOf("Review Order", StringComparison.InvariantCultureIgnoreCase) > -1 ||
                                 (string.IsNullOrEmpty(step) && title.IndexOf("Confirmation", StringComparison.InvariantCultureIgnoreCase) == -1))
                        {
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutReview,
                                Service      = checkoutService,
                                Method       = checkoutService.ParseReview
                            };
                        }
                        else if (title.IndexOf("Confirmation", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutConfirmation,
                                Service      = checkoutService,
                                Method       = checkoutService.ParseConfirmation
                            };
                        }
                        else if (breadCrumb.IndexOf("Login", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutBegin,
                                Service      = checkoutService,
                                Method       = checkoutService.ParseCheckoutBegin
                            };
                        }
                        else if (breadCrumb.IndexOf("My Account", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            var header = ParsingHelper.GetTemplateHeader(xDoc, _ns);

                            if (header.IndexOf("Account Login", StringComparison.InvariantCultureIgnoreCase) > -1)
                            {
                                var service = new AccountService(Core);
                                template = new Template
                                {
                                    TemplateName = Config.TemplateEnum.Login,
                                    Service      = service,
                                    Method       = service.ParseLogin
                                };
                            }
                            else if (header.IndexOf("ORDER SUMMARY", StringComparison.InvariantCultureIgnoreCase) > -1)
                            {
                                var service = new AccountService(Core);
                                template = new Template
                                {
                                    TemplateName = Config.TemplateEnum.OrderDetail,
                                    Service      = service,
                                    Method       = service.ParseAccountOrderDetail
                                };
                            }
                            else if (breadCrumb.IndexOf("Order History", StringComparison.InvariantCultureIgnoreCase) > -1)
                            {
                                var service = new AccountService(Core);
                                template = new Template
                                {
                                    TemplateName = Config.TemplateEnum.OrderDetail,
                                    Service      = service,
                                    Method       = service.ParseAccountOrderDetail
                                };
                            }
                        }
                    }
                    else
                    {
                        var legend = xDoc.Descendants(_ns + "legend")
                                     .FirstOrNewXElement()
                                     .ElementValue();

                        if (legend.IndexOf("Select Shipping Method", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            var service = new CheckoutService(Core);
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutShipping,
                                Service      = service,
                                Method       = service.ParseShippingOptions
                            };
                        }
                        else if (legend.IndexOf("Order Summary", StringComparison.InvariantCultureIgnoreCase) > -1)
                        {
                            var service = new CheckoutService(Core);
                            template = new Template
                            {
                                TemplateName = Config.TemplateEnum.CheckoutBilling,
                                Service      = service,
                                Method       = service.ParseUpdateSummary
                            };
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Errors.Add(e.Handle("ExtendedComRequest.GetTemplate",
                                    ErrorSeverity.FollowUp,
                                    ErrorType.Parsing));
            }

            return(template);
        }
Пример #9
0
 public CheckoutController(ProyectoContext context)
 {
     _checkoutservice = new CheckoutService(context);
 }
Пример #10
0
 public void StartUp()
 {
     checkoutService = new CheckoutService();
 }
 public CheckoutServiceTest()
 {
     checkoutService = new CheckoutService();
     milk_7          = new Product(7, "Milk", Category.Milk);
     bread_3         = new Product(3, "Bread");
 }
Пример #12
0
        protected void CreateOrderConfirmationEmailTest(object sender, EventArgs e)
        {
            var order = CheckoutService.GetFullOrder("3E397EA0-CB22-46B4-84A0-7AA31CF0F29E");

            CreateOrderConfirmationEmail(order);
        }
Пример #13
0
 public CartController(IHttpContextAccessor httpContext, IShoppingContext shoppingContext, CheckoutService checkoutService)
 {
     _httpContext     = httpContext;
     _shoppingContext = shoppingContext;
     _checkoutService = checkoutService;
 }
Пример #14
0
 public CheckoutController(WebshopDbContext context, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, AddressService addressService, CartService cartService, CheckoutService checkoutService)
 {
     _context         = context;
     _signInManager   = signInManager;
     _userManager     = userManager;
     _addressService  = addressService;
     _cartService     = cartService;
     _checkoutService = checkoutService;
 }
Пример #15
0
 public SuperTests()
 {
     _mockHttpContext     = new Mock <IHttpContextAccessor>();
     _mockShoppingContext = new Mock <IShoppingContext>();
     _checkoutService     = new CheckoutService(_mockHttpContext.Object, _mockShoppingContext.Object);
 }
Пример #16
0
        public static int Checkout(string skus)
        {
            CheckoutService checkServ = new CheckoutService();

            return(checkServ.ProcessBasket(skus));
        }
Пример #17
0
        //一筆訂單的總價
        public int GetOrderPrice(int memberId)
        {
            CheckoutService checkoutService = new CheckoutService();

            return(checkoutService.GetOrderPrice(memberId));
        }
Пример #18
0
        public IActionResult Index()
        {
            var listService = new CheckoutService(_context, HttpContext.Request.Cookies);

            return(View(listService.GetCheckoutList()));  //convert cookie into ImmutableList<CheckoutItemDto>
        }
Пример #19
0
 public AccountController()
 {
     _accountService  = new AccountService();
     _checkoutService = new CheckoutService();
 }
        public void CheckIn_Checks_Out_To_Earliest_Hold()
        {
            var options = new DbContextOptionsBuilder <LibraryDbContext>()
                          .UseInMemoryDatabase("Checks_out_to_earliest_hold")
                          .Options;

            using (var context = new LibraryDbContext(options))
            {
                var book = new Book
                {
                    Id     = 155,
                    Status = new Status {
                        Name = "Checked Out"
                    }
                };

                var checkout = new Checkout
                {
                    Id           = 2309,
                    LibraryAsset = book,
                    LibraryCard  = new LibraryCard {
                        Id = 5
                    }
                };

                context.Checkouts.Add(checkout);

                var libraryCard = new LibraryCard {
                    Id = 682
                };

                var earliestHold = new Hold
                {
                    Id           = 221,
                    LibraryCard  = libraryCard,
                    LibraryAsset = book,
                    HoldPlaced   = new DateTime(1954, 12, 30)
                };

                var latestHold = new Hold
                {
                    Id          = 1423,
                    LibraryCard = new LibraryCard {
                        Id = 12
                    },
                    LibraryAsset = book,
                    HoldPlaced   = new DateTime(2018, 2, 14)
                };

                context.Holds.Add(latestHold);
                context.Holds.Add(earliestHold);
                context.SaveChanges();
            }

            using (var context = new LibraryDbContext(options))
            {
                var service = new CheckoutService(context);
                service.CheckInItem(155);
                context.LibraryAssets.Find(155).Status.Name.Should().Be("Checked Out");
                context.LibraryCards.Find(682).Checkouts.Should().Contain(v => v.LibraryAsset.Id == 155);
            }
        }
        public void Test_LineItems_In_Save_Order()
        {
            var applicationUser = new ApplicationUser
            {
                FullName = "qwe rty",
                UserName = "******",
                PasswordHash = "AQAAAAEAACcQAAAAEFhb4f6tea+M5ljLQQv6paGE6/eo+IHQmiD0vlNdhJ66vPRY0rpFdoCW9XoeYm5/DQ==",
                Email = "*****@*****.**",
                EmailConfirmed = true,
                LockoutEnabled = false
            };
            orderLineItems = new List<OrderLineItemDTO>();

            var orderShippingPaymentDTO = new OrderShippingPaymentDTO
            {
                FullName = "qwe rty",
                PaymentMethod = "qwe rty",
                OrderDate = DateTime.UtcNow,
                PaymentStatus = "Paid",
                ShipAddress = "34c ,Test address ",
                ShippingMethod = "UPS",
                Email = "*****@*****.**",
                PhoneNumber = "0123456789",
                OrderTotalPrice = 568.00,
                OrderStatus = "Completed",
                ZipCode = "10001",
                UserName = "******",
                OrderLineItems = orderLineItems
            };

            var applicationUserlist = new List<ApplicationUser>();
            applicationUserlist.Add(applicationUser);
            var userManager = MockUserManager(applicationUserlist);
            userManager.Setup(x => x.FindByNameAsync(It.IsAny<string>())).Returns(Task.FromResult(applicationUser));

            var order = new Order
            {
                OrderDate = DateTime.UtcNow,
                ShippedDate = DateTime.UtcNow,
                ShipAddress = orderShippingPaymentDTO.ShipAddress,
                ShippingMethod = orderShippingPaymentDTO.ShippingMethod,
                Email = orderShippingPaymentDTO.Email,
                PhoneNumber = orderShippingPaymentDTO.PhoneNumber,
                TotalPrice = orderShippingPaymentDTO.OrderTotalPrice,
                OrderStatus = orderShippingPaymentDTO.OrderStatus
            };

            orderRepository.Setup(mr => mr.Save(It.IsAny<Order>())).Returns(order);

            var orderId = order.Id;
            foreach (var item in mapper.Map<IList<OrderLineItem>>(orderShippingPaymentDTO.OrderLineItems))
            {
                item.OrderID = orderId;
                orderLineItemsRepository.Setup(mr => mr.Save(It.IsAny<OrderLineItem>())).Returns(item);
            }

            var payment = new Payment
            {
                PaidDate = DateTime.UtcNow,
                Description = "",
                TotalPrice = order.TotalPrice,
                PaymentStatus = orderShippingPaymentDTO.PaymentStatus,
                PaymentMethod = orderShippingPaymentDTO.PaymentMethod,
                OrderID = order.Id,
                UserID = ""

            };

            paymentRepository.Setup(mr => mr.Save(It.IsAny<Payment>())).Returns(payment);

            var checkoutService = new CheckoutService(mapper, orderRepository.Object, orderLineItemsRepository.Object,
                paymentRepository.Object, userManager.Object);
            var result = checkoutService.SaveOrder(orderShippingPaymentDTO);

            var ex = Assert.ThrowsAsync<InvalidOperationException>( () =>  checkoutService.SaveOrder(orderShippingPaymentDTO));
            Assert.AreEqual("Can not save order Line items.", ex.Message);
        }
Пример #22
0
 public CheckoutServiceTests()
 {
     _checkoutService = new CheckoutService(_context, _httpContextAccessor);
     _cartService     = new CartService(_context, _httpContextAccessor);
     _addressService  = new AddressService(_context);
 }
Пример #23
0
        public Response <CheckoutResponse> ProcessCart(IResultResponse response, IRequestParameter parameters)
        {
            CheckoutService s = new CheckoutService(_core);

            return(s.ProcessCoupon(response, parameters));
        }
Пример #24
0
        public void SetUp()
        {
            Fake <ShippingOptionInfo, ShippingOptionInfoProvider>();
            Fake <PaymentOptionInfo, PaymentOptionInfoProvider>();
            Fake <ShoppingCartInfo, ShoppingCartInfoProvider>();
            Fake <CountryInfo, CountryInfoProvider>();
            Fake <StateInfo, StateInfoProvider>();
            Fake <ShoppingCartCouponCodeInfo, ShoppingCartCouponCodeInfoProvider>().WithData();

            mShoppingCartInfo = new ShoppingCartInfo();

            var cart = new ShoppingCart(mShoppingCartInfo);

            var paymentMethodRepository  = Substitute.For <IPaymentMethodRepository>();
            var shippingOptionRepository = Substitute.For <IShippingOptionRepository>();
            var countryRepository        = Substitute.For <ICountryRepository>();
            var addressRepository        = Substitute.For <ICustomerAddressRepository>();
            var shoppingService          = Substitute.For <ShoppingService>();
            var pricingService           = Substitute.For <PricingService>();

            shoppingService.GetCurrentShoppingCart().Returns(cart);

            var shippingUSPS = new ShippingOptionInfo()
            {
                ShippingOptionID   = SHIPPING_OPTION_ID,
                ShippingOptionName = "ShippingUSPS"
            };

            var paymentCashOnDelivery = new PaymentOptionInfo
            {
                PaymentOptionID   = PAYMENT_METHOD_ID,
                PaymentOptionName = "CashOnDelivery"
            };

            var paymentNotApplicable = new PaymentOptionInfo
            {
                PaymentOptionID   = PAYMENT_METHOD_NOT_APPLICABLE_ID,
                PaymentOptionName = "PaymentNotApplicable"
            };

            // Override method IsPaymentOptionApplicableInternal to make payment method not applicable
            PaymentOptionInfoProvider.ProviderObject = new LocalPaymentOptionInfoProvider();

            var countryUSA = new CountryInfo
            {
                CountryName = "USA",
                CountryID   = COUNTRY_ID
            };

            var stateOregon = new StateInfo
            {
                StateName = "Oregon",
                StateID   = STATE_ID,
                CountryID = COUNTRY_ID
            };

            shippingOptionRepository.GetAllEnabled().Returns(new List <ShippingOptionInfo> {
                shippingUSPS
            });
            paymentMethodRepository.GetAll().Returns(new List <PaymentOptionInfo> {
                paymentCashOnDelivery, paymentNotApplicable
            });
            countryRepository.GetCountryStates(COUNTRY_ID).Returns(new List <StateInfo> {
                stateOregon
            });
            countryRepository.GetCountryStates(COUNTRY_WITHOUT_STATES_ID).Returns(new List <StateInfo> {
            });
            countryRepository.GetCountry(COUNTRY_ID).Returns(countryUSA);

            checkoutService = new CheckoutService(shoppingService, pricingService, addressRepository, paymentMethodRepository, shippingOptionRepository, countryRepository);
        }
Пример #25
0
 public CheckoutController(IConfiguration configuration)
 {
     this.connectionString = configuration.GetConnectionString("ConnectionString");
     this.checkoutService  = new CheckoutService(new CheckoutRepository(this.connectionString), new CartRepository(this.connectionString));
 }
Пример #26
0
        private static void Main()
        {
            // See: https://www.codeproject.com/Questions/455766/Euro-symbol-does-not-show-up-in-Console-WriteLine
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Console.WriteLine("Press any key to start checkout process!");
            Console.ReadKey(true);

            var service = new CheckoutService();

            service.Start();

            string code;

            Console.Write($"Set credit limit - or continue '{SkipCode}'");
            code = Console.ReadLine();
            if (code != SkipCode)
            {
                try
                {
                    var rawLimit = Decimal.Parse(code);
                    service.CreditLimit = new Domain.Limiter.CreditLimit
                    {
                        CashLimit = rawLimit
                    };
                }
                catch (FormatException e)
                {
                    Console.WriteLine(e.Message);
                }
                catch (OverflowException e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            do
            {
                Console.Write($"Bar code (use '{StornoCode}' at the front of barcode) - or '{ExitCode}' to close checkout / '{ShowCode}' to show bill so far: ");
                code = Console.ReadLine();
                if (code == ExitCode)
                {
                    continue;
                }

                if (code == ShowCode)
                {
                    Console.WriteLine("Partial bill so far:");
                    Console.WriteLine(service.GetCurrentBill());
                    continue;
                }

                try
                {
                    if (code.StartsWith(StornoCode))
                    {
                        Console.WriteLine("Storno from:");
                        Console.WriteLine(service.GetCurrentBill());
                        var nakedBarCode = code.Substring(StornoCode.Length);
                        Console.WriteLine(service.Storno(nakedBarCode));
                        Console.WriteLine("To:");
                        Console.WriteLine(service.GetCurrentBill());
                    }
                    else
                    {
                        Console.WriteLine(service.Scan(code));
                    }
                }
                catch (InvalidBarCodeException e)
                {
                    Console.WriteLine(e.Message);
                }
            } while (code != ExitCode);

            service.Close();

            Console.WriteLine($"{Environment.NewLine}BILL:");
            Console.WriteLine(service.GetCurrentBill());
        }
        protected void CompletePaypalCheckout(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            var orderId            = string.Empty;
            var bCheckoutCompleted = false;

            try
            {
                // end create new user
                var newUser = CreateUser();

                _session.InCheckoutProccess     = false;
                _session.InOrderCreationProcess = true;

                AuthenticationService.UpdateSession(_session);

                if (_session.BasketId == null)
                {
                    Log("Invalid or missing basket in session. Id:" + _session.Id);
                    return;
                }

                //_basket = BasketService.GetBasket(_session.BasketId.Value);

                var isoCurrencyCode = CurrencyService.GetCurrencyIsoCodeById(_session.CurrencyId);

                Log("Paypal log- payment to take next, next is order");

                var payPalReturn = PaypalService.ConfirmPayment((_basket.Total.ToString(CultureInfo.InvariantCulture)), isoCurrencyCode, _session.PayPalToken, _session.PayPalPayerId);

                Log("Paypal log- payment taken, next is order, paypal return status: " + payPalReturn.ErrorMessage);

                _session.PayPalOrderId = payPalReturn.Transaction_Id;

                AuthenticationService.UpdateSession(_session);

                if (payPalReturn.IsError)
                {
                    throw new Exception(payPalReturn.ErrorMessage);
                }

                //create the order.
                var order = CheckoutService.CreateOrderPayPal(_session, _basket, newUser, GetClientIpAddress(), CurrentLanguageId,
                                                              MicrositeId);

                //persist address
                CheckoutService.CreateAddressPaypal(order, _session, newUser);

                //create barcodes
                Log("Payment success - Generate barcode");
                GenerateOrderBarcodes(order);

                //send booking to ECR.
                Log("Sending booking to ECR basketid: " + _basket.Id);
                var result = SendBookingToEcr(order);

                //result from booking must be there.
                if (result == null)
                {
                    JumpToOrderCreationError("Booking_failed", "SendBooking() to Ecr Failed");
                    return;
                }

                //clear cookie sessions and remove session from checkout mode
                ClearCheckoutCookies();

                //Prepare email notifications
                CreateOrderConfirmationEmail(order);
                orderId = order.Id.ToString();

                bCheckoutCompleted = true;
            }
            catch (Exception ex)
            {
                Log("Paypal Payment Error: " + ex.Message);
                bCheckoutCompleted = false;
            }
            finally
            {
                UnlockSessionFromOrderCreationLock(_session);
                Log("PayPal Payment - Session unlocked");
            }


            //Redirect user to order confirmation page or error
            Response.Redirect(bCheckoutCompleted
                ? string.Format("~/BookingCompleted.aspx?oid={0}", orderId)
                : @"~/ErrorPages/BookingError.aspx");
        }
Пример #28
0
 public CheckoutController(
     CheckoutService checkoutService)
 {
     _checkoutService = checkoutService;
 }
 public CheckoutController()
 {
     _checkoutService = new CheckoutService();
 }
Пример #30
0
 public static Garage GarageWithRandomTime()
 {
     
     var checkoutService = new CheckoutService(new RandomTimeService(), GetPriceCalculator());
     return new Garage(checkoutService);
 }
Пример #31
0
 public static Garage DefaultGarage()
 {
     var checkoutService = new CheckoutService(new DefaultTimeService(), GetPriceCalculator());
     return new Garage(checkoutService);
 }
Пример #32
0
 public ProductEventHandler()
 {
     _checkoutService = new CheckoutService();
 }