Hacker News new | past | comments | ask | show | jobs | submit login
How to read CC data from MagTek reader into web form?
1 point by s1mpl3 on Aug 10, 2017 | hide | past | favorite | 4 comments
I'm not looking to use Square.

I know about Jeffrey Malone and MagRead.

I also know about 'node-hid'.

I'm just looking for an easy way to swipe a credit card, and just print the data in a web form so you don't have to actually manually type the cc number, expir date, etc. Is this possible?




Hi s1pml3, yes, it's possible. Check out https://jsfiddle.net/KurtWM/tgeWn/

phppointofsale.com uses that code. Check out their demo. They swiping cards and breaking out the code into separate input fields.


Interesting, that's really useful. But, assuming I have MagTek connected via USB to the computer, how does this code "listen" for the swipe? It looks like it can handle parsing the data just fine, but my question is how to get the data from the swipe into the javascript for parsing


The MagTek reader acts as a USB HID (aka a keyboard). When the cursor focus is put on a text field and you swipe a card, the MagTek device acts as if someone typed each character into the field. Then the javascript detects that and parses it out


omg i see. That makes a lot of sense. Will test this out. Thanks a lot :)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: