コード例 #1
0
ファイル: Order.cs プロジェクト: ProwarenessDevNext/SOLID
        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);
                }
            }
        }
コード例 #2
0
ファイル: Order.cs プロジェクト: ProwarenessDevNext/SOLID
        public void Checkout(Cart cart, PaymentDetails paymentDetails, bool notifyCustomer)
        {
            if (paymentDetails.PaymentMethod == PaymentMethod.CreditCard)
            {
                ChargeCard(paymentDetails, cart);
            }

            ReserveInventory(cart);

            if (notifyCustomer)
            {
                NotifyCustomer(cart);
            }
        }
コード例 #3
0
ファイル: Order.cs プロジェクト: luizaprata/solid
 public Order(Cart cart, PaymentDetails paymentDetails, INotificationService notifyCustomer)
 {
     _cart           = cart;
     _paymentDetails = paymentDetails;
     _notifyCustomer = notifyCustomer;
 }