Is there a way in PHP to capture all post and get variables that are sent to a page?
I am testing my PayPal Subscription website in the PayPal Sandbox but every transaction I do triggers the invalid transaction in my code.
So, I would like to capture everything that PayPal sends to my ipn page and see if I can make sense of what is going on. Is this possible?
Thanks!
For a PayPal IPN, you should be able to use $postdata = file_get_contents('php://input'); to fetch the raw post data needed for the validation callback.
I've got a simple method that helps me capture all the post data:
$post_vars = "";
if ($_POST) {
$kv = array();
foreach ($_POST as $k => $v) {
if (is_array($v)):
$temp = array();
foreach ($v as $v2) {
$temp[] = $v2;
}
$kv[] = "$k=" . join("|", $temp);
else:
$kv[] = "$k=$v";
endif;
}
$post_vars = join("&", $kv);
}
This allows you to capture all the post data (regardless of its name or value) and then store than in a string, great for inserting into a database, though you might want to url encode it. I've updated it to include support for arrays but you'll have to customise it for your own requirements, it produces output like this:
firstname=Terry&lastname=Kernan&userid=111111&device=999999999&text=Hello&questions=q1|q2|q3&answers=a1|a2|a3&type=manual
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With