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)
| 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 |
nothing calls this directly
no test coverage detected