Mastercard IPM to CSV


Install and Test

Create the virtualenv

virtualenv --no-site-package venv

Install the package mciutil in virtualenv

source venv/bin/activate

pip install mciutil

Make testing project

mkdir -p test-ipm/data/binary
cd test-ipm
cp ../TT112T0.2016-xx-xx-xx-xx-xx data/binary/

Convert the file to ascii format

mideu convert -s ascii data/binary/TT112T0.2016-xx-xx-xx-xx-xx

Extract the converted file to csv file

mideu extract data/binary/TT112T0.2016-xx-xx-xx-xx-xx.out --csvoutputfile data/binary/TT112T0.2016-xx-xx-xx-xx-xx.csv

Remove the mask on pan number

Open the mciutil.py and file the _mask_pan method

Change this method to

def _mask_pan(field_data):
    return field_data

Fix the UnicodeError

Step 1

Open the mciutil.py and add the following code

import chardet

And then find the method _get_de43_fields and change the code

field_match = re.match(de43_regex, de43_field.decode())

To

char_detect = chardet.detect(de43_field)
field_match = re.match(de43_regex, de43_field.decode(char_detect['encoding']))

Step 2

Open the cli/common.py and change the code (Line 150 in filter_dictionary method)

return_dictionary[item] = dictionary[item].decode()

To

return_dictionary[item] = dictionary[item]

Step 3

Install the chardet package

pip install chardet