Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dmcglone's avatar

Stripe get and post routes

I've been playing around with stripe today and was following Jeffrey's "billing with stripe" series and I come across something I'm curious about..

If I use "/" in my routes instead of "buy" like Jeff does, the code doesn't work, but if I change the routes to anything other than, it works. Anybody know why this is?

Doesn't work

Route::get('/', 'WelcomeController@index');
Route::post('/', 'WelcomeController@store');

But this works.

Route::get('billing', 'WelcomeController@index');
Route::post('billing', 'WelcomeController@store');
0 likes
10 replies
dmcglone's avatar

I'm not using anything special, just following the tutorial. I find it weird, that it doesn't work on the root directory.

jlrdw's avatar

How did Jeffrey deal with the routing in the video, was it done differently for stripe.

jlrdw's avatar

Did you

Since Stripe webhooks need to bypass Laravel's CSRF verification, be sure to list the URI as an exception in your VerifyCsrfToken middleware:

protected $except = [
    'stripe/*',
];
dmcglone's avatar

The only thing that was different from his video that I was doing was he used "buy" as his view page:

Route::get('buy', function() {
    return view('buy')
});
Route::post('buy',function() {
    dd(Input::all())
});

But I was just being lazy and really didn't think it would make a difference so I stuck with the default root view like so:

Route::get('/', function() {
    return view('welcome')
});
Route::post('/',function() {
    dd(Input::all())
});

But for some reason it wasn't returning the input data to the page, so after an hour or 2 of comparing my work to the video, I decided to change the views to match his and it worked.

I then changed the view to "billing" and a couple other names and they worked also.

Finally, I changed it back to "/" just to see if I wasn't going crazy and sure enough it didn't work...

It's a fresh install of laravel too, with nothing except the default welcome pages.

Isn't that weird? In my mind "/" should work just as well as the other pages.

joedawson's avatar

That does seem like some weird behaviour, you don't have any other routes conflicting with those routes do you?

dmcglone's avatar

No, It's a completely fresh install with nothing changed and nothing added except for stripe and the post route.

dmcglone's avatar

I just tried using named routes to try and trick it, but that doesn't work either. Seems no matter what is tried, it refuses to post to "/".

I'm still curious why, but I guess I'll move on to something else for the time being.

jlrdw's avatar

Jeffrey is on forum, ask him. @JeffreyWay help, help.
I wonder if Jeffrey wears a cape like Underdog?

1 like
dmcglone's avatar

It's no biggie, I understand how it all works, I'll just have to remember it doesn't work on / lol

He might, unless he's Superman. ;-)

Please or to participate in this conversation.