Exemple #1
0
        public void GetPaymentInformation()
        {
            var    payment    = new CreditCardPayment();
            string cardNumber = payment.GetCardNumber();

            CardNumber = cardNumber;
            payment.GetExpDate();
            payment.GetCVV();
            string lastFourDigits = $"XXXX XXXX XXXX {cardNumber.Substring(cardNumber.Length - 4)}";

            LastFourDigits = lastFourDigits;
        }
        public string ReturnPaymentType(string paymentMethod, double subTotal)
        {
            if (paymentMethod.ToLower() == "credit")
            {
                var payment = new CreditCardPayment();
                payment.GetCardNumber();
                payment.GetExpDate();
                payment.GetCVV();
                payment.ObscureCCNumber(payment.CardNumber);
                string display = payment.LastFourDigits;
                DisplayCardNumber = display;
                return(DisplayCardNumber);
            }
            else if (paymentMethod.ToLower() == "cash")
            {
                var payment = new CashPayment();
                var total   = new Math();

                payment.GetPaymentInformation();
                AmountTendered = payment.AmountTendered;
                double changeDue = payment.ProvideChange(AmountTendered, (double)total.FindGrandTotal(total.FindtaxTotal(subTotal), subTotal));
                ChangeDue = $"${changeDue:#.##}";
                return(ChangeDue);
            }
            else if (paymentMethod.ToLower() == "check")
            {
                var payment = new CheckPayment();
                payment.GetPaymentInformation();
                var checkNumber = payment.CheckNumber;
                CheckNumber = checkNumber;
                return(CheckNumber);
            }
            else
            {
                throw new Exception(nameof(paymentMethod));
            }
        }