1

I am having a similar problem with Stripe webhooks. Spent all weekend trying to diagnose without success. Getting a general 500 error when running test through stripe dashboard. If I just load the page directly, it generates a blank page or if I echo something like echo http_response_code(200);, I get 200 back. My code is pretty straightforward.

require('/stripe/init.php');

\Stripe\Stripe::setApiKey("[intentionally deleted for post]");

$payload = file_get_contents("php://input");

$event_json = json_decode($payload);

http_response_code(200);

PHP runs fine on the site in all other contexts. There are no issues with implementing charges, both one time and subscriptions. Posts and Get work fine on all other pages. It's sharing hosting so have pretty limited access to error logs, etc...

I have already looked through the one or two stackoverflow responses to stripe webhook errors with through a 500 error but unfortunately these did not help. Thanks in advance.

Oleg Nurutdinov
  • 579
  • 3
  • 17
Rsbe
  • 19
  • 3
  • 2
    Without doing some sort of detailed error logging this'll be really hard to diagnose… – deceze Nov 26 '18 at 12:28
  • 1
    Yeah, you need to add more logging, try setting the [error reporting properties](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) for your PHP server, etc. – karllekko Nov 26 '18 at 13:23
  • I spend 1 1/2 hours on the phone with godaddy support trying to get error logging enabled without avail. Moving the hosting for this site is long overdue! – Rsbe Nov 26 '18 at 16:08

2 Answers2

1

I would try this kind of event creation:

$event = \Stripe\Webhook::constructEvent(
    $request->getContent(),
    $request->server->get('HTTP_STRIPE_SIGNATURE'),
    $this->getParameter('stripe_webhook_secret')
);

This is Symfony code so $request is provided by Symfony but you can replace those with your native PHP variables. After this assignment, $event is populated with the data that you see in the Stripe docs examples.

Miro Lehtonen
  • 549
  • 5
  • 17
0

With code 500 it is Internal Server error. So looks like the issue is on the server side.

Please see the various status codes for your reference, this will help you with debugging web requests.

http://www.w3.org/Protocols/HTTP/HTRESP.html

Madhuri Patel
  • 1,684
  • 10
  • 22