Paypal PDT错误4003

TGu*_*ond 5 php paypal eclipse-pdt paypal-sandbox

经过几个小时的混乱并试图建立一个相对简单的向www.sandbox.paypal.com发送付款的过程,并被重定向回到我的网站上的一个页面,在查询字符串中有一个事务ID,我有终于实现了它.

我现在收到错误消息'FAIL Error 4003'.

这是我正在使用的代码.它与paypal示例几乎相同(我所做的就是回应响应):

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

$tx_token = $_GET['tx'];

$auth_token = "ZdoN6q4GLiRniR2BbOzEEF22GJOWHpVOXRtP7fAhBpvwwm5GyWcTzO_sSSO";
$req .= "&tx=$tx_token&at=$auth_token";

// 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 ('www.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) 
{
    // HTTP ERROR
    echo "HTTP Error";
} 
else 
{
    fputs ($fp, $header . $req);
    // read the body data 
    $res = '';
    $headerdone = false;
    while (!feof($fp)) 
    {
        $line = fgets ($fp, 1024);
        if (strcmp($line, "\r\n") == 0) {
            // read the header
            $headerdone = true;
        }
        else if ($headerdone)
        {
            // header has been read. now read the contents
            $res .= $line;
            echo $line;
        }
    }

        // 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'];

            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 ("");
        }
        else if (strcmp ($lines[0], "FAIL") == 0) {
            echo "Failure: " . $lines[0];
            // log for manual investigation
        }

}

fclose ($fp);

?>
<br />
Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you. You may log into your account at <a href="http://www.sandbox.paypal.com/ie">www.sandbox.paypal.com/ie</a> to view details of this transaction.
Run Code Online (Sandbox Code Playgroud)

我已确保确认我的沙箱商家和买家帐户的电子邮件地址并启用了PDT.

客户端被正确地重定向回我的"谢谢"页面,其中包含以下查询字符串参数 - ?tx=4FU63684496248523&st=Pending&amt=29.90&cc=EUR&cm=&item_number=

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

TGu*_*ond 6

问题是我将测试http请求发送到paypal.com而不是sandbox.paypal.com.答案在Jukebox留下的常见问题解答中.

检查脚本.在Sandbox中测试付款数据传输(PDT)时,请确保您的PDT脚本将信息发送回www.sandbox.paypal.com.如果在Live PayPal站点上进行测试,请确保脚本将数据POST回www.paypal.com.目前,Live和Sandbox网站上的所有示例代码都"指向"现场PayPal网站.

希望它能帮助别人比我更快地起床跑步.我现在正处理我的下一个问题,即令牌被返回为空而不是错误..叹息..