Have you looked in the source code? That's not how errors are handled. It returns a Json object with a status code.
Dd() the request and you'll see it.
Check the status code in an if statement then handle your error then.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I try to catch errors throw by the charge method on Stripe.... impossible!
I have try everything...
try {
$user->charge(dollars_to_cents($product->price));
} catch (Exception $e) {
}
try {
$user->charge(dollars_to_cents($product->price));
} catch (\Exception $e) {
}
try {
$user->charge(dollars_to_cents($product->price));
} catch (\Stripe\Error\Card $e) {
}
Finally , the problem was not from the charge method. It was from the createAsStripeCustomer().
We can't generate a stripe id on a failed paiement... Obviously.
Please or to participate in this conversation.