I'm setting up Laravel Cashier in my app to accept payment through Stripe. I've got it working, and had starting trying to deal with errors/edge cases, and I'm having trouble catching errors when I try $user->newSubscription()
I've trying to catch a variety of cases: Laravel\Cashier\Exceptions\PaymentFailure, Stripe\Exception\InvalidRequestException but even when I wrap my code in a try/catch it errors out.
// Controller
try {
$subscription = $user->newSubscription("name", "plan")->create($payment_method);
} catch (Exception $e) {
return response()->json(["error" => ["code" => 500, "message" => "WTF"]], 500);
}
My frontend makes an ajax request to this controller but never returns the object from my catch. I've tried to following, too:
catch( \Stripe\Exception\InvalidRequestException $e )
catch(Laravel\Cashier\Exceptions\PaymentFailure $e)
But none seem to work. Hopefully this is a dumb question and I'm missing something obvious! :)