Skip to content

Latest commit

 

History

History
154 lines (113 loc) · 4.79 KB

File metadata and controls

154 lines (113 loc) · 4.79 KB

2. ISO-8583 Message Structure

ISO-8583 messages are structured in a specific way to ensure standardized communication between financial systems. The message structure consists of three main parts: the Message Type Indicator (MTI), Bitmaps, and Data Elements.

2.1. Message Type Indicator (MTI)

The Message Type Indicator (MTI) is a four-digit code that defines the overall purpose and characteristics of the ISO-8583 message.

2.1.1. Four-digit structure

The MTI is always a four-digit numeric value. Each digit has a specific meaning:

  1. First digit: Version
  2. Second digit: Message Class
  3. Third digit: Message Function
  4. Fourth digit: Message Origin

2.1.2. Version, Message Class, Message Function, Message Origin

  • Version (1st digit):

    • 0: ISO 8583-1:1987
    • 1: ISO 8583-2:1993
    • 2: ISO 8583-3:2003
    • 3-9: Reserved for future use
  • Message Class (2nd digit):

    • 0: Reserved
    • 1: Authorization
    • 2: Financial
    • 3: File actions
    • 4: Reversal and chargeback
    • 5: Reconciliation
    • 6: Administrative
    • 7: Fee collection
    • 8: Network management
    • 9: Reserved for ISO use
  • Message Function (3rd digit):

    • 0: Request
    • 1: Response
    • 2: Advice
    • 3: Advice response
    • 4-9: Reserved for ISO use
  • Message Origin (4th digit):

    • 0: Acquirer
    • 1: Acquirer repeat
    • 2: Issuer
    • 3: Issuer repeat
    • 4: Other
    • 5: Other repeat

Here's an example of how to create an ISO-8583 message with a specific MTI using jPOS:

import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOException;

public class MTIExample {
    public static void main(String[] args) throws ISOException {
        ISOMsg message = new ISOMsg();
        message.setMTI("0100"); // Authorization request
        
        System.out.println("MTI: " + message.getMTI());
    }
}

2.2. Bitmaps

Bitmaps are used to indicate which data elements are present in the message. Each bit in the bitmap represents a specific data element.

2.2.1. Primary bitmap

The primary bitmap is always present and indicates the presence of data elements 1 to 64.

2.2.2. Secondary bitmap

If bit 1 of the primary bitmap is set (1), it indicates the presence of a secondary bitmap. The secondary bitmap indicates the presence of data elements 65 to 128.

2.2.3. Tertiary bitmap (if applicable)

Some implementations may use a tertiary bitmap for data elements 129 to 192, although this is less common.

Here's an example of how to set and check bitmaps using jPOS:

import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOException;

public class BitmapExample {
    public static void main(String[] args) throws ISOException {
        ISOMsg message = new ISOMsg();
        message.setMTI("0100");
        
        // Set some fields
        message.set(2, "1234567890123456"); // Primary Account Number
        message.set(3, "000000"); // Processing Code
        message.set(4, "000000010000"); // Transaction Amount
        message.set(65, "1234567890"); // Extended Primary Account Number
        
        // Print bitmap information
        System.out.println("Primary Bitmap: " + message.getBitmap());
        System.out.println("Has Secondary Bitmap: " + message.hasSecondaryBitmap());
    }
}

2.3. Data Elements

Data elements are the actual fields that contain the transaction data.

2.3.1. Field numbering (1-128 for primary, 129-192 for secondary)

  • Fields 1-64 are represented by the primary bitmap
  • Fields 65-128 are represented by the secondary bitmap
  • Fields 129-192 are represented by the tertiary bitmap (if used)

2.3.2. Data element presence indication

The presence of a data element is indicated by setting the corresponding bit in the bitmap to 1. If the bit is 0, the data element is not present in the message.

Here's an example of how to work with data elements using jPOS:

import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOException;

public class DataElementExample {
    public static void main(String[] args) throws ISOException {
        ISOMsg message = new ISOMsg();
        message.setMTI("0100");
        
        // Set some fields
        message.set(2, "1234567890123456"); // Primary Account Number
        message.set(3, "000000"); // Processing Code
        message.set(4, "000000010000"); // Transaction Amount
        
        // Check if a field is present
        System.out.println("Field 2 present: " + message.hasField(2));
        System.out.println("Field 5 present: " + message.hasField(5));
        
        // Get field value
        System.out.println("Field 2 value: " + message.getString(2));
        
        // Print all fields
        for (int i = 0; i <= 128; i++) {
            if (message.hasField(i)) {
                System.out.println("Field " + i + ": " + message.getString(i));
            }
        }
    }
}