Security header is not valid & L_SEVERITYCODE0 = Error

vinfoakhilesh
Contributor
Contributor

I am gettign this error : 

TIMESTAMP=2020%2d04%2d24T09%3a11%3a10Z&CORRELATIONID=d30d90d46b6e7&ACK=Failure&VERSION=123&BUILD=53802284&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security%20error&L_LONGMESSAGE0=Security%20header%20is%20not%20valid&L_SEVERITYCODE0=Error


but when I hardcode merchant email , then it runs finely. can anybody help me what I am missing.


$url = 'https://api-3t.sandbox.paypal.com/nvp';
$data = array(
'USER' => PAYPAL_EMAIL,
'PWD' => PAYPAL_PASSWORD,
'SIGNATURE' => PAYPAL_SIGNATURE,
'METHOD' => 'GetTransactionDetails',
'VERSION' => '123',
'TransactionID' => $txnid
);
$data = http_build_query($data);

return $transactionInfo = make_post_call($url,$data);
}

function make_post_call($url, $postdata) {
global $token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSLVERSION , 6);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$token,
'Accept: application/json',
'Content-Type: application/json'
));

curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$response = curl_exec( $curl );
//print_r($response); //IM NOW RECEIVING OUTPUT, however symbols are now being replaced by placeholders such as '%40', how can i prevent this?
return $response;
// if (empty($response)) {
// die(curl_error($curl)); //close due to error
// curl_close($curl);
// } else {
$info = curl_getinfo($curl);
//echo "Time took: " . $info['total_time']*1000 . "ms\n";
curl_close($curl); // close cURL handler
if($info['http_code'] != 200 && $info['http_code'] != 201 ) {
echo "Received error: " . $info['http_code']. "\n";
echo "Raw response:".$response."\n";
die();
//}
}

Login to Me Too
1 REPLY 1

MTS_Rob
PayPal Employee
PayPal Employee

Hi @vinfoakhilesh

The 10002 error you are seeing is due to incorrect API credentials in the header. I saw in the code snippet you posted that you may be trying to use the PayPal username and password in the API call, but the API needs the API username and API password. These get generated in the PayPal account. Please follow the steps here to create/view credentials, then update the request with those credentials. That should fix the 10002 error you are seeing.

 

Thanks,

Rob - PayPal MTS

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.