2010-10-11 42 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',