public class CardValidatorImpl extends java.lang.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.
|
java.util.List<CreditCardType> |
getSupportedCardSchemes()
Returns the card schemes supported by the system.
|
protected boolean |
hasExpirationDate(CardInfo cardInfo) |
protected boolean |
inRange(int num,
int lower,
int upper)
Return whether a number is within a given range (inclusive)
|
protected boolean |
isAfterCurrentYear(java.lang.Integer year,
java.lang.Integer month,
int currentYear,
int currentMonth) |
protected boolean |
isBeforeCurrentYear(java.lang.Integer year,
java.lang.Integer month,
int currentYear,
int currentMonth) |
boolean |
isCardSchemeSupported(CreditCardType cardScheme)
Determines if the provided card scheme is supported by the system.
|
protected boolean |
isExpired(CardInfo cardInfo) |
boolean |
isInternationalMaestro(java.lang.String cardNumber)
Return whether the card number is an international Maestro card number.
|
protected boolean |
isLuhnCheckCompliant(CardInfo cardInfo) |
protected boolean |
isValidDate(java.lang.Integer month,
java.lang.Integer year,
boolean expiryDate) |
boolean |
luhnCheck(java.lang.String number)
Lifted from Wikipedia.
|
void |
setCv2ExemptCardSchemes(java.util.List<CreditCardType> cv2ExemptCardSchemes)
Sets a list of cards that do not require cv2 numbers.
|
void |
setSupportedCardSchemes(java.util.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 |
validateCv2Format(CardValidationResult validationResult,
CardInfo cardInfo) |
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(java.lang.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(java.lang.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(java.util.List<CreditCardType> supportedCardSchemes)
public java.util.List<CreditCardType> getSupportedCardSchemes()
CardValidatorgetSupportedCardSchemes in interface CardValidatorpublic void setCv2ExemptCardSchemes(java.util.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 boolean isLuhnCheckCompliant(CardInfo cardInfo)
protected void validateDates(CardValidationResult validationResult, CardInfo cardInfo)
protected boolean isExpired(CardInfo cardInfo)
protected boolean hasExpirationDate(CardInfo cardInfo)
protected boolean isValidDate(java.lang.Integer month,
java.lang.Integer year,
boolean expiryDate)
protected boolean isBeforeCurrentYear(java.lang.Integer year,
java.lang.Integer month,
int currentYear,
int currentMonth)
protected boolean isAfterCurrentYear(java.lang.Integer year,
java.lang.Integer month,
int currentYear,
int currentMonth)
protected void validateCv2(CardValidationResult validationResult, CardInfo cardInfo, boolean isCv2AvsPolicyDisabled)
protected void validateCv2Format(CardValidationResult validationResult, CardInfo cardInfo)
public CardValidationResult checkCard(CardInfo cardInfo)
CardValidatorcheckCard in interface CardValidatorCopyright © 2018 SAP SE. All Rights Reserved.