public void VisaPaymentAcceptsSimplePaymentDetails() { var sut = new VisaPayment(); var informationModifier = new SimplePaymentDetails(); sut.AcceptModificationsBy(informationModifier); Assert.That( informationModifier.GetModifiedData, Is.EqualTo("VisaDescription"), "description"); }
public void VisaPaymentAcceptsHtmlPaymentDetails() { var sut = new VisaPayment(); var informationModifier = new HtmlPaymentDetails(); sut.AcceptModificationsBy(informationModifier); Assert.That( informationModifier.GetModifiedData, Is.EqualTo("<html><body><div>VisaDescription</div></body></hmtl>"), "description"); }
public ActionResult SaveOrder(PaymentType type) { var basket = GetBasket(); int orderId = CreateOrUpdateCurrentOrder(basket); string customerId = (User as IUserPrincipal).Id; decimal sum = basket.Sum(p => p.Price * p.Quantity); IPaymentStrategy strategy; switch (type) { case PaymentType.Bank: _orderService.Pay(orderId); Session[Basket] = null; List <string> paragraphs = basket.Select(purchase => $"Game name: {purchase.GameName}\n" + $"Quantity: {purchase.Quantity}\n" + $"Price: {purchase.Price}\n\n").ToList(); paragraphs.Add($"Total price: {sum}"); strategy = new BankPayment(paragraphs.ToArray()); break; case PaymentType.IBox: _orderService.Pay(orderId); Session[Basket] = null; strategy = new IBoxPayment(customerId, orderId, sum, _iBoxPaymentResultBuilder); break; case PaymentType.Visa: string currentCulture = Thread.CurrentThread.CurrentCulture.Name.Substring(0, 2); strategy = new VisaPayment($"/{currentCulture}/Basket/Visa"); break; default: { throw new UndefinedPaymentTypeException(); } } return(strategy.GetActionResult()); }
public void AllowCartToBeCheckedout() { //Given Cart c = new Cart(); c.AddItem(new Item() { Name = "Microsot Mouse", Quantity = 1, Price = 10 }); //When Order o = new Order(); Address address = new Address() { HouseNum = 6969, Street = "IDK", Area = "IDK", State = "IDK", Country = "IDK" }; IPayment payment = new VisaPayment(); IPayment MastercardPayment = new MasterCardPayment(); payment.CardNumber = "343434343435645656"; payment.CVV = "123"; //Then o.Checkout(c, address, payment); Assert.Equal(o.OrderStatus, OrderStatus.Confirmed); }
public void MakePaymentWithVisa() { IPayment payment = new VisaPayment(); payment.Pay(Order.GetPrice()); }