Interface CreditCardNumberHelper
- All Known Implementing Classes:
DefaultCreditCardNumberHelper
public interface CreditCardNumberHelper
Credit card number - oriented helper.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisValidCardNumber(String cardNumber, CreditCardType type) Validates Credit card number according to the given card type.Returns a string representation of masked credit card number.normalizeCreditCardNumber(String cardNumber) Removes all non-numeric characters Sample: 4111-1111-1111-1111 -> 4111111111111111.
-
Method Details
-
maskCreditCardNumber
Returns a string representation of masked credit card number. After 'normalizing' the submitted credit card number, all characters, except for the last 4, will be replaced by '*' Sample: 4111-1111-1111-1111 -> 4111111111111111 -> ************1111- Parameters:
cn-
-
isValidCardNumber
Validates Credit card number according to the given card type. I.e, whenCreditCardType.MASTERis given astype, the method checks if the submitted MASTER number is valid and performs a luhn test. Note: The submitted credit card number will be normalized at first!- Parameters:
cardNumber- card Number to validatetype- one ofCreditCardTypeenum value- Throws:
BusinessException
-
normalizeCreditCardNumber
Removes all non-numeric characters Sample: 4111-1111-1111-1111 -> 4111111111111111.- Parameters:
cardNumber- the credit card number- Returns:
- normalized credit card number
-