Ejemplo n.º 1
0
        public static 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);
                }
            }
        }
 public override void Charge(PaymentDetails paymentDetails, Cart cart)
 {
     if (paymentDetails.PaymentMethod == PaymentMethod.CreditCard)
     {
         ChargeItems.ChargeCard(paymentDetails, cart);
     }
 }
        public override void Checkout(Cart cart, PaymentDetails paymentDetails, bool notifyCustomer)
        {
            Charge(paymentDetails, cart);

            ReserveInventory(cart);

            if (notifyCustomer)
            {
                NotifyCustomer(cart);
            }
        }
Ejemplo n.º 4
0
        public static void ChargeCash(PaymentDetails paymentDetails, Cart cart)
        {
            using (var paymentGateway = new PaymentGateway())
                try
                {
                    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 override void Checkout(Cart cart, PaymentDetails paymentDetails, bool notifyCustomer)
 {
     Charge(paymentDetails, cart);
 }
Ejemplo n.º 6
0
 public abstract void Charge(PaymentDetails paymentDetails, Cart cart);
Ejemplo n.º 7
0
 public abstract void Checkout(Cart cart, PaymentDetails paymentDetails, bool notifyCustomer);