#newsala_best-practices
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1229858112110989363
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello! Can you give me the ID of one of these failed Payment Intents so I can take a look?
It's likely you'll want to create your own message to use when you come across payment_intent_authentication_failure, but I want to make sure I fully understand the situation by looking at an example.
pi_3P6FHqR03O9UZoSU0w4p4UQd
'message' => 'Customer cancelled checkout on Klarna',
We currently use a generic message, but we would like to show better messages for all types of error.
Yeah, we don't surface a user-facing error message in the API for a situation like this one. You can look at last_payment_error.payment_method_customer_decline and create a message for that scenario.
But how do we know this error is a payment_method_customer_decline? We only get code: payment_intent_authentication_failure and type: invalid_request_error.
To be clear, I'm asking about this specific case as an example. I would like to understand how to distinguish the types of errors so that we can decide which message to display. Currently, the only thing I noticed that changes is the message.
Not sure I follow... last_payment_error.payment_method_customer_decline is a property on the Payment Intent you provided. Maybe it would help if you can show me a couple more examples where only the message has changed?
pi_3P6GHvR03O9UZoSU20I1ubTk
Ah, yeah, I see what you're saying. The message we provide there is info for you, as the merchant, to know what went wrong. There isn't really a customer-facing message that would be different between these two beyond a generic "you did not approve the payment" message. Can you give me an idea of what messages you'd like to display to the customer for these two examples?
I can't see this last_payment_error.payment_method_customer_decline. This is the object I get as last_payment_error:
{
"code": "payment_intent_authentication_failure",
"doc_url": "https:\/\/stripe.com\/docs\/error-codes\/payment-method-customer-decline",
"message": "The customer did not approve the PaymentIntent. Provide a new payment method to attempt to fulfill this PaymentIntent again.",
"message_code": "payment_intent_redirect_payment_method_failure",
"payment_method": { ... },
"type": "invalid_request_error"
}```
Ah, you're probably on an older API version where that info is slightly different.
Regardless, the code is the same across these two Payment Intents.
Well, in this specific case something like "The payment was not approved, please try again" (just an example). In fact, I expected the documentation to list the possible errors since I can't simulate anything other than customer declined in the sandbox. So, with this list, and a way to detect which error happened, we would write an error message for each type of error.
We do list the possible errors here: https://docs.stripe.com/error-codes
According to that list, shouldn't the code for these examples be payment_method_customer_decline instead of payment_intent_authentication_failure?
It would be if you weren't on an older API version. You're using 2020-08-27 but that more specific code wasn't available until 2023-08-16: https://docs.stripe.com/upgrades#2023-08-16
Got it! So we can use code to check what the error is and display a customized message, is that correct?
Yes
Thank you! Is there any way to test for other types of errors in the sandbox?
Any specific errors you have in mind? You can use test cards from here for failed payments, disputes etc
I mean for redirect methods, like Klarna, SEPA, or iDEAL.
Something like sepa_unsupported_account, insufficient_funds, or bank_account_declined
Those test credentials should help
with testing declines/failed payments
Redirect based payment methods usually redirect you to a Stripe hosted test page where you can authorize or decline the charge.. See: https://docs.stripe.com/testing#redirects
I know, but that always return payment_intent_authentication_failure, and maybe payment_method_customer_decline in newer API versions.
Ah okay. I don't believe there are any other ways to test this unfortunately.
Error test SEPA accounts do not redirect, and Klarna declined accounts fail without returning to the app, so it is not possible to use them for testing.
But just knowing that the code is not always the same payment_intent_authentication_failure helps a lot. I will monitor the live transactions more and check if there are other codes that we want to handle. Thank you very much!