Few days ago suddenly it is stopped to receive IPN messages from paypal. I have written the code which are below
$url_parsed=parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr'); $post_string = ''; foreach ($_POST as $field=>$value) { $post_string .= $field.'='.urlencode(stripslashes($value)).'&'; } $post_string.="cmd=_notify-validate"; $fp = fsockopen($url_parsed['host'],"80",$err_num,$err_str,30); $myFile = "testpaypal.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $post_string; fwrite($fh, $stringData); fwrite($fh, "------------"); if(!$fp){ return false; } else { fputs($fp, "POST $url_parsed[path] HTTP/1.0\r\n"); fputs($fp, "Host: $url_parsed[host]\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ".strlen($post_string)."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $post_string . "\r\n\r\n"); while(!feof($fp)) { $ipn_response .= fgets($fp, 1024); } fclose($fp); if (eregi("VERIFIED",$ipn_response)) { fwrite($fh, "VERIFIED"); return true; } else { fwrite($fh, "UNVERIFIED"); return false; } } fclose($fh);
This code returns err_num to "0" as well as when i print $ipn_response after "fclose($fp);" line it prints "HTTP/1.0 302 Found Location: https://www.sandbox.paypal.com Server: BigIP Connection: close Content-Length: 0 "
but unable to get "VERIFIED" in $ipn_respnse.
i have tried all possible method such as change parse url with "ssl://sandbox.paypal.com" and all other solution suggested on web.
i have been stuck in this issue since last three days. So, please help me out.
thanks in advance.