verygoodsecurity / vgs-collect-js

VGS Collect.js script loading module
https://www.verygoodsecurity.com/
7 stars 14 forks source link

card-number validation issue with vgs-collect version update #78

Open deannashih opened 4 months ago

deannashih commented 4 months ago

Expected Behavior

Previously, we've been testing with 4242 4242 4242 4242 using the vgs collect version 2.15.0 and the validations in place in line with your documentation:

                   validations={['required', 'validCardNumber']}

This stopped the number at 16 chars max length. Without changing code, and only by upgrading to vgs collect 2.22.0, we are now able to type in 3 extra chars.

Screenshot 2024-05-02 at 3 10 57 PM

If it's a 16-digit card, it should stop at 16 digits.

Current Behavior

I noticed in your test data documentation that the length of 19 is apparently accepted: https://www.verygoodsecurity.com/docs/vgs-collect/test-data

Sanity checked myself by trying out a Mastercard number that only allows 16 chars per your documentation table.

Screenshot 2024-05-02 at 3 12 19 PM

While it seems like per your documentation the length of 19 is expected for certain Visa cards, to us it's a bug because previously it stopped the 4242... card at 16 without allowing room for more characters to be typed in.

I don't know what happened between 2.15.0 and 2.22.0 to cause this. In the same way that you're able to deduce that the 2222 is a Mastercard number and stops at 16 digits, can the same not be done for certain Visa cards?

Possible Solution

If there isn't a way to determine by the first few numbers that it's a Visa success card, or whether it should be a 16- or 19-digit card, what is the best way to stop 16-digit cards from reaching extra 3 digits?

Steps to Reproduce (for bugs)

  1. Be on VGS Collect version 2.22.0
  2. Use validations validations: ['required', 'validCardNumber'], type: 'card-number
  3. Try standard Visa success test card 4242 4242 4242 4242 then see if you can type extra 424

Context

Your Environment