CarlRaymond / jquery.cardswipe

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

Success function not being triggered? #31

Open robp2175 opened 5 years ago

robp2175 commented 5 years ago

For some reason neither the success for nor the error function is being called. I have reviewed #27 and #28, but neither were helpful to me. The information from the card has nothing in line 1, line 2 = ;004089025410=? and line 3 is empty. I might just be dense, but I am not sure where to look. The console.log only shows the output like


59: ;
IDLE -> PENDING2
 48: 0
PENDING2 -> READING
48: 0
52: 4
48: 0

etc.

I would appreciate any assistance. 
robp2175 commented 5 years ago

Forgot to mention, that I am using simple-demo.html without any changes and the defaultSuccessCallback is firing with the alert var text = ['Line 1: ', cardData.line1, '\nLine 2: ', cardData.line2, '\nLine 3: ', cardData.line3].join('');

CarlRaymond commented 5 years ago

I tried that sequence in a test case, and the generic parser matched it.

The fact that you're seeing an alert means that the success callback was invoked - that's where the alert comes from. But if it shows literally var text = ['Line 1:... then the code isn't getting parsed properly. What browser are you using?

JamoCA commented 5 years ago

I believe that the function on this page: https://github.com/CarlRaymond/jquery.cardswipe/blob/master/demo-simple.html

Since there isn't any "complete" method, it should be replaced with "success":

Should be updated from:

$.cardswipe({
    firstLineOnly: false,
    complete: success,
    parsers: [ "visa", "mastercard", "amex", "discover", "generic" ],
    error: error,
    debug: true
});

to this:

$.cardswipe({
    firstLineOnly: false,
    success: success,
    parsers: [ "visa", "mastercard", "amex", "discover", "generic" ],
    error: error,
    debug: true
});

As soon as I changed the demo-simple.html example to use success instead of complete, it worked. (I initially thought something else was broken until I took the time to troubleshoot why it wasn't displayed data like the demo-events.html example was.)