jondavidjohn / payform

:credit_card: A library for building credit card forms, validating inputs, and formatting numbers.
https://jondavidjohn.github.io/payform/
Other
427 stars 81 forks source link

Problem with Visa cards? #55

Open PhilMDev opened 5 years ago

PhilMDev commented 5 years ago

It appears that Visa cards (starting with 4) are not validating properly if I include cardNumberInput. It formats the card number properly but when I tab out after entering 16 digits it removes the last digit. If I add a space at the end it validates the card number. If I remove the cardNumberInput setting it validates after 16 digits without error. And, without formatting, obviously.

If I test with MasterCard it works as expected including formatting.

Thanks for looking at this.

ddayguerrero commented 5 years ago

Hi @PhilMDev, looking into your issue and I'm not able to reproduce the error. Would you be able to provide me with a test Visa card number so that I can try this out?

PhilMDev commented 5 years ago

I tried several numbers. But you should be able to see this using 4111111111111111. I've taken three screen shots:

  1. This is the 4111... number entered. You can see all the digits and the validation doesn't work.
  2. This is the 4111... number after I tab out of the field. Notice that it lost the last 1.
  3. This is a default MC number. Validated properly.

I looked through your code and it appears that Visa allows something other than 16 digits. I played with your code a little to see if I could fix the issue and I couldn't.

Thank you! full number not validated deleted digit after tab mc validated properly

PhilMDev commented 5 years ago

One other thing I just noted. When entering a Visa card number the routine adds a space after I enter the last digit. When I enter the MC number it doesn't. It stops after the 16th digit.

And on the Visa number, if I backspace to delete the extra space it deletes the last digit!

Thanks!

ddayguerrero commented 5 years ago

Thanks for the examples! It seems like we do have something weird going on with the pre-formatting of Visa cards. This might be tied to the fact that we allow 19 digit Visa card numbers.

If this is urgent, perhaps you can trim the user's input for now. WDYT? I can look into an elegant solution.

PhilMDev commented 5 years ago

Thank you for your response. It certainly is not urgent. For right now I just turned off the formatting. That works just fine. Not as pretty, but it works! If you should be able to come up with a fix please let me know.

Thanks for all your hard work!

warksit commented 5 years ago

Is there any resolution of this as just come up against it? I realiase I can turn off formatting but would prefer not to.

eduarguz commented 5 years ago

I am having the same issue here... How happens that the live demo works with "4111 1111 1111 1111", but when I try the same (and other visa cards) the input allows us to keep entering more numbers? that is weird :/

Demo https://codesandbox.io/embed/wz609mw258

Try with "4111 1111 1111 1111" and keep adding 1's

Is there a way to prevent further chars in our end?

f1729 commented 5 years ago

@eduarguz I have exactly the same problem, I have not been able to solve it, the strange thing is that in the web demo of the library the error is not, maybe the demo has another version?

polpenaloza commented 5 years ago

I think the issue is here: https://github.com/jondavidjohn/payform/blob/master/src/payform.coffee#L124 I reverted back to version v1.2.5. before it was length: [13, 16], not sure why they added 19 to the combo. Is there a way to instruct the library to use just the first 2?

f1729 commented 5 years ago

@polpenaloza apparently now visa supports 19 characters, https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2016/november/prepare-for-19-digit-credit-cards/