By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

secure post with PHP and curl (to Paypal IPN)

P: n/a
HI

I have 2 problems, 1 of which is tied to PHP and 1 loosely tied, so
I'll put this out there.

Got a problem that I have been working on for a while now which
involves implementing the Paypal IPN. I am using PHP 4 to automatically
post back to Paypal and I am using curl package.

I am doing a Custom request and would like to know if anyone has
successfully posted data back to paypal with curl and got something
other than INVALID back. I am always getting INVALID!! :(

I am doign EVRYTHING they tell me to.. ie ordering the parameters and
adding the cmd=_notify-validate

I guess I have 2 questions:

1. Am I using curl properly with this paypal interface or is there
something I am not setting.
2. Has anyone a working version with HTTPS/curl/paypal. I am using the
https://www.eliteweaver.co.uk/testing/ipntest.php to test this.

The code is as follows:

// put all POST variables received from Paypal back into a URL $post =
array();

foreach ($this->paypal_post_vars as $field => $value) {
array_push($post,$field."=".rawurlencode(stripslas hes($value)));
}

array_push($post,"cmd=_notify-validate");
$uri = implode("&",$post);
$ch=curl_init();
$this->error_out($uri);

curl_setopt($ch, CURLOPT_URL, $this->url_string);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $uri);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

$this->paypal_response = curl_exec($ch);
$this->error_response = curl_error($ch);
curl_close($ch);

$this->error_out($this->paypal_response);

Sep 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.