Skip to content

Autoconnect MSR-100 Magnetic Stripe Card Reader and returns CardInfo on Swipe event.

License

Notifications You must be signed in to change notification settings

jarmyo/MSR-100-Magnetic-Stripe-Parser

MSR-100-Magnetic-Stripe-Parser

Codacy Badge CodeFactor .NET

Autoconnect MSR-100 Magnetic Stripe Card Reader Throught RS232 Port and returns MagneticCardInfo class with data on Swipe event.

This Reader:

Reader Device

ISO 7813 For financial transaction cards

https://en.wikipedia.org/wiki/ISO/IEC_7811

Install

Install-Package MSR-100-Magnetic-Stripe-Parser -Version 1.0.1

or

dotnet add package MSR-100-Magnetic-Stripe-Parser --version 1.0.1

How to use

Instance a MSR100Controller object, attach a custom method to OnCardSwiped event.

Constructor has two parameters:

  • PortName is a optional string parameter that will override the port name, default is COM1
  • baudRate is a optional integer parameter that will override the baud rate, default is 9600

MSR100Controller Class has one public event:

  • OnCardSwiped is event that will fire every time a card is swiped on the device, return an object of type MagneticCardInfo

Use Example

    static void Main(string[] args)
    {
            using (var controller = new MSR100Controller())
            {
                    controller.OnCardSwiped += Controller_OnCardSwiped;
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
            }
    }

    private static void Controller_OnCardSwiped(MagneticCardInfo cardinfo)
    {
            Console.WriteLine("Card Swiped!");
            Console.WriteLine($"PAN: {cardinfo.Track1.PAN}");
            Console.WriteLine($"NN: {cardinfo.Track1.Name}");
            Console.WriteLine($"ED: {cardinfo.Track1.ExpirationDate}");
            Console.WriteLine($"SC: {cardinfo.Track1.ServiceCode}");
            Console.WriteLine($"DD: {cardinfo.Track1.DiscretionaryData}");
    }        

Contributing

  • Bug Reporting: You can contribute opening issues.
  • Bug Fixing: Fix it and help others and write some tests to make sure that everything are working propertly.
  • Improving: Open an issue and lets discuss it.

Reader Device