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

            ReserveInventory(cart);

            if (notifyCustomer)
            {
                NotifyCustomer(cart);
            }
        }
Ejemplo n.º 4
0
        // 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"
        }
Ejemplo n.º 5
0
 public void ProcessCreditCard(PaymentDetails paymentDetails, decimal amount)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public PoSCreditOrder(Cart cart, PaymentDetails paymentDetails)
     : base(cart)
 {
     _paymentDetails   = paymentDetails;
     _paymentProcessor = new PaymentProcessor();
 }