Level 102
Seems that you are missing a return before response()
catch(\Stripe\Error\InvalidRequest $e) {
return response()->json(['message' => $e->getMessage()], 400);
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi All,
I'm having a little brain freeze with some jQuery....
I have this JS when the button is clicked:
$.ajax({
type: 'POST',
url: '/api/plans/auto-billing',
data: $('#form').serialize(),
success: function (data) {
console.log('Success ' + data);
window.location.href = data.redirect;
},
error: function (xhr, status, error) {
console.log('Error! ' + error.message);
},
});
But within my controller I have Stripe's errors in a try catch statement, but this one mainly is the one I want to return:
catch(\Stripe\Error\InvalidRequest $e) {
response()->json(['message' => $e->getMessage()], 400);
}
But I can't for the life of my remember how to return from the controller to the JS, can one of you awesome folks help a brother out :)
Thanks, in advance!
Please or to participate in this conversation.