Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe webhook test error 302

I am trying to test a stripe webhook for subscription trial ending. When I go to send the test even to my webhook receiving route I get error 302. I am using a middleware called stripe-webhook-middleware. My route looks like this:

app.post('/stripe/events',
    stripeWebhook.middleware,
    stripeEvents
  );

I know that route goes against what they docs say but I did get it directly from the package creator. So it should work, then I have the stripe-events.js from the package. I am just adding in a console.log to the route to find the correct data I need.

I tried different webhooks and all give the same error, it has to be in how I have it set up. I hope anyways.

Edit **

I have also done a new route that is just a basic post route with a console.log and still getting the 302 error. What could possible causes be? I can't post a github because of a credential I accidentally leaked.

like image 895
Kirbytech Avatar asked Jan 03 '23 06:01

Kirbytech


2 Answers

I am/was using cloud9.io as my development environment and had my test site as private. That was causing stripe to need to login in order to do anything. I made it public and now it works. I had completely forgotten I had to login to see the site because I always was logged in to cloud 9 when I accessed the site. If you are getting a 302 error, make sure you don't need to log in to get to that route.

like image 168
Kirbytech Avatar answered Jan 13 '23 09:01

Kirbytech


Just in case anyone sees this 302 error with Codeigniter 3, my webhook route was pointing to a Subscription controller that always exits the constructor if a user isn't logged in and authorised - so I moved the method to my Home controller (used for registration, login etc) thus:

$route['webhook']['post'] = 'home/webhook';

and the 302 error went away. I hope this helps a tired CI dev down the road.

like image 29
Arbor Avatar answered Jan 13 '23 08:01

Arbor