Skip to content

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

ISO 8583 Transaction Generator (FastAPI)

No pyiso8583 — the packer (iso8583_packer.py) is hand-rolled: builds the 64-bit primary bitmap by bit-shifting field numbers, and encodes/decodes each field per its ISO 8583 format type (n / a / an / ans, fixed or LL/LLL variable length).

Setup

pip install fastapi uvicorn
uvicorn main:app --reload --port 8000

Endpoint

  • GET /transaction/generate — single endpoint. Every hit randomly generates one of four scenarios and returns it packed: MTI, bitmap (hex), per-field breakdown, and raw message string.

    • authorization (MTI 0100, processing code 000000)
    • financial (MTI 0200, processing code 010000)
    • balance_inquiry (MTI 0100, processing code 310000)
    • error — either an invalid PAN (bad Luhn check digit, response code 14) or a missing mandatory field (randomly dropped from DE2/3/4/7/11/37/41/49, response code 30)

PAN generation

DE2 = random BIN (6 digits) + random 9-digit body from a fixed pool + Luhn check digit. ~85% of the time the check digit is correct; ~15% it's deliberately wrong to simulate a bad card number. BIN pool spans Visa/Mastercard/RuPay test ranges.

STAN / RRN

DE11 (STAN) = current time as HHMMSS. DE37 (RRN) = BIN + STAN (12 chars, matches DE37 length).

Example response

0100723844810AE0800016424242124345675500000000000016261908170831120831120831120817541105100087682360342424208311214TERM7260MERCH442096    Test Merchant 77/Kathmandu/NP           840

Notes

  • Only primary bitmap (fields 1–64) is implemented — no secondary bitmap (field 1 → 65-128).

Releases

Packages

Contributors

Languages