Paypal返回API凭据不正确

时间:2013-09-11 13:21:25

标签: php api paypal credentials paypal-adaptive-payments

我现在已经和这个问题打了五天了。这对我来说是个谜。任何人都可以找出为什么此代码返回error52003,API凭据不正确?非常感谢您的帮助或新观点。

<?php

$USER_ID="userid";
$USER_PASS="userpass";
$USER_SIG="usersig";
$APP_ID="appid";

$apiUrl="https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";

$headers = array(
    "X-PAYPAL-SECURITY-USERID: ".$USER_ID,
    "X-PAYPAL-SECURITY-PASSWORD: ".$USER_PASS,
    "X-PAYPAL-SECURITY-SIGNATURE: ".$USER_SIG,
    "X-PAYPAL-APPLICATION-ID: ".$APP_ID,
    "X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
    "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON"
);

$createPacket = array (
    "actionType"=>"PAY",
    "currencyCode"=>"EUR",
    "receiverList"=> array (
        "receiver"=> array(
            array(
                "amount"=> "1",
                "email"=>"merchant1@someemail.sk"
            ),
            array(
                "amount"=> "2",
                "email"=>"merchant2@someemail.sk"
            )
        )
    ),
    "returnUrl"=>"https://www.sandbox.paypal.com/",
    "cancelUrl"=>"https://www.sandbox.paypal.com/",
    "requestEnvelope"=>array(
        "errorLanguage"=>"en_US"
    )
);


$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($createPacket));
    curl_setopt($ch, CURLOPT_HEADER, array($headers));

    $result= curl_exec($ch);

    curl_close($ch);

    echo $result;

&GT;

1 个答案:

答案 0 :(得分:0)

curl_setopt($ch, CURLOPT_HEADER, array($headers));

应该是:

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);