Skip to main content

Python package for working with payment card systems

Project description

Cardutil is a python package for working with payment card systems.

  • Supports python 3.6 and later.

  • The core library has zero package dependencies.

https://img.shields.io/pypi/l/mciutil.svg| https://img.shields.io/pypi/v/mciutil.svg| https://img.shields.io/pypi/wheel/cardutil.svg| https://img.shields.io/pypi/implementation/cardutil.svg| https://img.shields.io/pypi/status/cardutil.svg| https://img.shields.io/pypi/dm/cardutil.svg| https://img.shields.io/pypi/pyversions/cardutil.svg

Quickstart

Install

$ pip install cardutil

ISO8583 messages

Read an ISO8583 message returning dict:

from cardutil import iso8583
message_bytes = b'1144\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00164444555566667777'
message_dict = iso8583.loads(message_bytes)

Create an ISO8583 message returning bytes:

from cardutil import iso8583
message_dict = {'MTI': '1144', 'DE2': '4444555566667777'}
message_bytes = iso8583.dumps(message_dict)

Mastercard IPM files

Read an IPM file:

from cardutil import mciipm
with open('ipm_in.bin', 'rb') as ipm_in:
    reader = mciipm.IpmReader(ipm_in)
    for record in reader:
        print(record)

Create an IPM file:

from cardutil import mciipm
with open('ipm_out.bin', 'wb') as ipm_out:
    writer = mciipm.IpmWriter(ipm_out)
    writer.write({'MTI': '1111', 'DE2': '9999111122221111'})
    writer.close()

cli tools

The following command line interface tools are included in the package

  • mci_ipm_extract converts Mastercard IPM files to csv

  • mci_ipm_param_encode changes the encoding of a Mastercard IPM parameter files

Contributing

install

$ git clone https://bitbucket.org/hoganman/cardutil.git
$ pip install -e ".[test]"

test

$ pytest

release

$ bumpversion (patch:minor:major)
$ git push --follow-tags

docs

$ pip install -e ".[docs]"
$ make html -C ./docs
$ open ./docs/build/html/index.html

acknowledgements

The python hexdump library is embedded in this package. Many thank to Anatoly Techtonik <techtonik@gmail.com> This library is a life saver for debugging issues with binary data. Available at Pypi:hexdump.

The python ISO8583-Module library was originally inspired by the work of Igor V. Custodio from his original ISO8583 parser. Available at Pypi:ISO8583-Module.

Mastercard is a registered trademark of Mastercard International Incorporated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cardutil-0.1.4.tar.gz (22.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page