How to parse credit card track data from magnetic swipe

Posted on 2012-09-19
Last Modified: 2012-10-04
I recently took over a project involving "repairing" a vb6 project that is a Point of Sale System. I'd rather file my teeth than deal with vb6 but I'm given no choice. The client complains that they can not "swipe" credit cards and need to enter each field by hand when accepting credit cards...

Credit Card Number & Expiration Date

I know that credit card track data is in plain text and can easily be viewed by swiping into any text editor. But I am unable to see a commonality across different credit cards. i.e. Visa, Mastercard, Amex, Discover etc.

Is there a set way of parsing this information that I can get my hands on? Is there an ocx that does it already somewhere. I want to be able to capture the info from the swipe and automate the population of these fields to save the end user data entry time.

Any help would be appreciated.
Question by:edjucatable
    LVL 56

    Accepted Solution

    There are three tracks on a card.  The first two are the card data and can be in one of two formats.  Format "A" is up to the issuer of the card, "B" is standard and has the following:

    Format code="B" -- 1 character (alpha only)
    Primary account number -- up to 19 characters
    Country code -- 3 characters
    Name -- 2-26 characters
    Expiration date or separator -- 4 characters or 1 character
    Discretionary data -- enough characters to fill out maximum record length (79 characters total)
    Longitudinal Redundancy Check (LRC) -- 1 character

     There's some seperators in there as well.  

     So is this a feature that was working in the software or something new they want added?  What country is this in and what reader are you using?


    Author Closing Comment

    Thanks Jim for the help. I'm new to experts exchange so after waiting a few days I ended up testing a ton of cards into note pad and deciphered enough to make the app work. It was something they originally wanted from the original developer and it never worked because his or her way or parsing only worked for certain cards. It's been over a week now and they haven't encountered anything that deviates from what we found.

    Thank you again!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
    As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now