CarlRaymond / jquery.cardswipe

jQuery plugin for magnetic card readers
MIT License
115 stars 49 forks source link

Empty line results #25

Closed rainmedia closed 6 years ago

rainmedia commented 6 years ago

I have MSR90 USB 3-Track Magnetic Credit Card Reader. Ebay link. When I swipe the credit cards I get the following formats:

%B5217XXXXXXXXX&BONBONI.JOHNNYçMR &XXXXXXXXXXXXXXXXXXXX 199 :şXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXX19901:

%b4564XXXXXXXXXXXX&hargreaves.tımothy w &XXXXXXXXXXXXXXXXXXXXXXXXXXXXX000:Ş4564XXXXXXXXXXXX-XXXXXXXXXXXXXXXX0000:

But I don't get any result when I try demo-simple.html and demo-events.html

I only get the following output.

Card: Generic
Line1:
Line2:
Line3:

Have I got the wrong reader or do I need to add a Custom Card Parser?

console.log

IDLE -> IDLE
21:39:56.534 jquery.cardswipe.js:181 37: %
21:39:56.535 jquery.cardswipe.js:161 IDLE -> PENDING
21:39:56.539 jquery.cardswipe.js:181 66: B
21:39:56.539 jquery.cardswipe.js:161 PENDING -> READING
21:39:56.553 jquery.cardswipe.js:181 57: 4
21:39:56.554 jquery.cardswipe.js:181 57: 9
21:39:56.555 jquery.cardswipe.js:181 52: 4
21:39:56.557 jquery.cardswipe.js:181 51: 3
........
.....
CarlRaymond commented 6 years ago

Your scans look a little different that what the generic regex will recognize. I see a "ç" in the name, and a "ş" later on. I wonder if it's a character set encoding issue.

Here's something to try: In the file demo-simple.html, change the <form> tag to <form accept-charset="UTF-8"> or to <form accept-charset="ISO-8859-1">. Possibly that could make a difference.

rainmedia commented 6 years ago

Thank you for your reply Carl. The format that I posted above was generated on a notepad.

After your reply I changed my keyboard layout to English and restarted my PC and swiped the card it worked with most of the cards.

The form populated with correct data except the one below.

%BXXXXXXXXXXXXXXXX^HARGREAVES/TIMOTHY.MR           ^18112019420244000001  199      ?;XXXXXXXXXXXXXXXX=18112019420244019901?

I tested on the page demo-events.html with and without accept-charset="UTF-8" nothing changed.

This time I have the following output.

Card: Generic
Line1: XXXXXXXXXXXXXXXX^HARGREAVES/TIMOTHY.MR ^18112019420244000001 199
Line2:
Line3:

Please see the screenshot below https://i.imgur.com/p1tgekC.jpg

The only difference between two cards is: the number 199 has two spaces on the right and 6 spaces on the right. The rest of the format is same. Can you help me out with reading this type of cards? Thank you again.

CarlRaymond commented 6 years ago

The problem is the "." character in the cardholder name. All the card examples I used didn't have that.

I updated the built-in parsers to recognize it as an additional field called "honorific", and added your card sample as a unit test for each card (after changing the name to "PERSON\RANDOM.MR").

Download the latest version, and try your card again. Get it straight from GitHub, not NPM. If this works, I'll bump the version number and publish the update there.

rainmedia commented 6 years ago

Thank you so much. All the cards are working now. This script is lifesaver.