Card Transaction Authorization
Write a program to authorize credit card transactions using a simplified version of interchange message as input and output. Note that you do not need knowledge of standard ISO 8583 to complete this test.
The input message is made up of the following parts:
A Message Type Indicator
A bitmap that indicates the presence of fields 3. Data elements, the actual data fields
Message Type Indicator
Message Type indicator is a 4-digit numeric field. Possible message types are
0100 - Authorization request message 0110 - Authorization response message
Bitmap
This field is a 2-character lower case hex encoding of a 1-byte bitmap value, indicating which data elements are present. Example:
c8 represents 11001000 which means that, data elements, bit 1, bit 2 and bit 5 are provided in this message.
Data Elements
Data elements are actual information fields. Data elements have the following types:
NUMERIC(n)
Number field with fixed length n. This type can only contain 0-9 characters and must be left padded to n characters with zero(s).
For example, NUMERIC(6) field with a value of 10, 000010 will be populated into this field.
ALPHA(n)
Alpha numeric field with fixed length n. This type can only contain 0-9a-zA-Z and spaces and must be right padded to n characters with space(s).
For example, ALPHA(6) field with a value of CITY, "CITY ” will be populated into this field.
LLVAR
ALPHA field with variable length. This field has two separates section, the first two characters are NUMERIC(2) indicating length of actual following ALPHA value.
For example, LLVAR has value 04CITY. Where "CITY" is the value and "04" is its length, 4. Here are the data elements and their type definition
Bit Type Data Element Mandatory
1 LLVAR PAN (credit card number) - 14-19 digit PAN Yes
2 NUMERIC(4) Expiration Date (MMYY) Yes
3
NUMERIC(10)
Transaction amount in cents (e.g. for 200 When Zip code is not provided, a transaction is approved if amount is less than $100 Expiration Date is greater than the current date
Input and Output
Your application should allow running using command line and accept an input file name as argument or allow piping file content. The input file will contain messages with a message per line (a line ends with \n). For example:
0100e016411111111111111112250000001000
0100e016401288888888188112250000011000
0100ec1651051051051051001225000001100011MASTER YODA90089
0100e016411111111111111112180000001000
01006012250000001000
Let break down the first message
Application will print out the authorization response messages, with one message per line:
Type Bitmap PAN Exp. Amount
0100 e0 164111111111111111 1225 0000001000
0110f016411111111111111112250000001000OK
0110f016401288888888188112250000011000DE
0110fc16510510510510510012250000011000OK11MASTER YODA90089
0110f016411111111111111112180000001000DE
01107012250000001000ER
The following can be assumed of the input:
Input will always be in a correct format for parsing with a correct type. Transaction amount is a positive number
PAN is always between 14-19 digits