#liam-hunt-bonterra_code
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/1324468567709716561
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐ I don't think you should do any filtering of errors there. Are you using an approach similar to what we show in our guides where all errors are passed to handleError?
Hi! That's right, I'm using something like handleError where I take the error string and show it to the customer in a banner.
My reason for thinking I should deviate from the approach of always calling handleError is: when const { error: submitError } = await elements.submit(); errors, it appears Stripe automatically shows a validation message on the PaymentElement? And I would prefer not to display the same error message twice
In this scenario, it looks like StripeJS automatically red outlines the card input and shows a red text error message
Also - and I'm likely overthinking this - the typescript type for StripeError says
/**
* A human-readable message providing more details about the error. For card errors, these messages can be shown to your users.
*/
message?: string;
which suggests that non-card errors should not be shown to the user. But again I might be reading too much into it
Gotcha, that is a good point. I am looking in to what guidance we have on this and will get back to you with what we can find.
Thank you! A bit more context - my company is touchy about showing customers messages with either too much info about either technical systems (things like "API limit reached"), or information that could be helpful to card fraudsters
Yeah definitely a good thing to consider. We do generally try to design things with that in mind. It is helpful for you to have informative error messages but confusing if a user sees one that isn't relevant to them. From my testing, the error definitely can be redundant to something that is already shown in the payment element. I am checking to see if there is a good consistent way to check this in our error response. If not, definitely raising some feedback about this.
๐ thank you again!
In our reference for the confirmPayment call we do directly say that card_error and validation_error errors can be shown to users, but the error from my test is a validation_error. It does sound like you can definitely avoid showing errors of type invalid_request_error, as those are more API focused.
If the confirmation fails, the Promise will resolve with an {error} object that describes the failure. When the error type is
card_errororvalidation_error, you can display the error message in error.message directly to your user. An error type ofinvalid_request_errorcould be due to an invalid request or 3DS authentication failures.
https://docs.stripe.com/js/payment_intents/confirm_payment
I am going to consult my colleagues on this. If we can't find anything now, we may need to create a ticket so I can raise this to the team that works on elements and get back to you later.
Yep as far as we can see that error message will always be redundant for the payment element and express checkout element. I am actually not immediately sure why we return the message and specify that in the docs. I'll raise this so we can review and clarify
Thank you - to clarify "that error message will always be redundant" that refers to any error message returned by const { error: submitError } = await elements.submit();? Of all error types?
Correct
Thanks! So then errors thrown by
await stripe.createConfirmationToken({
elements,
params,
});
do are not shown on the StripeJS elements automatically
I don't think so but am looking in to it.
Ty! Don't intend to rush, just want to make sure I'm confident I understand the findings ๐
Oh of course, I am honestly a bit surprised at myself that I never thought of these questions.
From what we can see, you are correct that createConfirmationToken will not effect the payment element. So I think the rule from the doc where you show errors other than invalid_request_errors should make sense there. Though as far as I am aware any validation type error should get caught by elements.submit so I'm not sure if it ever will return an error that needs to be shown.
Ok! I think this gives me most of a working approach
- Don't show errors from
const { error: submitError } = await elements.submit();as they show in the PaymentElement or ECE - Show errors from
createConfirmationTokenif they are of typecard_errororvalidation_error, though the latter might never happen
For 2, just clarifying that the typescript type StripeErrorType has items other than card_error, validation_error, invalid_request_error. So "show everything but invalid_request_error" and "show card_error or validation_error" aren't the same
Hello! I'm taking over and catching up...
You're referring to these error types, correct? https://github.com/stripe/stripe-js/blob/cf55c17944077b2339534569ce2970d911e4569d/types/stripe-js/stripe.d.ts#L1435-L1475
If so, how you handle these is entirely up to you. For example, an API connection error might be something you want to log in detail internally but show to your customer as a more generic error. A card error, on the other hand, can be shown directly to your customers.
Ok. The question is exactly which types of errors I can safely show to my customer - it sounds like to the answer to that is card_error or validation_error?
That depends on what you definition of "safely" is. Safely as in you won't disclose sensitive information? Safely as in the customer is likely to understand the error message? Something else?
I would say I'd want both of those things to be true in order to show the customer a message
Like showing them some generic non-stripe-generated string unless the message is something the customer could both understand and fix themself
In that case you'd want to show them card errors, validation errors, and maybe API connection errors (it's possible the connection issue could be on their end and might be something they can fix).
Ok, thank you! I think this answers all my questions.