I am trying to pass back information and validate via paypal ipn but am having problems can anyone see why it keeps returning invalid even when its not?
Anyhelp is apperciated.PHP Code:<?php
if($_POST){
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$sname = $_POST['custom'];
if($payment_amount != "0.10" && $payment_amount != "0.20"){
echo "<b>There is currently an error proccessing your order, if you feel this is a fault with out system please email support</b>";
die;
}
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
echo "<b>There is currently an error proccessing your order, if you feel this is a fault with out system please email support</b>";
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
echo $res;
if (strcmp ($res, "VERIFIED") == 0) {
if ($payment_status != "Completed") {
echo "<b>There is currently an error proccessing your order, if you feel this is a fault with out system please email support</b>";
}
elseif ($receiver_email != "my@paypal") {
echo "<b>There is currently an error proccessing your order, if you feel this is a fault with out system please email support</b>";
}
elseif ($payment_amount == "0.10") {
echo "Member bah, $item_name , $sname <br>";
}
elseif ($payment_amount == "0.20") {
echo "Premium Member bah, $item_name , $sname <br>";
}
else {
echo "<b>There is currently an error proccessing your order, if you feel this is a fault with out system please email support</b>";
}
}
elseif (strcmp ($res, "INVALID") == 0) {
echo "Paypal has failed to send us the proper feedback, an admin will investigate this payment and manually proccess it for you.";
}
}
fclose ($fp);
}
}
else
{
echo "<p>Please pay via paypal, and not come directly to this page thanks.</p>";
}
?>




Bookmarks