Skip to main content
iso8583sim.core.types

ISO8583Version

Bases: Enum ISO 8583 protocol versions | V1987 | '1987' | | V1993 | '1993' | | V2003 | '2003' |

FieldType

Bases: Enum Field data types in ISO 8583 | NUMERIC | 'n' | | ALPHA | 'a' | | ALPHANUMERIC | 'an' | | BINARY | 'b' | | SPECIAL | 's' | | TRACK2 | 'z' | | LLVAR | 'll' | | LLLVAR | 'lll' |

CardNetwork

Bases: Enum Card network identifiers | VISA | 'VISA' | | MASTERCARD | 'MASTERCARD' | | AMEX | 'AMEX' | | DISCOVER | 'DISCOVER' | | JCB | 'JCB' | | UNIONPAY | 'UNIONPAY' |

MessageClass

Bases: Enum Message class identifiers (position 2 of MTI) | AUTHORIZATION | '1' | | FINANCIAL | '2' | | FILE_ACTIONS | '3' | | REVERSAL | '4' | | RECONCILIATION | '5' | | ADMINISTRATIVE | '6' | | FEE_COLLECTION | '7' | | NETWORK_MANAGEMENT | '8' |

MessageFunction

Bases: Enum Message function identifiers (position 3 of MTI) | REQUEST | '0' | | RESPONSE | '1' | | ADVICE | '2' | | ADVICE_RESPONSE | '3' | | NOTIFICATION | '4' | | NETWORK_REQUEST | '8' | | NETWORK_RESPONSE | '9' |

MessageOrigin

Bases: Enum Message origin identifiers (position 4 of MTI) | ACQUIRER | '0' | | ACQUIRER_REPEAT | '1' | | ISSUER | '2' | | ISSUER_REPEAT | '3' | | OTHER | '4' | | OTHER_REPEAT | '5' |

FieldDefinition

Definition of an ISO 8583 field

ISO8583Message

Represents a complete ISO 8583 message

message_class

Get message class from MTI

message_function

Get message function from MTI

message_origin

Get message origin from MTI

ISO8583Error

Bases: Exception Base exception for ISO 8583 errors

ParseError

Bases: ISO8583Error Raised when parsing fails

ValidationError

Bases: ISO8583Error Raised when validation fails

BuildError

Bases: ISO8583Error Raised when message building fails

Functions

get_field_definition()

Get field definition considering network and version specifics. Parameters
int
required
The field number to look up
CardNetwork | None
default:"None"
Optional card network for network-specific definitions
ISO8583Version
default:"ISO8583Version.V1987"
ISO8583 version
FieldDefinition | None
FieldDefinition if found, None otherwise
Priority order:
  1. Network-specific definition
  2. Version-specific definition
  3. Standard field definition
Note: Results are cached for performance (lru_cache with 512 entries).

is_valid_mti()

Check if MTI is valid. Parameters
str
required
Message Type Indicator string
bool
True if MTI is valid, False otherwise
Validates:
  • Length is 4 digits
  • All characters are numeric
  • Each position contains valid values

get_network_required_fields()

Get list of required fields for a specific network. Parameters
CardNetwork
required
Card network
list[int]
List of required field numbers

get_field_format_pattern()

Get network-specific field format pattern. Parameters
CardNetwork
required
Card network
int
required
Field number
str | None
Regex pattern string if exists, None otherwise

is_binary_field()

Check if field is binary type. Parameters
FieldDefinition
required
Field definition
bool
True if field is binary, False otherwise