Reputation: 17573
I have set up the following script to test notifications of orders paid via Google Checkout:
<?php
mail('[email protected]', 'google checkout order alert', json_encode($_POST));
?>
I'm getting the email, but the value of the $_POST
array is blank (in other words, the body of the email is simply []
).
Am I wrong to think that the values should be getting sent immediately via POST? Or is the notification request really just an opportunity for me to then request from Google the most recent order details? I.e., my above script would need to make a request to Google for the order details.
Upvotes: 0
Views: 176
Reputation: 13348
The Google Checkout postback request is a raw JSON post, not a typical HTTP post (which is what would be needed in order to populate the $_POST
array). In order to read the contents of the postback request, you must get the raw post body, and json_decode
it.
This should do the trick: json_decode(file_get_contents('php://input'))
Upvotes: 1