#newsala_best-practices

1 messages ¡ Page 1 of 1 (latest)

little wolfBOT
#

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

fresh bloomBOT
heavy drum
#

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.

dusty night
#

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.

heavy drum
#

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.

dusty night
#

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.

heavy drum
#

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?

dusty night
#

pi_3P6GHvR03O9UZoSU20I1ubTk

heavy drum
#

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?

dusty night
#

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"
}```
heavy drum
#

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.

fresh bloomBOT
dusty night
#

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.

heavy drum
dusty night
#

According to that list, shouldn't the code for these examples be payment_method_customer_decline instead of payment_intent_authentication_failure?

heavy drum
dusty night
#

Got it! So we can use code to check what the error is and display a customized message, is that correct?

crimson aspen
#

Yes

dusty night
#

Thank you! Is there any way to test for other types of errors in the sandbox?

crimson aspen
#

Any specific errors you have in mind? You can use test cards from here for failed payments, disputes etc

dusty night
#

I mean for redirect methods, like Klarna, SEPA, or iDEAL.

#

Something like sepa_unsupported_account, insufficient_funds, or bank_account_declined

crimson aspen
#

Those test credentials should help

#

with testing declines/failed payments

dusty night
crimson aspen
#

Ah okay. I don't believe there are any other ways to test this unfortunately.

dusty night
#

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!