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); } }
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); }
public abstract void Charge(PaymentDetails paymentDetails, Cart cart);
public abstract void Checkout(Cart cart, PaymentDetails paymentDetails, bool notifyCustomer);