-1
我一直在試圖找出過去12小時爲什麼這不起作用。我發現每個人現在應該使用IPN系統的最新和更新的代碼。如果你不能確定,爲什麼現在POST頭是HTTP/1.1,而不是HTTP/1.0,請看這裏: https://www.x.com/content/bulletin-ipn-and-pdt-scripts-and-http-1-1PayPal IPN不會做任何
在這個腳本中的任何塊,消息應放置在日誌中。 TXT,但這並不會發生。
任何有識之士任何人都可以提供將是真棒:
<?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 (replaces old headers)
$header .="POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .="Content-Type: application/x-www-form-urlencoded\r\n";
$header .="Host: www.paypal.com\r\n";
$header .="Connection: close\r\n";
$fp = fsockopen ('ssl://paypal.com', 443, $errno, $errstr, 30);
//
//error connecting to paypal
if (!$fp) {
file_put_contents('log.txt', 'httperror');
}
//successful connection
if ($fp) {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
$res = trim($res); //NEW & IMPORTANT
if (strcmp($res, "VERIFIED") == 0) {
if ($_POST["payment_status"] == "Completed") {
$link = mysqli_connect("localhost", "removedforsecurity", "removedforsecurity", "removedforsecurity");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
exit();
}
$username = $_POST["custom"];
$date = date('Y-m-d');
/* update rows */
mysqli_query($link, "UPDATE users SET access='user' WHERE username='myusername'");
file_put_contents('log.txt', 'veri');
/* close connection */
mysqli_close($link);
}
}
if (strcmp ($res, "INVALID") == 0) {
file_put_contents('log.txt', 'failed');
}
}
fclose($fp);
}
?>