6

I need to get Track 1 and Track 2 data off magnetic cards and send them over the network to a waiting server. What is an easy way to get the track data from a USB HID magnetic card reader?

In case it helps, I have a MAGTEK Mini Swipe Magnetic Strip Reader (part no. 21040140)

I'm OS agnostic -- a solution for Windows, Mac or Linux would be great. Preferably no .NET, but if that's the easiest way I'll go for it.

What do you all think?

Thanks!

BuyTheBid
  • 277
  • 1
  • 3
  • 11

2 Answers2

4

Every card reader I've seen has had a keyboard emulator, so you swipe the card and it sends characters through the keyboard buffer. Looks like this one also does that (documentation : http://www.magtek.com/documentation/public/99875206-16.01.pdf)

Page 14 describes the data sent after a swipe, which is again, fairly standard across card readers:
[Tk1 SS] [Tk1 Data] [ES] [Tk2 SS] [Tk2 Data] [ES] [Tk3 SS] [Tk3 Data] [ES] [CR]

So your track one data starts with % and ends with ?
Track two data starts with ; and ends with ?

I noticed the question was tagged credit-card though, so it would be worth making sure you know the consequences of sending raw card-data across a network (even an internal network). Take a look at the Payment Card Industry Data Security Standards (PCI-DSS) : https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml


There is a demo program for that specific reader that comes with VB source.
http://www.magtek.com/support/software/demo_programs/usb_swipe_insert.asp

PaulG
  • 13,871
  • 9
  • 56
  • 78
  • Thanks for your response. Unfortunately, the specific device I have -- part # 21040140 -- is not covered by the document you linked (check "Hardware Configurations" table on p. 3). The document that covers this device is http://www.magtek.com/documentation/public/99875191-12.01.pdf – BuyTheBid Oct 12 '10 at 21:14
  • Actually I've realized that I can reset this device to KB mode -- just takes a little playing around with their USBMSR Demo app available on the support pages. Nonetheless a simple HID solution would be nice so that a keyboard could be used too. Thanks! – BuyTheBid Oct 12 '10 at 21:40
  • @BuyTheBid. There is a demo app (with source) available too. I updated the answer. – PaulG Oct 12 '10 at 21:44
  • Just for reference, I have the 21040102 and keyboard emulator mode is NOT supported on that model. – Brian Knoblauch Aug 10 '11 at 17:25
  • @BrianKnoblauch, I have the same model and was able to have it work in keyboard emulation mode. – Varun Madiath Jul 29 '13 at 05:00
  • I realize this is an old post but 21040145 is the keyboard emulator equiv version of 21040140 (last # different). I can't think of any reason there couldn't be a KB driver wrapper for the actual HID component. That would be very handy so I don't need two readers. – Adam Plocher Oct 09 '15 at 05:20
0

Easiest way to download the Cab file from this link & include it in the project directory in a "magtek" folder.

http://www.magtek.com/support/software/demo_programs/card/usb_hid_swipe_readers/read_parse.asp

Add this code in aspx file after tag (change cab file src as per )

   <object id="USBHID" classid="CLSID:22571E97-956A-4CDD-AF8D-AE9C26597683" codebase="magtek/99510060.CAB#version=1,13,0,2">
    </object>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
        $(function () {
$('#txtNameFirst').focus();  // Focus on a textbox is required
 USBHID.PortOpen = true;
            if (USBHID.PortOpen == false) {
                $('#<%= lblStatus.ClientID %>').text('Could not open MagTek reader');

            }
            else {
                $('#<%= lblStatus.ClientID %>').text('Please Swipe a card');
            }
    });
 $("#txtNameFirst").bind('change', function () {

var CCData = $("#txtNameFirst").val();  // CCData will contain the complete credit card data in a string.

alert(CCData);
$("#txtNameFirst").val(CCData.split('^')[1].split(' ')[0]);
                        $("#txtNameLast").val(CCData.split('^')[1].split(' ')[1]);
                        $("#txtCCNo").val(CCData.split('^')[0].substring(2, 18));
                        //alert('  Split1: ' + CCData.split('^')[1] + '  Split2: ' + CCData.split('^')[2]);
                        //alert('parsing good!');
                        $("#txtExpiDt_RoutingNo").val(CCData.split('^')[2].substring(2, 4) + '/' + CCData.split('^')[2].substring(0, 2));
});
    </script>

As per the above code I have added focus on a text box . After swiping the card focused textboxes automatically show the complete credit card data string.

panky sharma
  • 2,029
  • 28
  • 45