0

I try to set up a Paypal payment method on a website I'm working on.

However when I send a cUrl request in PHP to the sandbox I get this cUrl error :

Error 77 : Problem with the SSL CA cert (path? access rights?)

Here is my code :

$request = "&USER=myUser".
            "&PWD=myPwd".
            "&SIGNATURE=mySignature".
            "&METHOD=SetExpressCheckout".
            "&CANCELURL=myCancelUrl".
            "&RETURNURL=myReturnUrl".
            "&PAYMENTREQUEST_0_AMT=myPaymentAmount".
            "&PAYMENTREQUEST_0_CURRENCYCODE=EUR".
            "&PAYMENTREQUEST_0_PAYMENTACTION=SALE".
            "&LOCALECODE=countryCode".
            "&VERSION=122";

$ch = curl_init("https://api-3t.sandbox.paypal.com/nvp");

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

    $result_paypal = curl_exec($ch);

if(!$result_paypal)
        echo 'Error '.curl_errno($ch).' : '.curl_error($ch);

Paypal sandbox url, credentials, url parameters are fine as when I click my express checkout button I get the token in the opened page :

TOKEN=EC%2d7NT30345MB*******&TIMESTAMP=2015%2d05%2d28T11%3a36%3a57Z&CORRELATIONID=b539dd0******&ACK=Success&VERSION=122&BUILD=16837281

Facts :

  • request is fine, obviously (I get back the token),
  • As I use a signature in the call I shouldn't need a certificate,
  • Tried with and without the ? at the end of the URL (and did modify accordingly my call)
  • Changed CURLOPT_SSL_VERIFYPEER to 1 and 0, didn't change anything
  • Tried http_build_query() with an array of parameters, same result

I don't know what I could have missed.

Did anyone encounter this ?

Stephan B
  • 3,671
  • 20
  • 33
user3241019
  • 811
  • 9
  • 20
  • What happens if you change `curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);` to `curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);`? – Anthony May 28 '15 at 11:53
  • Also, you could create your POST variable list as an array and curl will automatically change it to the query string format for you. – Anthony May 28 '15 at 11:59
  • Edited my post with your feedbacks, sadly I already had tried those options – user3241019 May 28 '15 at 12:52
  • I'm going to update your code to make it clear what I meant. – Anthony May 28 '15 at 12:54
  • Testing the code as I edited it, there is no curl error response, just the returned query string. – Anthony May 28 '15 at 13:12
  • 1
    @Anthony Please do not edit the question, this makes it hard to see the source problem without looking at the history. Provide an answer instead. – Stephan B May 28 '15 at 13:20
  • I warned him I would. They can revert if needed. @user3241019 - Try installing a local cert for curl, as found at: http://curl.haxx.se/docs/caextract.html I did that awhile back and maybe that's why I'm not seeing the same thing. – Anthony May 28 '15 at 13:21
  • possible duplicate of [PHP Problem with the SSL CA cert (path? access rights?)](http://stackoverflow.com/questions/7179216/php-problem-with-the-ssl-ca-cert-path-access-rights) – Stephan B May 28 '15 at 13:26

0 Answers0