public OnlineOrder(ShoppingCart shoppingCart, PaymentDetails paymentDetails, INotificationService notificationService, IPaymentService paymentService, IReservationService reservationService) : base(shoppingCart) { _paymentDetails = paymentDetails; _paymentService = paymentService; _reservationService = reservationService; _notificationService = notificationService; }
public void ProcessCreditCard(PaymentDetails paymentDetails, decimal moneyAmount) { try { CardNumber = paymentDetails.CreditCardNumber; ExpiryDate = paymentDetails.ExpiryDate; NameOnCard = paymentDetails.CardholderName; AmountToCharge = moneyAmount; this.Charge(); } catch (AccountBalanceMismatchException 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); } }
static void Main(string[] args) { OrderItem objItem1 = new OrderItem { Identifier = "Toy", Quantity = 2 }; OrderItem objItem2 = new OrderItem { Identifier = "Utensils", Quantity = 1 }; List <OrderItem> items = new List <OrderItem>(); items.Add(objItem1); items.Add(objItem2); ShoppingCart objCart = new ShoppingCart(); objCart.CustomerEmail = "*****@*****.**"; objCart.TotalAmount = 120; objCart.Items = items; //#1 : CashOrder CashOrder objOrder = new CashOrder(objCart); objOrder.Checkout(); //#2 : CreditCardOrder PaymentDetails objPaymentDetails = new PaymentDetails(); objPaymentDetails.CardholderName = "Prashanth"; objPaymentDetails.CreditCardNumber = "1234-5678-6783-8712"; objPaymentDetails.ExpiryDate = DateTime.Now.AddDays(30); IPaymentService objPaymentService = new PaymentService(); CreditCardOrder objCreditCardOrder = new CreditCardOrder(objCart, objPaymentDetails, objPaymentService); objCreditCardOrder.Checkout(); //#3 : OnlineOrder INotificationService objNotificationService = new NotificationService(); //Filled with CustomerEmail IReservationService objReservationService = new ReservationService(); //Filled with items OnlineOrder objOnlineOrder = new OnlineOrder(objCart, objPaymentDetails, objNotificationService, objPaymentService, objReservationService); objOnlineOrder.Checkout(); }
public CreditCardOrder(ShoppingCart shoppingCart, PaymentDetails paymentDetails, IPaymentService paymentService) : base(shoppingCart) { _paymentDetails = paymentDetails; _paymentService = paymentService; }