Skip to content

A library to read and parse data coming from magnetic card readers, following the ISO7811.

License

Notifications You must be signed in to change notification settings

frankandoak/php-magstripe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-magstripe

Build Status

A library to read and parse data coming from magnetic card readers, following the ISO7811. Inspired by python-magstripe.

Install

Require the package in composer.json

"require" : {
    "frankandoak/php-magstripe" : "1.*"
}

Usage

<?php

        $magStripe = new MagStripe('%B4242424242424242^SURNAME/FIRSTNAME I^15052011000000000000?;4242424242424242=15052011000000000000?');
        // Then use the getters to fetch the info
        echo $magStripe->getAccount(); // 4242424242424242
        echo $magStripe->getName(); // FIRSTNAME I LASTNAME
        echo $magStripe->getExpYear(); // 15
        echo $magStripe->getExpMonth(); // 05
        // Raw tracks are available as an array too:
        $tracks = $magStripe->getTracks();
        echo $tracks[0]; // B4242424242424242^SURNAME/FIRSTNAME I^15052011000000000000
        echo $tracks[1]; // 4242424242424242=15052011000000000000

Tests

Tests are run with php unit, validating some benchmark credit card numbers and invalid values. To run them, just run make test.

License

MIT

About

A library to read and parse data coming from magnetic card readers, following the ISO7811.

Resources

License

Stars

Watchers

Forks

Packages

No packages published