php - 已解决 : PayPal Adaptive Payments Authentication failed

标签 php paypal paypal-sandbox

我已经在 PayPal Sandbox 上注册,然后我添加了卖家预配置测试账户。至于 ApplicationId,我使用了一些在 Web 上找到的。最后,触发Preapproval,我在响应中遇到错误:

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'
    .'&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);

会不会是 App Id 错误?我必须先注册我的应用程序才能获得应用程序 ID 才能在沙盒中使用它吗?

编辑:我找到了原因:headers 数组的格式不正确。 应该是:

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. 

一点赠送!

关于php - 已解决 : PayPal Adaptive Payments Authentication failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8641292/

相关文章:

php - 将登录时间存储在mysql数据库中

php - 使用 PHP 从文件夹中获取图片名称 - 然后在其中查找数字,然后分别将每个数字插入 MySQL 表中

PayPal API 返回 RESOURCE_NOT_FOUND/INVALID_RESOURCE_ID 但交易列在 Sandbox Business 帐户中

php - Paypal API : This transaction cannot be processed due to an invalid merchant configuration

javascript - 表单验证不验证

php - 如何避免创建重复行?

ios - Paypal Ruby SDK 未获取刷新 token

java - PayPal:callBack url 和 returnurl 有什么区别?

paypal - 简单的支付流程 Paypal

Paypal 定期付款沙箱对信用卡设置限制