0
我在我的dayz服務器上運行IPN以自動處理捐贈並分發該人購買的任何東西。有一個問題,雖然...我已經添加了一個名爲「播放器ID」的自定義字段,並且需要填寫它,因爲稍後會在數據庫條目中使用它。我shopping.php頁面看起來是這樣的:如何在我的IPN腳本中提取自定義字段的值?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="Alice Pack">
<input type="hidden" name="item_number" value="300">
<input type="hidden" name="amount" value="0.10">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<table>
<tr><td><input type="hidden" name="on0" value="Player Unique ID">Player Unique ID</td></tr><tr><td><input type="text" name="os0" maxlength="200"></td></tr>
</table>
<input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form>
現在,我看到,所以我試圖mysql_real_escape_string($_POST['os0'])
輸入字段被命名爲「OS0」和它返回什麼。
這裏是我的IPN.php:
<?php
mysql_connect("dbhost", "dbuser", "dbpass") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
// 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) {
$id = mysql_real_escape_string($_POST['item_number']);
$uniqueid = mysql_real_escape_string($_POST['os0']);
// PAYMENT VALIDATED & VERIFIED!
mysql_query("INSERT INTO cust_loadout_profile (cust_loadout_id, unique_id) VALUES ('$id', '$uniqueid')");
$to = '[email protected]';
$subject = 'Download Area | Login Credentials';
$message = '
Thank you for your purchase
Your account information
-------------------------
Email: '.$id.'
Password: '.$password.'
-------------------------
SUCCESS
You can now login at http://yourdomain.com/PayPal/';
$headers = 'From:[email protected]' . "\r\n";
mail($to, $subject, $message, $headers);
}
else if (strcmp ($res, "INVALID") == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
$to = '[email protected]';
$subject = 'Download Area | Login Credentials';
$message = '
Thank you for your purchase
THIS IS ALSO AN ERROR
Your account information
-------------------------
Email: '.$email.'
Password: '.$password.'
-------------------------
You can now login at http://yourdomain.com/PayPal/';
$headers = 'From:[email protected]' . "\r\n";
mail($to, $subject, $message, $headers);
}
}
fclose ($fp);
}
?>
有沒有辦法讓我的職務要求我的IPN工作?
* PSA:*該'mysql_ *'功能已廢棄在PHP 5.5](http://php.net/manual/en/faq.databases.php# faq.databases.mysql.deprecated)。不建議您編寫新的代碼,因爲這會阻止您將來升級。相反,請使用[MySQLi](http://php.net/manual/en/book.mysqli.php)或[PDO](http://php.net/manual/en/book.pdo.php)和[是一個更好的PHP開發人員](http://jason.pureconcepts.net/2012/08/better-php-developer/)。 –
你不能提交你喜歡的任何舊字段,只能使用paypal期望的那些字段。此外,你應該真的在本地存儲這個值,只發送一個交易ID到payupal – 2013-09-10 21:32:33
我可以存儲唯一的ID作爲會話,然後在IPN.php中調用會話? – user1895377