Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture credit card information from card reader into an uneditable text field

I'm newbie in terms of Javascript. Here's my problem:

I wish to capture credit card information from a card reader and then process it. So far, I've been able to capture dummy credit card data in an HTML textbox field - its no rocket science actually, 'cos the card reader input is just a set of keyboard events when a card is swiped through a card reader. The issue is that it works only when there is a cursor focus on a text field. If i turn the textfield into a read only box, it doesn't work - which is my exact requirement. I should be able to mask the input, show a couple of *s and I should be able to make the field non-editable. I'm hoping this could be done using a transparent div placed on the textbox - but I have no idea how that can be achieved.

I'm open to other ideas too.

like image 326
trishulpani Avatar asked May 10 '12 20:05

trishulpani


People also ask

How do you capture credit card information?

How to capture credit card information? A business needs a merchant account with a payment processor that offers storing of cardholder's information to keep it on file. Payment processors enable businesses to charge a credit card on file without showing its account number.

How do you send credit card information securely?

Send by Fax Sending credit card information through fax does not pose much of a risk from hackers. When data gets faxed over the telephone lines, even tapping the phone lines will not yield anything. You don't need to worry much about your credit card information being intercepted while in transit.

Can you keep credit card details on file?

PCI-DSS requirements state that cardholder data can only be stored for a “legitimate legal, regulatory, or business reason.” In other words: “If you don't need it, don't store it.”

Can card readers steal information?

Although banks claim that RFID chips on cards are encrypted to protect information, it's been proven that scanners—either homemade or easily bought—can swipe the cardholder's name and number. (A cell-phone-sized RFID reader powered at 30 dBm (decibels per milliwatt) can pick up card information from 10 feet away.


1 Answers

You can use javascript to set a disabled text field's value, and to get keystroke event data through document.onkeydown = function(e) { ... }. No need for hidden divs.

I assume you have other fields on your page, which will make it difficult to know when to capture the card reader data. Are you fortunate enough that your credit card reader sends some unique first character(s) so you know the keyboard events are coming from the reader and not user keystrokes? If so, then you can listen for those particular key strokes so you don't have to worry about setting focus. Otherwise maybe consider a button like "Read Credit Card" that has an on("click") function set to read the next xx digits.

Here's some debugging code you can use to see if your reader sends any unique characters that you can listen for:

document.onkeydown = function(d) {
    console.log( d.which ? d.which : window.event.keyCode);
};

It's conceivable that there's some other unique event information when the reader is used. Maybe check the device's manual.

like image 122
ZachB Avatar answered Sep 21 '22 05:09

ZachB