PayPal PDT始终返回"无效"

时间:2015-11-11 13:30:05

标签: php paypal

我在PayPal开发者网站和其他一些教程的帮助下为PayPal编写了一个PDL阅读器。但即使经过几个小时谷歌搜索,我也无法找到我可以使用的答案(或正确理解)。这是我的代码:

<?php

  $tx=$_GET["tx"];
  $idt="N65xa1iqpNvLzAPkePfnUFYFC-VGBRmu2pftUkUUfOGZqYxOxyucrhDP-Aa";

  $itemName = $_POST["item_name"];
  $amount = $_POST["payment_gross"];
  $myEmail = $_POST["receiver_email"];
  $userEmailPaypalId = $_POST["payer_email"];
  $paymentStatus = $_POST["payment_status"];
  $paypalTxId = $_POST["txn_id"];
  $currency = $_POST["mc_currency"];

// Build the required acknowledgement message out of the notification just received
  $req = 'cmd=_notify-validate';               // Add 'cmd=_notify-validate' to beginning of the acknowledgement

  foreach ($_POST as $key => $value) {         // Loop through the notification NV pairs
     $value = urlencode(stripslashes($value));  // Encode these values
     $req  .= "&$key=$value";                   // Add the NV pairs to the acknowledgement
  }

  $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
  $header .= "Host: www.sandbox.paypal.com\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.sandbox.paypal.com', 443, $errno, $errstr, 30);

  if($fp) {
     echo"connected";
     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
           echo "<br> IPN: Verified<br>";
        } 
        else if (strcmp ($res, "INVALID") == 0) { //Response contains INVALID - reject
           echo "<br> IPN: Invalid";
        }
     }
     fclose($fp);
     } else {
        echo $errstr;
        echo $errno;
        echo "connection failed";    
     }
   ?>

这就是输出(paypalbutton在另一个文档中):

注意:未定义的索引:第6行的C:\ xampp \ htdocs \ subconf \ www \ helper \ PDT.php中的item_name

注意:未定义的索引:第7行的C:\ xampp \ htdocs \ subconf \ www \ helper \ PDT.php中的payment_gross

注意:未定义的索引:第8行的C:\ xampp \ htdocs \ subconf \ www \ helper \ PDT.php中的receiver_email

注意:未定义的索引:第9行的C:\ xampp \ htdocs \ subconf \ www \ helper \ PDT.php中的payer_email

注意:未定义的索引:第10行的C:\ xampp \ htdocs \ subconf \ www \ helper \ PDT.php中的payment_status

注意:未定义的索引:第11行的C:\ xampp \ htdocs \ subconf \ www \ helper \ PDT.php中的txn_id

注意:未定义的索引:第12行的C:\ xampp \ htdocs \ subconf \ www \ helper \ PDT.php中的mc_currency 连接的 IPN:无效

0 个答案:

没有答案