2016-07-04 173 views
0

我有這個問題關於通過php的IPN Paypal付款。PayPal - IPN頁面

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

嗨,不是權限問題,因爲它的腳本保存了它的文件。 – Jeager

回答

0

我一直用這個辦法:

$filename = **FULL_PATH** . "/" . $filename . ".txt"; 
$handle = fopen($filename, "a+"); 

If($handle) { 
    fwrite($handle, YOUR_CONTENTS_HERE); 
} 

我可以看到你不提供文件的完整路徑。