Class Track2.Builder
java.lang.Object
org.jpos.core.Track2.Builder
- Enclosing class:
Track2
Fluent builder that parses a raw track2 string or assembles a
Track2
from individual fields and validates the result against a configurable pattern.- Since:
- jPOS 2.0.5
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the immutableTrack2.Constructs the Track2 data based on the card data provided.Sets the CVV/CVC value.discretionaryData(String discretionaryData) Sets the discretionary data trailing the service code.Sets the expiration date.Sets the primary account number.Optional method, can be used to override default patternserviceCode(String serviceCode) Sets the service code.Parses a raw track2 string and populates the builder fields.
-
Method Details
-
pan
Sets the primary account number.- Parameters:
pan- primary account number- Returns:
- this builder
-
exp
Sets the expiration date.- Parameters:
exp- expiration date inYYMMform- Returns:
- this builder
-
cvv
Sets the CVV/CVC value.- Parameters:
cvv- CVV/CVC value- Returns:
- this builder
-
serviceCode
Sets the service code.- Parameters:
serviceCode- three-digit service code- Returns:
- this builder
-
discretionaryData
Sets the discretionary data trailing the service code.- Parameters:
discretionaryData- discretionary data trailing the service code- Returns:
- this builder
-
pattern
Optional method, can be used to override default pattern- Parameters:
pattern- overrides default pattern- Returns:
- this builder
-
track
Parses a raw track2 string and populates the builder fields.- Parameters:
s- raw track2 data- Returns:
- this builder
- Throws:
InvalidCardException- ifsis null, exceeds 37 characters, or does not match the configured pattern
-
buildTrackData
Constructs the Track2 data based on the card data provided. The generated Track2 data is validated using the pattern. If the Track2 data doesn't match the pattern, the track attribute keeps the original value.- Returns:
- this builder.
-
build
Builds the immutableTrack2. If no raw track string was set, one is assembled from the individual fields viabuildTrackData().- Returns:
- the built
Track2
-