Php Paypal PDT错误4003

Php Paypal PDT错误4003,php,paypal,paypal-sandbox,eclipse-pdt,Php,Paypal,Paypal Sandbox,Eclipse Pdt,在花了好几个小时的时间胡思乱想,试图建立一个相对简单的流程,将付款发送到www.sandbox.paypal.com,并被重定向回我网站上的一个页面,查询字符串中有一个交易id,我终于做到了 我现在收到一条错误消息“FAIL error 4003” 这是我正在使用的代码。这与paypal的示例几乎相同(我所做的只是呼出响应): 感谢您的支付。您的交易已完成,您的购买收据已通过电子邮件发送给您。您可以登录到您的帐户以查看此交易的详细信息。 我已确保确认我的沙箱商户和买家帐户的电子邮件地址,并

在花了好几个小时的时间胡思乱想,试图建立一个相对简单的流程,将付款发送到www.sandbox.paypal.com,并被重定向回我网站上的一个页面,查询字符串中有一个交易id,我终于做到了

我现在收到一条错误消息“FAIL error 4003”

这是我正在使用的代码。这与paypal的示例几乎相同(我所做的只是呼出响应):



感谢您的支付。您的交易已完成,您的购买收据已通过电子邮件发送给您。您可以登录到您的帐户以查看此交易的详细信息。
我已确保确认我的沙箱商户和买家帐户的电子邮件地址,并启用了PDT

使用以下查询字符串参数将客户正确重定向回我的“谢谢”页面-
?tx=4FU63684496248523&st=Pending&amt=29.90&cc=EUR&cm=&item_number=


是否有其他人遇到此错误消息?如果是,通常的原因是什么?

问题是我将测试http请求发送到了paypal.com而不是sandbox.paypal.com。答案在自动存储塔留下的常见问题中

检查脚本。在中测试支付数据传输(PDT)时 沙盒,确保您的PDT脚本将信息发回到 www.sandbox.paypal.com。如果在Live PayPal网站上进行测试,请确保 脚本将数据发回www.paypal.com。目前,所有样本 Live和沙盒站点上的代码“指向”Live PayPal 地点


希望它能帮助其他人比我跑得更快。我现在讨论下一个问题,即令牌返回为空而不是错误。。叹息..

确保您的交易ID未过期。4003 PDT错误代码在您的交易ID过期时也会出现。

以下是为我解决此问题的方法

在“立即购买”按钮中,我有一个与我的LIVE PayPal帐户关联的业务电子邮件地址,而我需要使用与我的SANDBOX PayPal帐户关联的业务电子邮件地址,如中所示:

<input type="hidden" name="business" value="user@host.com">

值属性需要反映与我的沙盒帐户关联的业务电子邮件地址

顺便说一下,下面是上述脚本的另一个PHP cURL版本,它还可以从PayPal的沙箱中获得响应:

if (isset($_GET['tx'])) {

$tx = $_GET['tx'];
$identity_token = "INSERT_YOUR_IDENTITY_TOKEN_HERE";

//echo $tx;

$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';

$nvpString="cmd=_notify-synch".
           "&tx=$tx".
           "&at=$identity_token";

//echo $nvpString;

//define where the data is going to
$curl = curl_init($url);
//tell cURL to fail if an error occurs
curl_setopt($curl, CURLOPT_FAILONERROR, 1); 
//allow for redirects
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
//assign the returned data to a variable
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//set the timeout
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
//use POST
curl_setopt($curl, CURLOPT_POST, 1);
//set the POST data
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvpString);
//execute the transaction
$response = curl_exec($curl);
//show errors
curl_error($curl);
//close the connection
curl_close($curl);

echo '<pre>';
print_r($response);
echo '</pre>';

}//end if (isset($_GET['tx']))
if(isset($\u GET['tx'])){
$tx=$_GET['tx'];
$identity\u token=“在此处插入您的\u identity\u token”;
//echo$tx;
$url='1https://www.sandbox.paypal.com/cgi-bin/webscr';
$nvpString=“cmd=\u notify-synch”。
“&tx=$tx”。
“&at=$identity\u token”;
//echo$nvpString;
//定义数据的去向
$curl=curl\u init($url);
//如果发生错误,告诉cURL失败
curl_setopt($curl,CURLOPT_FAILONERROR,1);
//允许重定向
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);
//将返回的数据分配给变量
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
//设置超时
curl_setopt($curl,CURLOPT_超时,60);
//使用邮政
curl_setopt($curl,CURLOPT_POST,1);
//设置POST数据
curl_setopt($curl,CURLOPT_POSTFIELDS,$nvpString);
//执行事务
$response=curl\u exec($curl);
//显示错误
旋度误差($curl);
//关闭连接
curl_close($curl);
回声';
打印(回复);
回声';
}//如果结束(isset($\u GET['tx']))

我的测试卖家帐户的身份令牌在未通知的情况下更改。使用新的(正确的)标识令牌修复了问题。

$tx=$\u请求['tx'];
$paypal\u url='1https://www.paypal.com/cgi-bin/webscr?cmd=_notify-同步&tx='.$tx.&at=token here';
$curl=curl\u init($paypal\u url);
$data=数组(
“cmd”=>“\u notify-synch”,
“tx”=>tx美元,
“在“=>”标记处”
);                                                                    
$data\u string=json\u encode($data);
curl_setopt($curl,CURLOPT_头,0);
curl_setopt($curl,CURLOPT_POST,1);
curl_setopt($curl,CURLOPT_POSTFIELDS,$data_string);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,1);
$headers=数组(
'内容类型:application/x-www-form-urlencoded',
“主持人:www.paypal.com”,
'连接:关闭'
);
curl_setopt($curl,CURLOPT_HTTP_VERSION,curl_HTTP_VERSION_1_1);
curl_setopt($curl,CURLOPT_HTTPHEADER,$headers);
$response=curl\u exec($curl);
$lines=explode(“\n”,$response);
$keyarray=array();
if(strcmp($lines[0],“SUCCESS”)==0){

对于($i=1;$i,有关Paypal的PTD的更多信息,请参见:

我实际上就这个错误给paypal打了电话,他们给了我一个神秘的回答,说这个错误是由于我的购物车(我正在使用ubercart)中的一些错误配置造成的。一点帮助都没有……这里还有一个常见问题要解决:我用一个简单的表单向paypal提交付款请求,并实际使用他们自己的代码来处理响应。我开发网站和应用程序已经有相当长的一段时间了,但大部分时间都避开了paypal。我感到震惊他们的文档、测试设置和一般服务有多糟糕。你有关于交易ID何时过期的更多信息吗?如果你有,也可以轻松回答这个问题:你有多确定?好的,PayPal交易ID永远不会过期。
if (isset($_GET['tx'])) {

$tx = $_GET['tx'];
$identity_token = "INSERT_YOUR_IDENTITY_TOKEN_HERE";

//echo $tx;

$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';

$nvpString="cmd=_notify-synch".
           "&tx=$tx".
           "&at=$identity_token";

//echo $nvpString;

//define where the data is going to
$curl = curl_init($url);
//tell cURL to fail if an error occurs
curl_setopt($curl, CURLOPT_FAILONERROR, 1); 
//allow for redirects
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
//assign the returned data to a variable
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//set the timeout
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
//use POST
curl_setopt($curl, CURLOPT_POST, 1);
//set the POST data
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvpString);
//execute the transaction
$response = curl_exec($curl);
//show errors
curl_error($curl);
//close the connection
curl_close($curl);

echo '<pre>';
print_r($response);
echo '</pre>';

}//end if (isset($_GET['tx']))
$tx=$_REQUEST['tx'];

$paypal_url='https://www.paypal.com/cgi-bin/webscr?cmd=_notify-synch&tx='.$tx.'&at=token here';

$curl = curl_init($paypal_url);

$data = array(

"cmd" => "_notify-synch",

"tx" => $tx,

"at" => "token here"


);                                                                    

$data_string = json_encode($data); 

curl_setopt ($curl, CURLOPT_HEADER, 0);

curl_setopt ($curl, CURLOPT_POST, 1);

curl_setopt ($curl, CURLOPT_POSTFIELDS, $data_string);

curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 1);

$headers = array (

'Content-Type: application/x-www-form-urlencoded',

'Host: www.paypal.com',

'Connection: close'

);

curl_setopt ($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

curl_setopt ($curl, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($curl);

$lines = explode("\n", $response);

$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);

}


$first_name=$keyarray['first_name'];

$last_name=$keyarray['last_name'];

$payment_status=$keyarray['payment_status'];

$business=$keyarray['business'];

$payer_email=$keyarray['payer_email'];

$payment_gross=$keyarray['payment_gross'];

$mc_currency=$keyarray['mc_currency']; 

}