Demo API Reference

Interactive helpers for notebooks and exploration. Generated from the package docstrings.

iso8583sim.demo

Demo module with helper functions for notebooks and interactive use.

This module provides convenient functions for:

  • Pretty-printing ISO 8583 messages
  • Generating sample messages for different scenarios
  • Explaining message components

Functions

pretty_print(message: iso8583sim.core.types.ISO8583Message | str, show_raw: bool = False) -> None

Pretty print an ISO 8583 message.

Args: message: ISO8583Message object or raw message string show_raw: Whether to show the raw message bytes

explain_field(field_number: int, value: str | None = None) -> None

Explain a specific field’s definition and optionally its value.

Args: field_number: The field number to explain value: Optional field value to interpret

generate_auth_request(pan: str = '4111111111111111', amount: int = 1000, stan: str = '123456', terminal_id: str = 'TERM0001', merchant_id: str = 'MERCHANT123456 ', network: iso8583sim.core.types.CardNetwork | None = None) -> iso8583sim.core.types.ISO8583Message

Generate a sample authorization request.

Args: pan: Primary Account Number amount: Transaction amount in cents stan: System Trace Audit Number terminal_id: Terminal ID (8 chars) merchant_id: Merchant ID (15 chars) network: Optional network type

Returns: ISO8583Message object

generate_financial_request(pan: str = '4111111111111111', amount: int = 5000, stan: str = '654321', processing_code: str = '000000') -> iso8583sim.core.types.ISO8583Message

Generate a sample financial request (0200).

Args: pan: Primary Account Number amount: Transaction amount in cents stan: System Trace Audit Number processing_code: Processing code (default: purchase)

Returns: ISO8583Message object

generate_reversal(original: iso8583sim.core.types.ISO8583Message, new_stan: str = '999999') -> iso8583sim.core.types.ISO8583Message

Generate a reversal message for an original transaction.

Args: original: The original transaction message new_stan: New STAN for the reversal

Returns: ISO8583Message reversal

generate_network_message(message_type: str = 'echo') -> iso8583sim.core.types.ISO8583Message

Generate a network management message.

Args: message_type: Type of message - ‘echo’, ‘signon’, ‘signoff’, ‘key_exchange’

Returns: ISO8583Message object

generate_emv_auth(pan: str = '4111111111111111', amount: int = 10000, cryptogram: str = 'AABBCCDD11223344') -> iso8583sim.core.types.ISO8583Message

Generate an EMV chip card authorization.

Args: pan: Primary Account Number amount: Transaction amount in cents cryptogram: Application cryptogram (8 bytes hex)

Returns: ISO8583Message with EMV data

build_and_parse(message: iso8583sim.core.types.ISO8583Message) -> iso8583sim.core.types.ISO8583Message

Build a message to raw format and parse it back.

Useful for testing roundtrip.

Args: message: ISO8583Message to process

Returns: Parsed message

validate(message: iso8583sim.core.types.ISO8583Message | str) -> None

Validate a message and print results.

Args: message: ISO8583Message or raw message string

explain_emv(emv_hex: str) -> None

Parse and explain EMV data.

Args: emv_hex: Hex-encoded EMV TLV data