public class CardValidatorImpl extends Object implements CardValidator
| Constructor and Description |
|---|
CardValidatorImpl() |
| Modifier and Type | Method and Description |
|---|---|
CardValidationResult |
checkCard(CardInfo cardInfo)
Performs the complete suite of card validation, including the luhn check.
|
List<CreditCardType> |
getSupportedCardSchemes()
Returns the card schemes supported by the system.
|
protected boolean |
inRange(int num,
int lower,
int upper)
Return whether a number is within a given range (inclusive)
|
boolean |
isCardSchemeSupported(CreditCardType cardScheme)
Determines if the provided card scheme is supported by the system.
|
boolean |
isInternationalMaestro(String cardNumber)
Return whether the card number is an international Maestro card number.
|
protected boolean |
isValidDate(Integer month,
Integer year,
boolean expiryDate) |
boolean |
luhnCheck(String number)
Lifted from Wikipedia.
|
void |
setCv2ExemptCardSchemes(List<CreditCardType> cv2ExemptCardSchemes)
Sets a list of cards that do not require cv2 numbers.
|
void |
setSupportedCardSchemes(List<CreditCardType> supportedCardSchemes)
Set all the card schemes that are supported by the site.
|
protected void |
validateCardNumber(CardValidationResult validationResult,
CardInfo cardInfo)
Implements basic card validation.
|
protected void |
validateCardScheme(CardValidationResult result,
CardInfo cardInfo)
checks to see if the card scheme is supported for the given result with card scheme data.
|
protected void |
validateCv2(CardValidationResult validationResult,
CardInfo cardInfo,
boolean isCv2AvsPolicyDisabled) |
protected void |
validateDates(CardValidationResult validationResult,
CardInfo cardInfo) |
protected void |
validateName(CardValidationResult result,
CardInfo cardInfo)
Checks that the name consists of two separate names
|
public boolean luhnCheck(String number)
luhnCheck in interface CardValidatornumber - the credit card number to validate. If no credit card number is provided, false will be returned.public boolean isInternationalMaestro(String cardNumber)
protected boolean inRange(int num,
int lower,
int upper)
num - The number to testlower - The low end of the rangeupper - The upper end of the rangepublic void setSupportedCardSchemes(List<CreditCardType> supportedCardSchemes)
public List<CreditCardType> getSupportedCardSchemes()
CardValidatorgetSupportedCardSchemes in interface CardValidatorpublic void setCv2ExemptCardSchemes(List<CreditCardType> cv2ExemptCardSchemes)
public boolean isCardSchemeSupported(CreditCardType cardScheme)
CardValidatorisCardSchemeSupported in interface CardValidatorprotected void validateName(CardValidationResult result, CardInfo cardInfo)
protected void validateCardScheme(CardValidationResult result, CardInfo cardInfo)
result - protected void validateCardNumber(CardValidationResult validationResult, CardInfo cardInfo)
protected void validateDates(CardValidationResult validationResult, CardInfo cardInfo)
protected void validateCv2(CardValidationResult validationResult, CardInfo cardInfo, boolean isCv2AvsPolicyDisabled)
public CardValidationResult checkCard(CardInfo cardInfo)
CardValidatorcheckCard in interface CardValidatorCopyright © 2017 SAP SE. All Rights Reserved.