public void ChargeCard(PaymentDetails paymentDetails, 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);
                }
            }
        }
Exemple #2
0
 public OnlineOrder(Cart cart, PaymentDetails paymentDetails)
     : base(cart)
 {
     _paymentDetails      = paymentDetails;
     _paymentProcessor    = new PaymentProcessor();
     _reservationService  = new ReservationService();
     _notificationService = new NotificationService();
 }
        public void Checkout(Cart cart, PaymentDetails paymentDetails, bool notifyCustomer)
        {
            if (paymentDetails.PaymentMethod == PaymentMethod.CreditCard)
            {
                ChargeCard(paymentDetails, cart);
            }

            ReserveInventory(cart);

            if (notifyCustomer)
            {
                NotifyCustomer(cart);
            }
        }
        // you will see that most of the work is done in the "CheckOut" Method.
        public void Checkout(Cart cart, PaymentDetails paymentDetails, bool notifyCustomer)
        {
            // Problem 1: "Cash" Transactions do not need "Credit Card" Processing
            if (paymentDetails.PaymentMethod == PaymentMethod.CreditCard)
            {
                ChargeCard(paymentDetails, cart);
            }

            // Problem 2: Point Of Sale Transactions Do not need Inventory Reservations
            ReserveInventory(cart);

            // Problem 3: Point Of Sale Transactions do not need email notifications
            // the customer does not provide an email
            // the customer knows immediately that the order was success
            if (notifyCustomer)
            {
                NotifyCustomer(cart);
            }

            // Problem 4: Any Change to notifications, Credit Card processing, Or Inventory
            // management will affect "Order" as well as the "Web" and "Point Of Sale"
            // implementations of "Order"
        }
Exemple #5
0
 public void ProcessCreditCard(PaymentDetails paymentDetails, decimal amount)
 {
     throw new NotImplementedException();
 }
Exemple #6
0
 public PoSCreditOrder(Cart cart, PaymentDetails paymentDetails)
     : base(cart)
 {
     _paymentDetails   = paymentDetails;
     _paymentProcessor = new PaymentProcessor();
 }