此脚本无效:
IPN脚本,不工作,我不知道为什么......
IPN脚本:
<?php
header('HTTP/1.1 200 OK');
// POST
$payer_email = $_POST['payer_email'];
$userID = $_POST['custom'];
$txn_id = $_POST['txn_id'];
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value"; }
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen('tls://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
fputs($fp, $header . $req);
while (!feof($fp)) { // While not EOF
$res = fgets($fp, 1024); // Get the acknowledgement response
if (strcmp ($res, "VERIFIED") == 0) { // Response contains VERIFIED - process notification
// Send an email announcing the IPN message is VERIFIED
$mail_From = "root@*******.fr";
$mail_To = "******@gmail.com";
$mail_Subject = "VERIFIED IPN";
$mail_Body = "good";
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
}
else if (strcmp ($res, "INVALID") == 0) { //Response contains INVALID - reject notification
// Authentication protocol is complete - begin error handling
// Send an email announcing the IPN message is INVALID
$mail_From = "root@*******.fr";
$mail_To = "******@gmail.com";
$mail_Subject = "INVALID IPN";
$mail_Body = "bad";
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
} }
fclose($fp); // Close the file
?>