Provide Stripe error code when trying to complete a payment #2483
Unanswered
modelesque
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What are you trying to do?
Translate Stripe error messages.
What's your proposed solution?
Provide a Stripe error code in
\craft\commerce\controllers\PaymentsController::actionCompletePayment()
when there's an error so it's easier to get a static translation.Additional context
In Europe (at least), when a customer checks out using the Stripe Payment Intents gateway via the Commerce Stripe plugin, they are sent to an authorization step where they confirm to their bank they indeed want to pay the amount (as per the SCA rules), and the result of that step redirects them back to whatever the order's
returnUrl
orcancelUrl
is set to based on whether it was successful or not.That redirect happens in the
\craft\commerce\controllers\PaymentsController::actionCompletePayment()
method:The problem is that the error message is simply a string that gets mixed up with Commerce's own translation:
Stripe doesn't translate their error messages; they only provide English responses. So if your site is in German, Commerce is translating "Payment error" to German while
{message}
is in English. Having to manipulate the string to extract Stripe'smessage
and get my own static translation based on that lengthy text is sort of the poor man's way of handling this I think, especially when Stripe provides standardized error codes.It would be ideal if somehow the error code like
payment_intent_authentication_failure
was available so that that would be the key in my static messages and not Stripe's own text extracted from Commerce's static translation. One reason being that I won't know if Stripe updates the text to their error messages, and the second reason is that there are these error codes for this very reason that aren't being provided in the Commerce response (to my knowledge).Perhaps there's a way to obtain this and I just haven't found it in the code (please let me know if I'm just misunderstanding something here). I get that Commerce's controller has to accommodate other gateways than just Stripe, but the current situation isn't very helpful for providing an error response to users not speaking English.
Beta Was this translation helpful? Give feedback.
All reactions