문제

I have set up the following script to test notifications of orders paid via Google Checkout:

<?php
    mail('max@edison.com', '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.

도움이 되었습니까?

해결책

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'))

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top