public void TakePaymentCheck(double grandTotalOwed, double tax) { //Menu.cs Ask user for check number Console.WriteLine("Check: "); Console.WriteLine("Please enter your 4 digit check number: "); var userCheckNumber = Console.ReadLine(); bool userRoutingNumberValidation; do { Console.WriteLine("Please enter your 9 digit routing number: "); var userRoutingNumber = Console.ReadLine(); userRoutingNumberValidation = (!(ValidatePayment.ValidateRoutingNum(userRoutingNumber))); if (userRoutingNumberValidation) { Console.WriteLine("Incorrect routing number, please enter a valid 9 digit number"); } } while (userRoutingNumberValidation); Console.WriteLine("Please enter your checking 9 digit account number: "); var userCheckingAccountNumber = Console.ReadLine(); var checkingAccountValidation = (!(ValidatePayment.ValidaCheckingAccountNum(userCheckingAccountNumber))); FileHandler.Writereceipt(ReceiptWriterPath, "\n"); FileHandler.Writereceipt(ReceiptWriterPath, $" Subtotal {grandTotalOwed - tax:C}", true); FileHandler.Writereceipt(ReceiptWriterPath, $" Tax {tax:C}", true); FileHandler.Writereceipt(ReceiptWriterPath, " ----------------------------"); FileHandler.Writereceipt(ReceiptWriterPath, $" Total: {grandTotalOwed:C}"); FileHandler.Writereceipt(ReceiptWriterPath, $"Method of payment check in the amount of: {grandTotalOwed:C}"); }
public static bool IsAnInteger(string userPaymentMethod) { if (int.TryParse(userPaymentMethod, out int userPaymentMethodInteger)) //check to see if parseable to integer { var isWithinRange = ValidatePayment.BetweenMoRanges(1, 3, userPaymentMethodInteger); //check to see if within 1-3 return(isWithinRange); //within range and parselable to integer } return(false); //not int or withing 1-3 }
public void TakePaymentCreditCard(double grandTotalOwed, double tax) {//Menu.cs Ask user for cc number, expiry date, and cvv number bool validatedUserInput; do { Console.WriteLine("Credit/Debit card: "); Console.WriteLine("Please enter your 12 digit credit card number: "); var userCardNumber = Console.ReadLine(); validatedUserInput = (!(ValidatePayment.ValidateCreditCardAccountNumberIsLongEnough(userCardNumber) && ValidatePayment.ValidateAcctNum(userCardNumber))); if (validatedUserInput) { Console.WriteLine("Sorry, that number is not a valid credit card number."); //TakePaymentCreditCard(totalOwed); } }while (validatedUserInput); bool validateUserExpiration; do { Console.WriteLine("Please enter your 4 digit expiration date (MMYY): "); var userExpirationDate = Console.ReadLine(); validateUserExpiration = !(ValidatePayment.ValidateExpDate(userExpirationDate)); if (validateUserExpiration) { Console.WriteLine("Sorry, that number is not a valid expiration date (MMYY)"); //TakePaymentCreditCard(totalOwed); } }while (validateUserExpiration); bool cvvUserValidation; do { Console.WriteLine("Please enter your 3 digit CVV number: "); var userCvvNumber = Console.ReadLine(); cvvUserValidation = !(ValidatePayment.ValidateCVV(userCvvNumber)); if (cvvUserValidation) { Console.WriteLine("Sorry, that number is not a valid CVV number."); //TakePaymentCreditCard(totalOwed); } }while (cvvUserValidation); FileHandler.Writereceipt(ReceiptWriterPath, "\n"); FileHandler.Writereceipt(ReceiptWriterPath, $" Subtotal {grandTotalOwed - tax:C}", true); FileHandler.Writereceipt(ReceiptWriterPath, $" Tax {tax:C}", true); FileHandler.Writereceipt(ReceiptWriterPath, " ----------------------------"); FileHandler.Writereceipt(ReceiptWriterPath, $" Total: {grandTotalOwed:C}"); FileHandler.Writereceipt(ReceiptWriterPath, $"Credit/Debit card charged in the amount of: {grandTotalOwed:C}"); //to do receipt writer }