I have written a PDL reader for PayPal with the help of the PayPal developer site and a few other tutorials. But even after hours long google searching I couldn't find an answer that I can use (or understand properly). This is my code:
<?php
$tx=$_GET["tx"];
$idt="N65xa1iqpNvLzAPkePfnUFYFC-VGBRmu2pftUkUUfOGZqYxOxyucrhDP-Aa";
$itemName = $_POST["item_name"];
$amount = $_POST["payment_gross"];
$myEmail = $_POST["receiver_email"];
$userEmailPaypalId = $_POST["payer_email"];
$paymentStatus = $_POST["payment_status"];
$paypalTxId = $_POST["txn_id"];
$currency = $_POST["mc_currency"];
// Build the required acknowledgement message out of the notification just received
$req = 'cmd=_notify-validate'; // Add 'cmd=_notify-validate' to beginning of the acknowledgement
foreach ($_POST as $key => $value) { // Loop through the notification NV pairs
$value = urlencode(stripslashes($value)); // Encode these values
$req .= "&$key=$value"; // Add the NV pairs to the acknowledgement
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if($fp) {
echo"connected";
fputs($fp, $header . $req);
while (!feof($fp)) { // While not EOF
$res = fgets($fp, 1024); // Get the acknowledgement response
if (strcmp ($res, "VERIFIED") == 0) { // Response contains VERIFIED - process notification
echo "<br> IPN: Verified<br>";
}
else if (strcmp ($res, "INVALID") == 0) { //Response contains INVALID - reject
echo "<br> IPN: Invalid";
}
}
fclose($fp);
} else {
echo $errstr;
echo $errno;
echo "connection failed";
}
?>
and that is the output (the paypalbutton is in another document):
Notice: Undefined index: item_name in C:\xampp\htdocs\subconf\www\helper\PDT.php on line 6
Notice: Undefined index: payment_gross in C:\xampp\htdocs\subconf\www\helper\PDT.php on line 7
Notice: Undefined index: receiver_email in C:\xampp\htdocs\subconf\www\helper\PDT.php on line 8
Notice: Undefined index: payer_email in C:\xampp\htdocs\subconf\www\helper\PDT.php on line 9
Notice: Undefined index: payment_status in C:\xampp\htdocs\subconf\www\helper\PDT.php on line 10
Notice: Undefined index: txn_id in C:\xampp\htdocs\subconf\www\helper\PDT.php on line 11
Notice: Undefined index: mc_currency in C:\xampp\htdocs\subconf\www\helper\PDT.php on line 12 connected IPN: Invalid