Class LifeCycleId
java.lang.Object
org.jpos.iso.LifeCycleId
Encodes and decodes the ISO 8583 Transaction Life Cycle Identification Data
(DE-021).
DE-021 is a 19-byte constructed field that correlates related messages across a transaction's full life cycle—authorization, financial presentment, reversal, and chargeback.
Wire layout
Bytes Notation Sub-field 1 AN1 (ASCII) Life cycle support indicator 2–16 AN15 (ASCII) Life cycle trace identifier 17–18 N2 (BCD) Life cycle transaction sequence number 19–22 N4 (BCD) Life cycle authentication token
jPOS TxnId integration
When jPOS originates a transaction, the trace identifier is populated from
a TxnId via its base-36 TxnId.toRrn() form, right-padded with
spaces to 15 characters. On inbound messages, txnId() attempts to
reverse this mapping; it returns an empty Optional when the trace
identifier does not represent a TxnId (e.g. when received from an
external network with its own trace ID scheme).
Usage — outbound (originates authorization)
byte[] de21 = LifeCycleId.builder()
.supportIndicator(mti) // derives '1' for 1xx, '2' for 2xx, etc.
.traceId(txnId) // uses txnId.toRrn(), padded to 15 chars
.build()
.pack();
msg.set(new ISOBinaryField(21, de21));
Usage — outbound (financial presentment echoing prior auth)
LifeCycleId authLC = LifeCycleId.unpack(authMsg.getBytes(21));
byte[] de21 = authLC.toBuilder()
.sequenceNumber(seq)
.authToken(tokenFromAuthResponse)
.build()
.pack();
Usage — inbound (from external network)
LifeCycleId lc = LifeCycleId.unpack(msg.getBytes(21));
lc.txnId().ifPresent(t -> ctx.put("TXNID", t));
String rawTrace = lc.traceIdentifier();
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum trace identifier length in characters.static final intWire length of the full DE-021 field in bytes. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the life cycle authentication token assigned by the card issuer.static LifeCycleId.Builderbuilder()Returns a new empty builder.byte[]pack()Serializes this life cycle identifier to the DE-021 wire format.intReturns the life cycle transaction sequence number.charReturns the life cycle support indicator character.static charDerives the life cycle support indicator character from an ISO 8583 MTI.Creates a newLifeCycleId.Builderpre-populated with this instance's values.toString()Returns the raw 15-character life cycle trace identifier.txnId()Attempts to parse the trace identifier as a jPOSTxnId.static LifeCycleIdunpack(byte[] data) Deserializes DE-021 bytes into aLifeCycleId.
-
Field Details
-
WIRE_LENGTH
-
TRACE_ID_LENGTH
-
-
Method Details
-
supportIndicator
Returns the life cycle support indicator character.'1'indicates the identifier was first assigned during an authorization message;'2'during a financial presentment.- Returns:
- support indicator
-
traceIdentifier
Returns the raw 15-character life cycle trace identifier.- Returns:
- trace identifier
-
txnId
-
sequenceNumber
Returns the life cycle transaction sequence number. Zero when not assigned.- Returns:
- sequence number
-
authToken
Returns the life cycle authentication token assigned by the card issuer. Zero when not yet assigned or when omitted by mutual agreement.- Returns:
- authentication token
-
pack
Serializes this life cycle identifier to the DE-021 wire format.- Returns:
- 19-byte wire representation
-
unpack
Deserializes DE-021 bytes into aLifeCycleId.- Parameters:
data- 19-byte DE-021 field content- Returns:
- parsed life cycle identifier
- Throws:
ISOException- when the byte array is null, empty, or too short
-
toBuilder
Creates a newLifeCycleId.Builderpre-populated with this instance's values. Useful for constructing a financial presentment that echoes an authorization's life cycle identifier.- Returns:
- builder initialized from this instance
-
builder
-
supportIndicatorForMTI
Derives the life cycle support indicator character from an ISO 8583 MTI. Returns the first digit of the MTI's class component (position 1, 0-indexed).Examples:
"0100"→'1',"0200"→'2',"0420"→'4'.- Parameters:
mti- 3- or 4-character ISO 8583 MTI string- Returns:
- support indicator character
- Throws:
IllegalArgumentException- when the MTI is null or too short
-
toString
-