2013-05-02 51 views
-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); 
    } 

?> 

回答

0

看看這些IPN Troubleshooting Steps。這些可能有幫助。還要檢查您的PayPal賬戶中的IPN歷史記錄,以確保IPN實際上正在發送出去。它還應顯示它是否已成功發送,或者是否失敗並正在重試。還應該有一個狀態代碼,說明您的服務器在IPN歷史消息的詳細信息中所反映的內容。貝寶希望200ok響應。