#maya121
1 messages · Page 1 of 1 (latest)
👋 let's chat here! could you share more context on what you need help with?
I need help with the integration of error messages in payments, that is, when a card is insufficient, tell me with a pop-up screen
I already tried with the api error code but it gives me a fatal exception error 402
We have an example in our docs on how to display error messages: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment
the line that handles displaying the error message is:
messageContainer.textContent = error.message;
Regarding the 402 error, this could be the response code being returned by Stripe for that particular payment: https://stripe.com/docs/api/errors#errors-code
I tried the try cacth function and it gives me a fatal error. I need an example.
ok and if the payment is denied and I want to show you you do not have funds
For examples, I recommend reviewing our quickstart guide: https://stripe.com/docs/payments/quickstart?client=html
Payments can be denied for a wide range of reasons. If you want to test insufficient funds in particular, I recommend testing with the second card in this table if you haven't done so already: https://stripe.com/docs/testing#declined-payments
ok i already did it but using this
function example_function($args) {
try {
$stripe->paymentIntents->create($args);
error_log("No error.");
} catch(\Stripe\Exception\CardException $e) {
error_log("A payment error occurred: {$e->getError()->message}");
} catch (\Stripe\Exception\InvalidRequestException $e) {
error_log("An invalid request occurred.");
} catch (Exception $e) {
error_log("Another problem occurred, maybe unrelated to Stripe.");
}
help