I am using this for the PayPal Express Checkout API, but I get an error:
ACK=Failure&VERSION=78&BUILD=000000&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security%20error&L_LONGMESSAGE0=Security%20header%20is%20not%20valid&L_SEVERITYCODE0=Error
Code:
$request = 'USER=myuser.de&PWD=mypass&SIGNATURE=mysig&METHOD=SetExpressCheckout&VERSION=78&PAYMENTREQUEST_0_PAYMENTACTION=SALE&PAYMENTREQUEST_0_AMT=19&PAYMENTREQUEST_0_CURRENCYCODE=EUR&cancelUrl=http://xyz.biz/index.php?id=16&returnUrl=http://xyz.biz/abc/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api-3t.sandbox.paypal.com/nvp");
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec ($ch);
curl_close ($ch);
What can I do?
Security header is not valid is typically due to having your API credentials entered incorrectly.
curl_setopt($ch, CURLOPT_URL, "https://api-3t.sandbox.paypal.com/nvp");
It looks like you are sending to your live environment. Be sure you are using the correct credentials.
When I use your string and curl call with my credentials I get a positive resposne:
Array
(
[TOKEN] => EC-8JH22470WY0704826
[TIMESTAMP] => 2015-08-11T17:24:08Z
[CORRELATIONID] => 18a347794c5a1
[ACK] => Success
[VERSION] => 78
[BUILD] => 000000
)
OK, I found the website where I can create the necessary Sandbox-account: https://developer.paypal.com/docs/classic/lifecycle/sb_create-accounts/