cancel
Showing results for 
Search instead for 
Did you mean: 

Discover CardType is Null

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!

erikhanson
Member
1 REPLY 1

 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.

 
mikey445
New Member