2011-12-27 307 views
3

我已在PayPal沙箱中注册,然后添加了Seller Preconfigured测试帐户。至于ApplicationId,我使用了在Web上发现的几个。最后,触发批准前,我在错误响应:已解决:PayPal自适应付款身份验证失败

Array 
(
    [RESPONSEENVELOPE.TIMESTAMP] => 2011-12-26T19:39:54.500-08:00 
    [RESPONSEENVELOPE.ACK] => Failure 
    [RESPONSEENVELOPE.CORRELATIONID] => a052cd3abd4ea 
    [RESPONSEENVELOPE.BUILD] => 2279004 
    [ERROR(0).ERRORID] => 520003 
    [ERROR(0).DOMAIN] => PLATFORM 
    [ERROR(0).SUBDOMAIN] => Application 
    [ERROR(0).SEVERITY] => Error 
    [ERROR(0).CATEGORY] => Application 
    [ERROR(0).MESSAGE] => Authentication failed. API credentials are incorrect. 
) 

PHP代码:

$URL = 'https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval' 
    .'?startingDate='.date('Y-m-d\Z') 
    .'&endingDate='.date('Y-m-d\Z', strtotime('+1 year')) 
    .'&currencyCode=USD' 
    .'&maxTotalAmountOfAllPayments=500.00' 
    .'&maxAmountPerPayment=200.00' 
    .'&maxNumberOfPayments=30' 
    .'&[email protected]' 
    .'&cancelUrl=http://example.com/cancel' 
    .'&returnUrl=http://example.com' 
    .'&pinType=NOT_REQUIRED' 
    .'&requestEnvelope.errorLanguage=en_US'; 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $URL); 
curl_setopt($ch, CURLOPT_VERBOSE, 0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HTTPHEADER 
    , array(
     'X-PAYPAL-SECURITY-USERID' => 'xxxx' 
     , 'X-PAYPAL-SECURITY-PASSWORD' => 'xxxx' 
     , 'X-PAYPAL-SECURITY-SIGNATURE' => 'xxxxxxxxxxxxxxxxxxxx' 
     , 'X-PAYPAL-APPLICATION-ID' => 'APP-80W284485P519543T' 
     , 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV' 
     , 'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV' 
    ) 
); 
$response = curl_exec($ch); 
$responseAr = explode('&', $response); 
$parsedResponseAr = array(); 
foreach($responseAr as $i => $value) { 
    $tmpAr = explode('=', $value); 
    if(!empty($tmpAr)) 
     $parsedResponseAr[strtoupper($tmpAr[0])] = urldecode($tmpAr[1]); 
} 
print_r($parsedResponseAr); 

莫非是因为错误的应用ID的?我必须先注册我的应用程序才能让应用程序ID在沙盒中使用它?

编辑:我发现原因:标题数组的格式不正确。 它应该是:

array(
    'X-PAYPAL-SECURITY-USERID: xxx' 
    , 'X-PAYPAL-SECURITY-PASSWORD: xxxx' 
    , 'X-PAYPAL-SECURITY-SIGNATURE: xxxxxxxx' 
    , 'X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T' 
    , 'X-PAYPAL-REQUEST-DATA-FORMAT: NV' 
    , 'X-PAYPAL-RESPONSE-DATA-FORMAT: NV' 
) 

回答

1
[ERROR(0).MESSAGE] => Authentication failed. API credentials are incorrect. 

的有点放弃!

+0

我知道,但我使用PayPal的凭证,它们是正确的。它是否表明钥匙是不正确的? '[ERROR(0).CATEGORY] =>应用程序' – 2011-12-27 04:58:23

+0

API凭据不正确意味着它可能表示错误,可能是您自己打错了,重新检查凭据,如果其他所有操作都失败,请创建新的用户帐户(沙箱) – Philip 2011-12-27 05:01:44

+0

新创建的PayPal Sandbox帐户下的相同错误...我想我必须先注册我们的应用程序。 – 2011-12-27 05:14:39