payflow pro api - curl problem

I'm having a hard time getting this code to work.

All I'm trying to do initially is make the provided example work on my server with my payflow pro login info. I know my login info is valid and works and I know curl is enabled on my server. I did a test to to check curl and it returned headers fine (see code).

I've gone through every part payflow_curl.php and it works fine up to the actual curl request but for some reason the request doesn't seem to be going through. The only thing $headers returns is the url and a filename value of -1. All other values are 0

Any help would be greatly appreciated. Thanks.

// test example that worked.
$ch = curl_init('');
$headers = curl_getinfo($ch);
// code from api that doesn't work
      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_URL, $this->submiturl);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
      curl_setopt($ch, CURLOPT_HEADER, 1); // tells curl to include headers in response
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
      curl_setopt($ch, CURLOPT_TIMEOUT, 45); // times out after 45 secs
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // this line makes it work under https
      curl_setopt($ch, CURLOPT_POSTFIELDS, $plist); //adding POST data
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2); //verifies ssl certificate
      curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE); //forces closure of connection when done 
      curl_setopt($ch, CURLOPT_POST, 1); //data sent as POST 
      $result = curl_exec($ch);
      $headers = curl_getinfo($ch);

Open in new window

Who is Participating?
sstahnkeAuthor Commented:
OK. After a long wait the problem has been diagnosed and solved. The server started returning the message "Protocol https not supported or disabled in libcurl" My host was able to re-compile apache with curl ssl support and now the script works fine.
Ray PaseurCommented:
As with most things, it is helpful to see the ACTUAL code used in the test case.  This appears to be a very abbreviated segment.  Wouldn't there be a class and some conditional logic also?  If you can post that, we might be able to help.  

The README file indicates that if you don't get a response, you can simply re-submit the transaction.  What happens when you do that?

Would we be on firm ground in understanding that you have contacted Radu Manole and there was no help there?

Here is the README file:
Implementation of PayFlow API with PHP and CURL using the HTTP protocol (no SDK needed)

The script implements the HTTPS protocol, via the PHP cURL extension.

Check payflow_examples.php file for different transactions you can use.

The URLs to use are:
for testing:

The nice thing about this protocol is that if you *don't* get a
$response, you can simply re-submit the transaction *using the same
REQUEST_ID* until you *do* get a response -- every time PayPal gets
a transaction with the same REQUEST_ID, it will not process a new
transactions, but simply return the same results, with a DUPLICATE=1
parameter appended.

API rebuild by Radu Manole,, March 2007

Many thanks to Sieber Todd,

Best regards, ~Ray
sstahnkeAuthor Commented:
I have contacted Radu and he had some helpful ideas about checking permissions etc on the server. I have also been able to do a successful use of the test code from my local testing server (with all ports open) which seems to reinforce the idea that there is a port that is blocked or a conflicting permission issue on my server. I will post more info as I get it.
Ray PaseurCommented:
Great.  That is progress.  Bring this to the server tech support folks, too.  Good luck with it, ~Ray
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.