I am implementing paypal in my website, the problem I have is that I am doing it first through sand box since I am doing tests with the two fictional accounts (business and personal). The payment is fine but I have activated IPN to receive the information and know if it is paid or not and so I can update it in my database. It is all activated and arrives at the web page that I have indicated IPN. The problem is that it does not just work for me. In addition, all payments have their status in is being reviewed and I do not know if maybe the problem is here. I put the code here
header('HTTP/1.1 200 OK');
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
// If testing on Sandbox use:
$header .= "Host: www.sandbox.paypal.com:443\r\n";
// For live servers use $header .= "Host: www.paypal.com:443\r\n";
// Open a socket for the acknowledgement request
// If testing on Sandbox use:
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// For live servers use $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
fputs($fp, $header . $req);
$id_reserva=$_POST['item_number'];
while (!feof($fp)) {
$res = fgets($fp, 1024);
$sql="update reservas set estado='".$id_reserva."'";
mysqli_query($conn, $sql);
if (strcmp ($res, "VERIFIED") == 0) {
$sql="update reservas set estado='1'";
mysqli_query($conn, $sql);
} else if (strcmp ($res, "INVALID") == 0) {
$sql="update reservas set estado='2'";
mysqli_query($conn, $sql);
}
fclose ($fp);
}
?>
Inside the while, if it enters me because that query does it well: $ sql="update reserves set status = '". $ reserve_id. "'";
but I do not enter any of the 2 if there is, then I can not validate if it has been paid correctly or not.