When using a card that is not supported such as JCB (Stripe test card: 3530111333300000, Commerce Stripe returns this error message: "We encountered an error processing your card details. Please verify your details and try again."
But the Stripe error that is logged to Watchdog is: "Your card is not supported. Please use a Visa, MasterCard, or American Express card"
We should not tell the user to try again when the card won't work because the brand is not supported.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2925768-7_commerce_stripe_error-when-card-declined-not-supported.patch | 1.13 KB | ptmkenny |
Comments
Comment #2
ptmkenny commentedComment #3
ptmkenny commentedAnd actually, if the card is declined because it's not supported, the card shouldn't be registered to the account at all, but I don't know how to prevent that.
Comment #4
ptmkenny commentedNew patch: shows the error to the user for "incorrect cvc", "card not supported", and "card expired".
Also, error messages are now translatable.
Comment #5
ptmkenny commentedNew patch. @bojanz informed me that it is a bad practice to whitelist errors to show to users (incorrect cvc, etc.), so I abandoned that approach.
The patch now only warns the user if the card is not supported.
Comment #6
bojanz commentedThe extra parenthesis around both conditions are not needed.
The annotation and the message are not in sync. AFAIK the supported card types are market specific, so perhaps what we need to do is have a more generic message, perhaps just "Your card is not supported."?
Comment #7
ptmkenny commented@bojanz Thank you for the review.
I removed the extra parentheses.
The message "Your card is not supported. Please use a Visa, MasterCard or American Express card." is actually the exact string returned by Stripe itself. Since this string is provided by Stripe and tells users specifically what cards are supported, I think it is more helpful than simply a "card not supported" message.
Reference: supported card types are "all card types for US dollars, Visa/MasterCard/Amex only for non-USD."
Source:
https://stripe.com/docs/currencies
Comment #9
bojanz commentedThanks for the clarification. Added a comment, and committed.
Comment #11
maestrojed commentedThis patch added a more specific message for "card_declined && card_not_supported". But why not for all the other reasons a card could be declined?
I have the same concern as above. The exception is the card is declined. But the message encourages the user to keep trying. This is true for many of the delined reasons (not just card_not_supported). Stripe returns a message "Your card was declined.". Why is this not included?
I can work to make src/ErrorHelper.php more specific. I am just trying to understand why it wasn't this way (i.e. just print the stripe error message). Maybe I am overlooking a pitfall?
Comment #12
mrphilipwarner commented@maestrojed how did you get the "Your card was declined" error to display to the user?