0

Currently using PHP + cURL to test the NVP SetExpressCheckout Paypal feature (sandbox mode) on xampp, no matter what I do, I receive the following error:

Error Code 10002 : Authentication/Authorization Failed. You do not have permission to make this API call.

$nvp = array(
    'METHOD' => 'SetExpressCheckout',
    'VERSION' => '98',
    'USER' => $user,
    'PWD' => $pwd,
    'SIGNATURE' => $signature,
    'RETURNURL' => $returnurl,
    'CANCELURL' => $cancelurl,
    'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
    'PAYMENTREQUEST_0_AMT' => '20.00',
    'PAYMENTREQUEST_0_CURRENCYCODE' => $currency,
    'REQCONFIRMSHIPPING' => '0',
    'NOSHIPPING' => '1',
    'ALLOWNOTE' => '0',
    'LOCALECODE' => 'US'
    'L_PAYMENTREQUEST_0_NAME0' = 'A product name';
    'L_PAYMENTREQUEST_0_AMT0' = '20.00';
    'L_PAYMENTREQUEST_0_QTY0' = '1';
    'L_PAYMENTREQUEST_0_ITEMCATEGORY0' = 'Digital';
);

$request = 'https://api-3t.sandbox.paypal.com/nvp?' . http_build_query($nvp);
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $request);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = urldecode(curl_exec($curl));

curl_close($curl);

The weird thing is if I type curl request(the same as $request variable) in the browser I get the SUCCESS and token from the endpoint, I don't know if it has something to do with the curl itself or if it's something else, I tried to completely disable my firewall but the error persists...

Mike Chip
  • 23
  • 3
  • Try logging the raw request that you are sending out to make sure nothing is gettin chopped off in the request. Also, do you have the correlation id that is being returned, I can check the logs to see if there is any indication of any issues on my end. – PP_MTS_Chad Jul 11 '13 at 00:26
  • After logging the request made by the curl function I've found the problem: the http_build_query() function was replacing '&' by '&'... after fixing that it successfully got the proper token. Thank you!! – Mike Chip Jul 11 '13 at 01:02

1 Answers1

0

Your array is malformed.

'L_PAYMENTREQUEST_0_NAME0' = 'A product name';

That's a good way to start debugging