所以我有PayPal的这个IPN监听器,一切都很好,但是PayPal正在向我发送2个具有相同交易ID的通知。 如何让它只发送1个通知?
这个脚本文件没有任何问题,一旦用户购买了我收到通知并处理它,但在那之后第二个通知发送给我,这让我很烦。为什么PayPal会不断向我发送另一个通知?
<?
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$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);
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
$bussines = addslashes($_POST['bussines']);
$receiver_email = addslashes( $_POST['receiver_email']);
$txn_type = addslashes($_POST['txn_type']);
$mc_gross = addslashes($_POST['mc_gross']);
$tax = doubleval(addslashes($_POST['tax']));
$payment_status = addslashes($_POST['payment_status']);
$item_number = addslashes($_POST['item_number']);
$item_name = addslashes($_POST['item_name']);
$transaction_id = addslashes($_POST['txn_id']);
$currency = addslashes($_POST['mc_currency']);
$payer_email = addslashes($_POST['payer_email']);
$username = addslashes($_POST['custom']);
if (!$fp) {
write_log($log_dir,'Unable to fsockopen ssl://www.paypal.com');
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if(strcmp ($res, "VERIFIED") == 0) {
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Status: VERIFIED]');
if(strtolower($receiver_email) == strtolower($mucore['paypal']['email'])){
if(($txn_type == 'web_accept' OR $txn_type == 'subscr_payment') AND $payment_status == 'Completed'){
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Payment Status: Completed]');
if($tax > 0){$mc_gross -=$tax;}
if(is_file('*****/'.$transaction_id.'.txt')){
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Error Message: Transaction ID Already Processed]');
}else{
if($item_number == md5('USD'.intval($mc_gross).$username.$mucore['cryptkey'])){
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Success Message: Accepted MD5 String]');
//HERE I PROCESS THE TRANSCATION
}else{
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Error Message: Account ID not found in MEMB_INFO]');
}
}else{
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Error Message: Invalid MD5 String] [Amount: '.$mc_gross.' '.$currency.' / Tax: '.$tax.']');
}
}
}elseif($payment_status == 'Reversed' OR $payment_status == 'Refunded'){
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Payment Status: Refunded or Reversed]');
}else{
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Payment Status: '.$payment_status.']');
}
}else{
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Error Message: Invalid Paypal Receiver Email]');
}
}else if (strcmp ($res, "INVALID") == 0) {
write_log($log_dir,'[Account ID: '.$username.'] [Item Number: '.$item_number.'] [Item Name: '.$item_name.'] [Transaction ID: '.$transaction_id.'] [Status: INVALID]');
}
}
fclose ($fp);
}
?>