1

我已经为这个问题奋斗了五天了。这对我来说是个谜。任何人都可以找出为什么此代码返回 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;

?>

4

1 回答 1

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

应该:

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
于 2013-09-11T15:31:41.657 回答