Iso8583 message structure
alloha.
at last i have been able to get my lazy behind to write a blog post on this .
About time :) .
This will be the first in a series about parsing iso8583 financial messages using erlang .
we will get to know
about iso8583 and the message structure,
receiving iso 8583 messages over the wire using erlang tcp server and parsing the message .
parsing those messages in various formats(text(acii),binary,custom format).
Here we go .
First off what is iso8583 ?
Simply put it is a protocol which specificies the content of financial transaction done with payment cards in the form of request/response messages as well as info on how to process the financial transaction.
more general info can be found on the wikipedia page about it here .
What are the components of an iso message ?
- optional header . optional zero padded header showing size of message.header size is known in advance by receipient and is specified by sender .Usually contains size of message ony but may contain size of header + size of message . An example of a header is 0158 which means the content of the message(mti+bitmap+data elements) is 158 bytes
- mti(message type indicator). A 4 digit number showing info about the message . each digit shows some info about the message .
example of an mti is 1200 meaning with the meaning below .
1 - first digit is message version - 1 message class means 1993 version
2 - second digit specifies the message class(purpose of message) eg. authorization,reversal.etc.. 2 means financial message
0 - third digit specifies message function(how the message should flow within system) -eg. requests,advices,etc.. 0 means request
0 - fourth digit specifies message origin (where is the message coming from ) eg. from acquirer,issue etc.. 0 means acquirer - bitmap(primary or secondary).A 16/32 hexadecimal number showing the presence or absence of data elements . a bitmap can be a primary or a secondary bitmap .
primary means presence of fields from 1-64 .
secondary means the presence of presence of fields greater than 64 means 64-128 .
the bitmap has to be converted from hex form to binary form where each binary digit represent presence or absence of a data element .if if the first digit of the bitmap in binary form is 1 it means bitmap has fields greater than 64 which makes it a secondary bitmap .
An example of a bitmap is F230040102B000000000000004000000 meaning fields 1,2,3,4,7,11,12,22,32,39,41,43,44,102 are present and bitmap is a secondary bitmap due to fields greater than 64 being present . - data elements . These are the actual contents of the financial message such as the amount of the transaction,currecy,transaction type(balance enquiry,withdrawal,etc..),card number .
there are 128 data elements from 1-128 .
What variants of iso messages are available?
There are a few differnt variants of the iso8583 messaging format but the most common ones are (1987 format/1993 format /2003 format ).
the specification of the various variants specify the position of the various data elements as well as what format the message will be transmitted in .
proprietery/custom ones also exist based on the above ones which may be cusom format agreed to be used between two parties or internal format for one party.
How are messages processed ?
Financial messages consist of request/response messages are sent between two entities to process financial transactions .
a tcp connection or other connection type(UDP, X.25, SDLC, SNA,ASYNC, QTP, SSL, HTTP,custom) is opened between the two entities .
Some handshake mechanism may be done to prepare both parties for sending messages .
Messages are sent consisting of a request/response message .
Depending on connection type a persistant connection may be kept open or a connection may be closed and reopened later for subsequent messages to be sent and received.
What to keep in mind when processing messages ?
- Message format (ascii,binary,custom format).eg 1993 acii,1993 binary.in what format the message will be transmitted in as well as rules to encode/decode the message .
- Wire protocol (TCP/IP,UDP, X.25, SDLC, SNA,ASYNC, QTP, SSL, HTTP,custom protocol )how a message is transmitted over the wire.
- Message flow (e.g., send request for authorization, wait for response, retransmit, reversal).Various states the message may be in .
- Optional beginning and ending headers showing size of message and/or headers themeselves .
Enough talking . An example please ???
The assumption is that we are using iso 1992 iso8583 ascii specification for specifying message rules for encoding decoding messages .the specification will also show the data type of a field(number,string,hex,etc..),where it is variable length or not or whether it has an optional padding or not .
We will deconstruct the iso message below as an example and show the optional header,mti,bitmap,data elements in the message .
the optional header will be assumed to be 4 bytes long excluding the size of the header itself.
Consider the iso message below
01581200F230040102B000000000000004000000
1048468112122012340000100000001107221800
000001161204171926FABCDE123ABD06414243
000termid1210Community106A5DFGR1112341234234
this is breakdown of the message below from left to right
- 0158 -> header length(4 byte or digit header). this show the length of the message is 158 digits excluding the header
- 1200 -> mti
- F230040102B000000000000004000000 -> fld 1 bitmap(secondary in this case cuz F converted into 4 digit binary number is 1111 meaning bitmap contains secondary )
- 104846811212 -> fld 2 primary account number(prefix header showing length of fld 2 is is 10 digits)
- 201234 -> fld3 processing code
- 000010000000 -> fld 4 transaction amount
- 1107221800 -> fld 7 Transmission date & time
- 000001 -> fld 11 rrn
- 161204171926 -> fld 12 time local transaction
- FABCDE123ABD -> fld 22 pos data code
- 06414243 -> fld 32 Acquiring institution identification code(prefix header showing length of fld32 is 6 digits)
- 000 -> fld 39 response code
- termid12 -> fld 41 terminal id
- 10Community1 -> fld 43 location data(prefix header showing length of fld43 is 10 digits)
- 06A5DFGR -> fld 44 additional response code (prefix header showing length of fld32 is 6 digits)
- 1112341234234 -> fld 102 account number
this is a short summary of the basics of iso .
more info can be on the wikipedia page if you want to delve more deeply into it .
next post will be about using erlang to extract the various component (mti,bitmap,data elements) out of a message using a spec .