pyiso8583

4.0.1 · active · verified Thu Apr 16

pyiso8583 is a Python package designed for serializing and deserializing ISO8583 data. It converts raw ISO8583 byte streams into Python dictionaries and vice-versa, supporting various custom specifications for field lengths, data encoding (like BCD, ASCII, EBCDIC), and field types (fixed, LLVAR, LLLVAR). The current version is 4.0.1, with releases typically occurring a few times a year, indicating active development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to decode a raw ISO8583 message using the default_ascii specification, modify some fields, and then encode it back into a raw bytearray. It uses `iso8583.decode` and `iso8583.encode` functions.

import iso8583
from iso8583.specs import default_ascii as spec
import pprint

# Example ISO8583 raw message (MTI '0200', Field 2 '1234567890', Field 12 '123456')
encoded_raw_message = b'02004000000000000000101234567890123456'

# Decode the message
decoded_data, encoded_fields_info = iso8583.decode(encoded_raw_message, spec)
print("Decoded data:")
pprint.pprint(decoded_data)

# Modify the decoded message for a response (e.g., '0210' response, add field 39)
decoded_data['t'] = '0210'
decoded_data['39'] = '00'

# Encode the modified message back to raw bytes
response_raw_message, response_encoded_fields_info = iso8583.encode(decoded_data, spec)
print("\nEncoded response raw message:")
print(response_raw_message)
print("\nEncoded response fields info:")
pprint.pprint(response_encoded_fields_info)

view raw JSON →