已解决:PayPal自适应付款身份验证失败



我已经在PayPal沙盒上注册,然后我添加了卖家预配置测试账户。至于ApplicationId,我使用了在Web上找到的几个。最后,触发预批准,我的响应出错:

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-dZ')
    .'&endingDate='.date('Y-m-dZ', strtotime('+1 year'))
    .'&currencyCode=USD'
    .'&maxTotalAmountOfAllPayments=500.00'
    .'&maxAmountPerPayment=200.00'
    .'&maxNumberOfPayments=30'
    .'&senderEmail=user@domain.com'
    .'&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'
)
[ERROR(0).MESSAGE] => Authentication failed. API credentials are incorrect. 

有点放弃!

相关内容

  • 没有找到相关文章

最新更新