Class PosCapability

java.lang.Object
org.jpos.iso.PosFlags
org.jpos.iso.PosCapability

public class PosCapability extends PosFlags
Structured representation of DE-027 (POS Capability) in the jPOS CMF.

DE-027 is a 27-byte fixed-length field that describes the capabilities of the point-of-service terminal. It is the capability counterpart of PosDataCode (DE-022), which records what actually happened.

Wire layout

 Bytes  1- 4  Sub-field 27-1: card reading capability      (B4, bit-flags)
 Bytes  5- 8  Sub-field 27-2: cardholder verification cap. (B4, bit-flags)
 Byte   9     Sub-field 27-3: approval code length         (N1, ASCII)
 Bytes 10-12  Sub-field 27-4: cardholder receipt length    (N3, ASCII)
 Bytes 13-15  Sub-field 27-5: card acceptor receipt length (N3, ASCII)
 Bytes 16-18  Sub-field 27-6: cardholder display length    (N3, ASCII)
 Bytes 19-21  Sub-field 27-7: card acceptor display length (N3, ASCII)
 Bytes 22-24  Sub-field 27-8: ICC scripts data length      (N3, ASCII)
 Byte  25     Sub-field 27-9: track 3 rewrite capability   (A1, 'Y'/'N')
 Byte  26     Sub-field 27-10: card capture capability     (A1, 'Y'/'N')
 Byte  27     Sub-field 27-11: PIN input length capability (B1, binary)

Sub-fields 27-1 and 27-2 share the same bit-flag tables as DE-022. The PosDataCode.ReadingMethod and PosDataCode.VerificationMethod enums are therefore reused directly.

The bit-numbering convention follows ISO 8583: B1 = MSB = 0x80. Internally, PosFlags maps flag intValue() 1 to the LSB of each 4-byte word and serialises little-endian within each word—identical to PosDataCode. See the DE-022 spec note for the historical rationale.

Usage example:

// Build and pack
PosCapability cap = PosCapability.builder()
    .readingCapability(PosDataCode.ReadingMethod.MAGNETIC_STRIPE)
    .readingCapability(PosDataCode.ReadingMethod.ICC)
    .verificationCapability(PosDataCode.VerificationMethod.ONLINE_PIN)
    .verificationCapability(PosDataCode.VerificationMethod.MANUAL_SIGNATURE)
    .approvalCodeLength(6)
    .cardholderReceiptLength(40)
    .cardAcceptorReceiptLength(40)
    .cardholderDisplayLength(16)
    .cardAcceptorDisplayLength(16)
    .iccScriptDataLength(128)
    .track3RewriteCapable(false)
    .cardCaptureCapable(false)
    .pinInputLength(12)
    .build();

msg.set(new ISOBinaryField(27, cap.pack()));

// Unpack
PosCapability received = PosCapability.unpack(msg.getBytes(27));
if (received.canReadICC()) { ... }
See Also:
  • Field Details

  • Method Details

    • getBytes

      public byte[] getBytes()
      Returns the raw 27-byte wire buffer backing this instance. The returned array is the live backing store; callers should not modify it.
      Specified by:
      getBytes in class PosFlags
      Returns:
      the 27-byte wire buffer
    • builder

      public static PosCapability.Builder builder()
      Returns a new PosCapability.Builder for constructing a PosCapability.
      Returns:
      a new builder
    • unpack

      public static PosCapability unpack(byte[] data)
      Unpacks a PosCapability from a 27-byte wire buffer.
      Parameters:
      data - exactly 27 bytes
      Returns:
      the decoded PosCapability
      Throws:
      IllegalArgumentException - if data is null or not exactly 27 bytes
    • pack

      public byte[] pack()
      Packs this PosCapability into a 27-byte array suitable for placing directly into DE-027 of an ISOMsg.
      Returns:
      a fresh 27-byte copy of the wire buffer
    • toBuilder

      Returns a PosCapability.Builder pre-populated with all values from this instance, allowing selective modification.
      Returns:
      a builder initialised from this instance
    • canRead

      public boolean canRead(PosDataCode.ReadingMethod method)
      Returns true if the terminal supports the given card reading method.
      Parameters:
      method - the reading method to test
      Returns:
      true if the bit for method is set
    • canReadICC

      public boolean canReadICC()
      Returns true if the terminal can read ICC (chip) cards.
      Returns:
      true if PosDataCode.ReadingMethod.ICC is set
    • canReadMagstripe

      public boolean canReadMagstripe()
      Returns true if the terminal can read magnetic stripe cards.
      Returns:
      true if PosDataCode.ReadingMethod.MAGNETIC_STRIPE is set
    • canReadContactless

      public boolean canReadContactless()
      Returns true if the terminal supports contactless (RFID) reading.
      Returns:
      true if PosDataCode.ReadingMethod.CONTACTLESS is set
    • canVerify

      public boolean canVerify(PosDataCode.VerificationMethod method)
      Returns true if the terminal supports the given cardholder verification method.
      Parameters:
      method - the verification method to test
      Returns:
      true if the bit for method is set
    • canVerifyOnlinePin

      public boolean canVerifyOnlinePin()
      Returns true if the terminal supports online PIN entry.
      Returns:
      true if PosDataCode.VerificationMethod.ONLINE_PIN is set
    • canVerifyOfflinePinInClear

      public boolean canVerifyOfflinePinInClear()
      Returns true if the terminal supports offline PIN entry in clear.
      Returns:
      true if PosDataCode.VerificationMethod.OFFLINE_PIN_IN_CLEAR is set
    • canVerifyOfflinePinEncrypted

      public boolean canVerifyOfflinePinEncrypted()
      Returns true if the terminal supports offline encrypted PIN entry.
      Returns:
      true if PosDataCode.VerificationMethod.OFFLINE_PIN_ENCRYPTED is set
    • canVerifySignature

      public boolean canVerifySignature()
      Returns true if the terminal supports manual signature verification.
      Returns:
      true if PosDataCode.VerificationMethod.MANUAL_SIGNATURE is set
    • getApprovalCodeLength

      public int getApprovalCodeLength()
      Returns the maximum approval code length supported by this terminal (sub-field 27-3).
      Returns:
      approval code length, 0–9
    • getCardholderReceiptLength

      Returns the maximum cardholder receipt data length in characters (sub-field 27-4). A value of 0 indicates no receipt capability.
      Returns:
      cardholder receipt length, 0–999
    • getCardAcceptorReceiptLength

      Returns the maximum card acceptor (merchant) receipt data length in characters (sub-field 27-5). A value of 0 indicates no receipt capability.
      Returns:
      card acceptor receipt length, 0–999
    • getCardholderDisplayLength

      Returns the maximum cardholder display data length in characters (sub-field 27-6). A value of 0 indicates no display capability.
      Returns:
      cardholder display length, 0–999
    • getCardAcceptorDisplayLength

      Returns the maximum card acceptor display data length in characters (sub-field 27-7). A value of 0 indicates no display capability.
      Returns:
      card acceptor display length, 0–999
    • getIccScriptDataLength

      public int getIccScriptDataLength()
      Returns the maximum ICC scripts data length in bytes (sub-field 27-8). A value of 0 indicates no ICC script capability.
      Returns:
      ICC scripts data length, 0–999
    • canRewriteTrack3

      public boolean canRewriteTrack3()
      Returns true if the terminal can rewrite magnetic stripe track 3 (sub-field 27-9).
      Returns:
      true if track 3 rewrite is supported
    • canCaptureCard

      public boolean canCaptureCard()
      Returns true if the terminal can capture (retain) cards (sub-field 27-10).
      Returns:
      true if card capture is supported
    • getPinInputLength

      public int getPinInputLength()
      Returns the maximum PIN length the terminal's PIN pad can accept (sub-field 27-11).
      Returns:
      PIN input length capability, 0–255
    • dump

      public void dump(PrintStream p, String indent)
      Dumps a human-readable representation of this PosCapability to the given stream.
      Parameters:
      p - the output stream
      indent - indentation prefix