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.

Comments

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB
ptmkenny’s picture

And 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.

ptmkenny’s picture

New patch: shows the error to the user for "incorrect cvc", "card not supported", and "card expired".

Also, error messages are now translatable.

ptmkenny’s picture

New 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.

bojanz’s picture

Status: Needs review » Needs work
+      if (($exception->getStripeCode() == 'card_declined') && ($exception->getDeclineCode() == 'card_not_supported')) {

The extra parenthesis around both conditions are not needed.

 *   credit_card_types = {
 *     "amex", "dinersclub", "discover", "jcb", "maestro", "mastercard", "visa",
 *   },
        $message = t('Your card is not supported. Please use a Visa, MasterCard, or American Express card.');

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."?

ptmkenny’s picture

Status: Needs work » Needs review
StatusFileSize
new1.13 KB

@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:

Supported presentment currencies
Stripe users can process charges in the following list of currencies with these exceptions:
JCB, Discover, and Diners Club cards can only be charged in USD

https://stripe.com/docs/currencies

  • bojanz committed 23d91d7 on 8.x-1.x authored by ptmkenny
    Issue #2925768 by ptmkenny: Error message is wrong when card_declined...
bojanz’s picture

Status: Needs review » Fixed

Thanks for the clarification. Added a comment, and committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

maestrojed’s picture

This 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?

mrphilipwarner’s picture

@maestrojed how did you get the "Your card was declined" error to display to the user?