2010-10-11 150 views
6

我正在使用PayPal的DoDirectPayment API进行支付集成。我收到如下所示的错误消息。PayPal“安全标题无效”错误。该怎么做?


Security error: 
Error no: 10002 
Error message: Security header is not valid 

这里是我的代码,

$environment = 'sandbox'; 
    // Set up your API credentials, PayPal end point, and API version. 
    $API_UserName = urlencode('xxxxxxxx'); 
    $API_Password = urlencode('xxxxxxxx'); 
    $API_Signature = urlencode('xxxxxxxxxxxxxxxxxxxxxxxxxxx'); 
    $API_Endpoint = "https://api-3t.paypal.com/nvp"; 
    if("sandbox" === $environment || "beta-sandbox" === $environment) { 
     $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp"; 
    } 
    $version = urlencode('51.0'); 

    // setting the curl parameters. 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint); 
    curl_setopt($ch, CURLOPT_VERBOSE, 1); 

    // Set the curl parameters. 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, 1); 

    // Set the API operation, version, and API signature in the request. 
    $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_"; 

    // Set the request as a POST FIELD for curl. 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); 

    // Get response from the server. 
    $httpResponse = curl_exec($ch); 

请帮我从这个问题。

谢谢。

回答

0

一定要非常仔细地检查你的API端点和版本:发生

https://www.x.com/message/156280#156280

+5

失效链接12年3月12日 – 2012-03-13 00:14:24

+0

链接已被网站 – 2012-10-15 06:32:31

+2

尝试删除:https://developer.paypal.com/webapps/developer/docs/classic/api/endpoints/ – 2013-11-18 12:57:30

0

我的问题,是由于API证书是不正确。即使输入了正确的沙盒api用户名,密码和api密钥,我仍然得到相同的错误。我重新创建了我的测试帐户,再次将它们输入到我的应用程序中,重新启动服务器,然后运行。

下面是从x.com谈论类似问题的链接:paypal security header issue

0

你应该改变你的端点api.sandbox.paypal.com,它的工作对我 首先你登入账户sendbox和标签检查应用程序

0

user2230647是对的。你需要有沙盒相关信息的情况下,要在沙盒模式下测试所有的参数如下:

'api_endpoint' => 'https://api-3t.sandbox.paypal.com/nvp', 
'api_username' => 'example_api1.email.com', 
'api_password' => 'your_password', 
'api_signature' => 'your_signature',