我有关于通过php进行IPN Paypal付款的这个问题。
ipn.php
<?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);
$fp = fsockopen ('ssl://www.sandbox.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) {
// PAYMENT VALIDATED & VERIFIED!
$hour = date("g:ia");
$fp = fopen("richieste_".date("d_m_Y").".txt", "a");
fwrite($fp, "1,16,6.01,".$hour.";");
}
else if (strcmp ($res, "INVALID") == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
}
}
fclose ($fp);
}
?>
未保存txt文件,ipn状态为payment_status =已完成HTTP请求代码200。 哪里错了?
答案 0 :(得分:0)
我总是使用这种方法:
$filename = **FULL_PATH** . "/" . $filename . ".txt";
$handle = fopen( $filename, "a+" );
If( $handle ) {
fwrite( $handle, YOUR_CONTENTS_HERE );
}
我可以看到你没有提供文件的完整路径。