public OnlineOrder(Refactored.Cart cart, PaymentDetails paymentDetails) : base(cart) { _notificationService = new NotificationService(); _paymentDeatils = paymentDetails; _paymentProcessor = new PaymentProcessor(); _reservationService = new ReservationService(); }
public void ChargeCard(PaymentDetails paymentDetails, Refactored.Cart cart) { using (var paymentGateway = new PaymentGateway()) { try { paymentGateway.Credentials = "account credentials"; paymentGateway.CardNumber = paymentDetails.CreditCardNumber; paymentGateway.ExpiresMonth = paymentDetails.ExpiresMonth; paymentGateway.ExpiresYear = paymentDetails.ExpiresYear; paymentGateway.NameOnCard = paymentDetails.CardholderName; paymentGateway.AmountToCharge = cart.TotalAmount(); paymentGateway.Charge(); } catch (AvsMismatchException ex) { throw new OrderException("The card gateway rejected the card based on the address provided.", ex); } catch (Exception ex) { throw new OrderException("There was a problem with your card.", ex); } } }
public OnlineOrder(Refactored.Cart cart, PaymentDetails paymentDetails, IPaymentProcessor paymentProcessor, IReservationService reservationService, INotificationService notificationService) : base(cart) { _paymentDetails = paymentDetails; _paymentProcessor = paymentProcessor; _reservationService = reservationService; _notificationService = notificationService; }
//Tightly Coupled public void Checkout(Refactored.Cart cart, PaymentDetails paymentDetails, bool notifyCustomer) { if (paymentDetails.PaymentMethod == PaymentMethod.CreditCard) { ChargeCard(paymentDetails, cart); } ReserveInventory(cart); if (notifyCustomer) { _notifyCustomer.NotifyCustomerOrderCreated(cart); } }
public void ReserveInventory(Refactored.Cart cart) { foreach (var item in cart.Items) { try { var inventorySystem = new InventorySystem(); inventorySystem.Reserve(item.Sku, item.Quantity); } catch (InsufficientInventoryException ex) { throw new OrderException("Insufficient inventory for item " + item.Sku, ex); } catch (Exception ex) { throw new OrderException("Problem reserving inventory", ex); } } }
public void NotFailWithNoItemsNotificationNoCreditCard() { var paymentProcessor = new FakePaymentProcessor(); var reservationService = new FakeReservationService(); var notificationService = new NotificationService(); var cart = new Refactored.Cart() { CustomerEmail = "*****@*****.**" }; var paymentDetails = new PaymentDetails() { PaymentMethod = PaymentMethod.CreditCard }; var order = new LosselyCoupled.OnlineOrder(cart, paymentDetails, paymentProcessor, reservationService, notificationService); order.Checkout(); // if I got here, I guess it worked... }
public PosCreditOrder(Refactored.Cart cart, PaymentDetails paymentDetails) : base(cart) { _paymentDetails = paymentDetails; _paymentProcessor = new PaymentProcessor(); }
public void SetUp() { _cart = new Refactored.Cart(); }
public PoSCashOrder(Refactored.Cart cart) : base(cart) { }
protected OrderSRP(Refactored.Cart cart) { _cart = cart; }