Hello,
I'm running into an issue when trying to display the CardType from a creditCardMaskedType for a Discover card in a PaymentProfile. Other card types return properly, but for a Discover card, the CardType field is null. Is this expected behavior for a Discover card? Or is there another way of getting the CardType?
Thanks!
04-28-2022 08:20 AM
public static void main(final String args[]) { String cType = null; System.out.println("Enter a credit card number: "); final Scanner input = new Scanner(System.in); final String cardNumber = input.next(); if (cardNumber.startsWith("4")) { cType = "Visa"; } else if (cardNumber.startsWith("5")) { cType = "MasterCard"; } else if (cardNumber.startsWith("6")) { cType = "Discover"; } else if (cardNumber.startsWith("37")) { cType = "American Express"; } else { cType = "Unknown type"; } final long total = sumOfEvenPlaces(Long.valueOf(cardNumber)) + (sumOfOddPlaces(Long.valueOf(cardNumber)) * 2); if (isValid(total)) { System.out.println("The " + cType + " card number is valid"); } else { System.out.println("The " + cType + " card number is invalid."); } }
On a stylistic note, Ctype should start with a lower case letter (e.g. CType). You'll have to experiment with the use of Scanner as well as I'm not sure my implementation will do what you're looking for.
Let me know if this doesn't work.
04-29-2022 05:34 PM
CreditCardWidget( cardNumber: card['cardNumber'], expiryDate: card['expiryDate'], cardHolderName: card['cardHolderName'], cvvCode: card['cvvCode'], showBackView: false, onCreditCardWidgetChange: (brand) { print(brand); }, ),
07-30-2022
11:28 AM
- last edited on
07-30-2022
11:58 AM
by
KH-Taylarie