2010-08-24 59 views
1

我的處理程序和貝寶已經溝通了幾天,然後發生了一些事情,使後者停止發送IPN了。我嘗試通過我自己的腳本模擬IPN發送,而無需使用cURL進行驗證的回發功能。我的處理程序非常完美。我還在發回PayPal的行之前放置了一行簡單的代碼(已通過cURL測試過),以便我可以檢查PayPal的響應。該行代碼只是將IPN記錄到數據庫中。它也沒有記錄。它應該是對的?因爲paypal發送兩次IPN。我確保IPN在我的商戶帳戶中打開,鏈接指向我的處理程序。現在我開始懷疑貝寶沒有給我任何東西。這是我的處理器:沙盤PayPal怎麼不送我IPN?

<?php 

require_once 'classes/Mysql.php'; 
require_once 'classes/Email.php'; 

$mysql = new Mysql(); 
$myemail = new Email(); 

// 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"; 
} 

// assign posted variables to local variables 
$item_name = $_POST['item_name']; 
$payment_status = $_POST['txn_type']; 
$payment_amount = $_POST['mc_amount3']; 
$payment_currency = $_POST['mc_currency']; 
$subscr_id = $_POST['subscr_id']; 
$receiver_email = urldecode($_POST['receiver_email']); 
$payer_email = $_POST['payer_email']; 
$subscr_type = $_POST['option_selection1']; 
$username = $_POST['custom']; 

//Save a copy of $req to the database. If paypal sends IPN, this should at least grab the first one before validation. 
$memberID = $mysql->get_member_id($username); 
$mysql->test_message($req.$payment_amount.$payment_currency, $memberID, $username, $payment_amount, $payment_currency); 

// 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 ('ssl://www.paypal.com', 443, $errno, $errstr, 30); 

if (!$fp) { 
// HTTP ERROR 
} else { 
fputs ($fp, $header . $req); 
while (!feof($fp)) { 
$res = fgets ($fp, 1024); 
if (strcmp ($res, "VERIFIED") == 0) { 

//This if block does the payment processing. If I place this before the validation/post back occurs, it doesn't work either. But it works when testing using my cURL script--- before the validation. 
if($memberID) 
{ 
    if($payment_status=='subscr_signup' && $payment_currency=='USD' && !$mysql->check_if_transactionID_exists($subscr_id)) 
    { 
     $mysql->activate_subscription($memberID, $subscr_id, $subscr_type, $payment_amount); 
    } 

} 

} 
else if (strcmp ($res, "INVALID") == 0) { 
// log for manual investigation 
} 
} 
fclose ($fp); 
} 

我聽到很多故事paypal是如此令人沮喪的設置。難道貝寶只是不發送IPN,或者我的處理程序有問題嗎?

回答

0

我碰到了類似的issue--如果轉儲從行了var $res$res = fgets ($fp, 1024);你會看到HTTP/1.1 200 OK,不正是你尋找的VERIFIED/INVALID

請試試看看這個答案以獲取更多信息:Paypal IPN returning HTTP/1.1 200 OK