React-stripe-elements: ZIP validation fails when re-entering CC number

Created on 13 Mar 2018  路  6Comments  路  Source: stripe/react-stripe-elements

Summary

Using the single UI element, I am able to submit a card without inputting a zip code, even though the zip code is required. This happens when receiving a stripe error on the first submission, and then subsequently submitting valid info without a postal code. I suspect that this might be related to #158 because the steps to reproduce are very similar (so I am not sure if this is a react-stripe-elements issue or a Stripe.js issue).

Steps to reproduce:

  1. Enter faulty CC information and submit (for testing, use one of the stripe test cards like 4000000000000101, for a real card use the card number with an incorrect CVC code)
  2. Clear the CC number (which also clears ZIP) and enter a valid CC number and CVC code
  3. Submit with empty ZIP field

Other Information

Examining the element's state through the onChange function, we see that the postalCode is initially '' (the empty string), and once reset becomes undefined. Also (and I assume the reason for this issue) complete is set to true, even though there is no postalCode. On the first attempt, complete is false when there is no postalCode.
I should also note that this is for adding a card, not checking out.

Most helpful comment

Yep, we found that as well! We're actively working on a fix, and will post here once it's done.

All 6 comments

Thanks for reporting @ejarzo! This indeed seems like a bug in Stripe.js. I've reported it internally, and we will work to push a fix soon.

@atty-stripe Thanks! I actually noticed that my steps are a little convoluted (whoops). All you need to do is enter a CC number, enter a ZIP, and then delete the CC number and you will be able to submit with an empty ZIP.

Yep, we found that as well! We're actively working on a fix, and will post here once it's done.

@atty-stripe Would you be able to suggest a workaround for the interim? We tried using the postalCode of the underlying elements card object but no luck as it's an unreliable source of truth (will be an empty string initially and then undefined after the bug state is entered).

@ACollectionOfAtoms I don't think there's a workaround in the mean time. We're still working on a fix though, and we will post here when this issue is resolved!

Hi all -- this bug should now be fixed. Please let us know if you find any other issues!

@ACollectionOfAtoms The value.postalCode attribute in the change event should also now always be a string (empty or with a value.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

max-favilli picture max-favilli  路  5Comments

indiesquidge picture indiesquidge  路  5Comments

shortcircuit3 picture shortcircuit3  路  5Comments

kavsingh picture kavsingh  路  4Comments

michael-reeves picture michael-reeves  路  3Comments