Jump to content

NULL response when processing Stripe webhook


Recommended Posts

I am trying to process a Stripe POST response with a webhook endpoint script.

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

Problem is that I am getting NULL.

However... the Stripe Dashboard that shows the request & response to the Stripe request is correct for the specific event, even to the extent of showing the dump and error messages afterwards. Any ideas would gratefully received as I have spent way too long on this... although having to pick apart stuff like this does end up with me learning a lot more!

Link to comment
Share on other sites

Narrowed this right down to

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

if ($payload) {
    // $payload = file_get_contents("php://input");
    echo "worked";
} else {
    echo "not working";
}

So, in the browser, I am getting "not working" - in the stripe dashboard response, I am getting "worked" - how is this possible?

Link to comment
Share on other sites

OK, I have resolved this although I am not sure I fully understand but basically I was trying to use webhook code on a 'success' page. Moved it to something that could be polled asynchronously an it worked straightaway.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...