MCPcopy Create free account
hub / github.com/banq/jdonframework / getCardType

Method getCardType

src/main/java/com/jdon/util/UtilValidate.java:1024–1038  ·  view source on GitHub ↗

Checks to see if the cc number is a valid number for any accepted credit card, and return the name of that type @param ccPassed - a string representing a credit card number @return true, if the credit card number is any valid credit card number for any of the accepted card types, false othe

(String ccPassed)

Source from the content-addressed store, hash-verified

1022 * @return true, if the credit card number is any valid credit card number for any of the accepted card types, false otherwise
1023 */
1024 public static String getCardType(String ccPassed) {
1025 if (isEmpty(ccPassed)) return "Unknown";
1026 String cc = stripCharsInBag(ccPassed, creditCardDelimiters);
1027
1028 if (!isCreditCard(cc)) return "Unknown";
1029
1030 if (isMasterCard(cc)) return "MasterCard";
1031 if (isVisa(cc)) return "Visa";
1032 if (isAmericanExpress(cc)) return "AmericanExpress";
1033 if (isDinersClub(cc)) return "DinersClub";
1034 if (isDiscover(cc)) return "Discover";
1035 if (isEnRoute(cc)) return "EnRoute";
1036 if (isJCB(cc)) return "JCB";
1037 return "Unknown";
1038 }
1039
1040 /** Checks to see if the cc number is a valid number for the specified type
1041 * @param cardType - a string representing the credit card type

Callers

nothing calls this directly

Calls 10

isEmptyMethod · 0.95
stripCharsInBagMethod · 0.95
isCreditCardMethod · 0.95
isMasterCardMethod · 0.95
isVisaMethod · 0.95
isAmericanExpressMethod · 0.95
isDinersClubMethod · 0.95
isDiscoverMethod · 0.95
isEnRouteMethod · 0.95
isJCBMethod · 0.95

Tested by

no test coverage detected