Php Paypal PDT没有返回所有变量

Php Paypal PDT没有返回所有变量,php,paypal,Php,Paypal,我是Paypal Payment Data Transfer(PDT)的新手,我正在尝试让PDT返回以下变量并在确认页面上打印它们:名字、姓氏、付款人电子邮件、付款总额、项目编号、项目名称、付款日期。我使用Github的PHP代码让PDT工作(),它只返回变量first_name、last_name、payer_email和payment_gross。PDT不返回变量payment\u date、item\u number和item\u name。谁能看出我有什么问题吗 以下是确认页面的PHP代

我是Paypal Payment Data Transfer(PDT)的新手,我正在尝试让PDT返回以下变量并在确认页面上打印它们:名字、姓氏、付款人电子邮件、付款总额、项目编号、项目名称、付款日期。我使用Github的PHP代码让PDT工作(),它只返回变量first_name、last_name、payer_email和payment_gross。PDT不返回变量payment\u date、item\u number和item\u name。谁能看出我有什么问题吗

以下是确认页面的PHP代码,用户在Paypal上购买商品后返回:

<?php

$pp_hostname = "www.sandbox.paypal.com";


// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];
$auth_token = "O1UZLXPTewPRo9cWvtdU5fSEB0KH4PerJcyTKCJzj-yiZi2JOQzZcjwTf1G";
$req .= "&tx=$tx_token&at=$auth_token";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
//set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
//if your server does not bundled with default verisign certificates.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
$res = curl_exec($ch);
curl_close($ch);

if(!$res){
//HTTP ERROR

echo ("<p><h3>ERROR!</h3></p>");

}
else{  echo ("<p><h3>THIS WOKRED!</h3></p>");
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
$itemnumber = $keyarray['item_number'];
$payeremail = $keyarray['payer_email'];
$paymentdate = $keyarray['payment_datel'];


echo ("<p><h3>Thank you for your purchase!</h3></p>");

echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("<li>Item Number: $itemnumber</li>\n");
echo ("<li>Payer Email: $payeremail</li>\n");
echo ("<li>Payment Date: $paymentdate</li>\n");

echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation  
echo ("<p><h3>ERROR NUMBER TWO!</h3></p>");}
}

?>

谢谢您的帮助。

将此行
if(strcmp($lines[0],“SUCCESS”)==0)
更改为此行
if(strcmp($lines[1],“SUCCESS”)==0)

将此行
else if(strcmp($lines[0],“FAIL”)==0)更改为此行
else if(strcmp($lines[1],“FAIL”)==0)

简单地用更好的代码替换; 将此行
if(strcmp($lines[0],“SUCCESS”)==0)
更改为此行
if(stripos($lines,,“SUCCESS”)!==false)

同样,使用更好的代码; 将此行
else if(strcmp($lines[0],“FAIL”)==0)
更改为此行
if(stripos($lines,“FAIL”)!==false)

应该可以了!:-)

贝宝喜欢抛出古怪的代码供美国程序员/开发人员修复,这太糟糕了。祝你今天愉快

我在同一个脚本中遇到了同样的问题,不幸的是,这个解决方案对我不起作用。