MicahCarrick / PHP-PayPal-IPN

PHP 5 class to listen for and handle Instant Payment Notifications (IPN) from PayPal.
BSD 3-Clause "New" or "Revised" License
419 stars 211 forks source link

cURL not returning 200 status but no error either #3

Closed Quixotix closed 13 years ago

Quixotix commented 13 years ago

Issue from Sandro originally posted on my Blog http://www.micahcarrick.com/paypal-ipn-with-php.html

I used your new ipnlistener: https://github.com/Quixotix/PHP-PayPal-IPN/blob/master/ipnlistener.php But the respons is always the same as: But, I still get the same (when I use cURL) response, as:

[16-Sep-2011 17:36:40] PayPal IPN: Invalid response status: 0 :-(
Quixotix commented 13 years ago

I'm wondering if perhaps cURL is returning an integer for the response code rather than a string as a user has reported in the PHP docs. I am going to put a string cast on that, however, I will need Sandro to test the fix.

Quixotix commented 13 years ago

Sandro,

Can you do the following for me? First, use this new ipnlistener.php https://github.com/Quixotix/PHP-PayPal-IPN/blob/master/ipnlistener.php

Next, add this code to line 91, right before the if block:

foreach (curl_version() as $key => $value) {
    if (is_array($value)) $value = implode(", ", $value);
    error_log("cURL $key: $value");
}
error_log('cURL Response: '.$this->response);
error_log('cURL Status: '.$this->response_status);

Then run your IPN test and look in the error log. Can you send me that information?

Quixotix commented 13 years ago

We now know that the error is:

cURL error: [52] GnuTLS recv error (-9): A TLS packet with unexpected length was received.

There are quite a few others who have had this problem with cURL and paypal when cURL is built on GnuTLS rather than openSSL. One possible workaround...

curl_setopt($c, CURLOPT_SSLVERSION, 3)

But I don't think I want to explicitly set the SSL version in the IPN class itself. I think I need a way to set additional curl options based on individual needs.

Quixotix commented 13 years ago

This issue has been resolved. Simply this to your ipn listener script

$listener->force_ssl_v3;