Class CardHolder
java.lang.Object
org.jpos.core.CardHolder
- All Implemented Interfaces:
Serializable, Cloneable, Loggeable
This class is called 'CardHolder', but a better name could have been 'Card'
At some point we'll deprecate this one and create a new 'Card' class.
- Since:
- jPOS 1.1
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptioncreates an empty CardHolderCardHolder(String track2) creates a new CardHolder based on track2CardHolder(String pan, String exp) Creates a new CardHolder with the given PAN and expiry date.CardHolder(ISOMsg m) Construct a CardHolder based on content received on field 35 (track2) or field 2 (PAN) + field 14 (EXP) -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(PrintStream p, String indent) dumps CardHolder basic information
by default we do not dump neither track1/2 nor securityCode for security reasons.booleangetBIN()Get the traditional 6-digit BIN (Bank Issuer Number) from the PANgetBIN(int len) Returns the firstlendigits of the PAN (the BIN).getEXP()Get Expiration DateReturns the cardholder name from track1.getPAN()Returns the Primary Account Number.Returns the card security code (CVV/CVC), or null.Returns the service code from track2, or three blanks if not available.Returns the track 1 raw data.Returns a reconstructed track 2 string, or null if track 2 data is absent.Returns the card trailer string.Deprecated.use getTrailer()inthashCode()booleanReturns true if a security code is present.booleanReturns true if track1 data is present.booleanReturns true if track2 data is (potentially) present.booleanY2K compliant expiration checkbooleanY2K compliant expiration checkbooleanReturns true if the PAN passes the Luhn (mod-10) check.static booleanisValidCRC(String p) Returns true if the given PAN passes the Luhn (mod-10) check.voidextract pan/exp/trailler from track2booleanReturns true if this card appears to have been entered manually.voidSet Expiration DatevoidSets Primary Account NumbervoidsetSecurityCode(String securityCode) assigns securityCode to this CardHolder objectvoidSets the track1 data.voidsetTrailer(String trailer) Sets the card trailer string.voidsetTrailler(String trailer) Deprecated.use setTrailerMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Loggeable
dumpModifier and TypeMethodDescriptiondefault voiddump(PrintStream p, String indent, LogRenderer.Type type) Dumps a representation of this object using the specified renderer type.
-
Field Details
-
pan
-
exp
-
trailer
-
securityCode
Optional security code (CVC, CVV, Locale ID, wse) -
track1
-
-
Constructor Details
-
CardHolder
public CardHolder()creates an empty CardHolder -
CardHolder
creates a new CardHolder based on track2- Parameters:
track2- cards track2- Throws:
InvalidCardException- if card data fails validation
-
CardHolder
Creates a new CardHolder with the given PAN and expiry date.- Parameters:
pan- the primary account numberexp- the expiry date (YYMM)- Throws:
InvalidCardException- if card data is invalid
-
CardHolder
Construct a CardHolder based on content received on field 35 (track2) or field 2 (PAN) + field 14 (EXP)- Parameters:
m- an ISOMsg- Throws:
InvalidCardException- if card data is invalid
-
-
Method Details
-
parseTrack2
extract pan/exp/trailler from track2- Parameters:
s- a valid track2- Throws:
InvalidCardException- if card data is invalid
-
setTrack1
-
getTrack1
-
hasTrack1
Returns true if track1 data is present.- Returns:
- true if we have a track1
-
getNameOnCard
Returns the cardholder name from track1.- Returns:
- the Name written on the card (from track1)
-
getTrack2
-
hasTrack2
Returns true if track2 data is (potentially) present.- Returns:
- true if we have a (may be valid) track2
-
setSecurityCode
assigns securityCode to this CardHolder object- Parameters:
securityCode- Card's security code
-
getSecurityCode
Returns the card security code (CVV/CVC), or null.- Returns:
- securityCode (or null)
-
hasSecurityCode
Returns true if a security code is present.- Returns:
- true if we have a security code
-
getTrailler
-
setTrailler
Deprecated.use setTrailerSet Card's trailer- Parameters:
trailer- Card's trailer
-
getTrailer
-
setTrailer
Sets the card trailer string.- Parameters:
trailer- card trailer
-
setPAN
Sets Primary Account Number- Parameters:
pan- Primary Account NUmber- Throws:
InvalidCardException- if the PAN is too short or fails validation
-
getPAN
-
getBIN
-
getBIN
-
setEXP
Set Expiration Date- Parameters:
exp- card expiration date- Throws:
InvalidCardException- if card data is invalid
-
getEXP
-
isExpired
Y2K compliant expiration check- Returns:
- true if card is expired (or expiration is invalid)
-
isExpired
-
isValidCRC
Returns true if the PAN passes the Luhn (mod-10) check.- Returns:
- true if the Luhn check passes
-
isValidCRC
Returns true if the given PAN passes the Luhn (mod-10) check.- Parameters:
p- the PAN to validate- Returns:
- true if the Luhn check passes
-
dump
dumps CardHolder basic information
by default we do not dump neither track1/2 nor securityCode for security reasons. -
getServiceCode
Returns the service code from track2, or three blanks if not available.- Returns:
- ServiceCode (if available) or a String with three blanks
-
seemsManualEntry
Returns true if this card appears to have been entered manually.- Returns:
- true if manual entry is suspected
-
hashCode
-
equals
-