有這個IPN腳本工作正常,沒有變化,直到昨天(今天早些時候)...這裏是核心PayPal代碼的關鍵位置,我希望有人可以檢討,讓我知道如果有問題是什麼?我的Wordpress代碼似乎在它自己的工作正常(所以我排除它)...貝寶改變了他們的版本(1.0到1.1)?或URL或其他?PayPal IPN在WordPress網站停止工作
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$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";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
if (!$fp) {
echo $errstr . ' (' . $errno . ')';
$mail_From = 'From: [email protected]';
$mail_To = '[email protected]';
$mail_Subject = 'HTTP ERROR';
$mail_Body = $errstr;//error string from fsockopen
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
$fh = fopen("logipn.txt", 'a');//open file and create if does not exist
fwrite($fh, "\r\n/////////////////////////////////////////\r\n HTTP ERROR \r\n");//Just for spacing in log file
fwrite($fh, $errstr);//write data
fclose($fh);//close file
}
elseif
{
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
$res=trim($res);
if (strcmp ($res, "VERIFIED") == 0) {
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$aid= $_POST['custom'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross']; //full amount of payment. payment_gross in US
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id']; //unique transaction id
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
//do stuff
}
else {
//do stuff
}