Hello,
I am working on a small project with Laravel and Laravel Cashier. I have most things working correctly but I am having some trouble with handling stripes card errors. At the moment I am testing the declined card error which is giving me the standard "Whoops" page with the your card was declined message. I am trying to catch this exception so that I can return a view and display the error in a nicer way but for some reason it is not catching it. I have attached my try catch block of code below. Any help would be greatly appreciated.
try {
$this->user->subscription(Input::get('plan'))->create(Input::get('stripeToken'),[
'email' => $this->user->email
]);
}
catch(Stripe_CardError $e)
{
$body = $e->getJsonBody();
$err = $body['error'];
dd($err);
}
All Stripe exceptions (on the current PHP lib) extend from \Stripe\Error\Base.
\Stripe\Error\Card
\Stripe\Error\Api
Stripe\Error\InvalidRequest
\Stripe\Error\RateLimit
\Stripe\Error\ApiConnection
\Stripe\Error\Authentication
Try catching \Stripe\Error\Card :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community