2011-10-26 46 views
2

我正在嘗試獲取PayPal IPN訂閱ID時遇到了最困難的時間。這是我的IPN頁面。我在嘗試獲取PayPal IPN訂閱ID時遇到了最困難的時間Id

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


// 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) { 
// check the payment_status is Completed 
// check that txn_id has not been previously processed 
// check that receiver_email is your Primary PayPal email 
// check that payment_amount/payment_currency are correct 
// process payment 
    if("susbcr_signup" == $_POST['txn_type']){ 

     $_id = $_POST['subscr_id']; 



    $websites= "websites"; 
    $database = "k29803_1"; 
    mysql_connect("localhost", $username, $password) or die(mysql_error()); 
    mysql_select_db($database); 

    $query = "SELECT * FROM users WHERE username= 'drahoslava' AND password = 'drah0slava'"; 
    $results = mysql_query($query)or die(mysql_error()); 
    if(mysql_num_rows($results)==1){ 
     $add_credits = "UPDATE users SET hash = '$_id' 
     WHERE username= 'drahoslava' AND password = 'drah0slava'"; 
     mysql_query($add_credits) or die(mysql_error()); 
     echo 'done'; 


     } 

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

這是我的形式

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
<input type="hidden" name="cmd" value="_s-xclick"> 
<input type="hidden" name="hosted_button_id" value="6ZZUDQCUUXGMS"> 
    <input type="hidden" name="item_name" value="Baseball Hat Monthly"> 
    <input type="hidden" name="item_number" value="123"> 
<input type="hidden" name="notify_url" value="http://www.germcode.kodingen.com/ipn.php" /> 

<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
</form> 

MySQL表犯規更新..可能是什麼問題。 *我有自動返回上

回答

1

抱歉,這並不是真的每說一個答案,但我不能讓我的建議爲註釋正確

嘗試用於測試目的將接收設置額外的表每個事務的ipn信息的原始轉儲。然後,您可以查看收到的內容以確定它未​​插入到表格中的原因。

要保存所有的原始數據,你可以做像這樣:

$IpnSerialized = serialize($_POST); 
$RawInsert = "INSERT INTO `IpnRaw` (`IpnDump`) VALUES ('{$IpnSerialized}')"; 

而且,任何回聲或打印不添加到IPN處理程序腳本。無論如何,沒有人會看到它。

您可能希望在測試表中添加一些額外的字段,您可以在其中存儲進度標記以查看在劇烈爆炸前腳本獲得的距離。

1

嘗試做一個電子郵件ipn數據,你從貝寶回來,看看你是否可以獲取數據。如果您可以獲取數據,則問題出現在您的查詢中。