ID:1423072
 
So, I've been having some trouble getting this to work.
index.php
<?php

//Paypal IPN Tutorial
// http://jream.com

/**

How it Works

1: A user buys something from your BUY button
2: The BUY button is configured with a URL for PayPal to go to when complete
3: The CALLBACK is on our site (This Page). It queries Paypal to see the result of the transaction just made.
4: If it is good, we update some kind of record.

**/


require 'Paypal_IPN.php';
echo "done";
$paypal = new Paypal_IPN('sandbox');
echo "1";
$paypal->run();
echo "2"; // does not echo 2
?>


Paypal_IPN.php
<?php

class Paypal_IPN
{
/** @var string $_url The paypal url to go to through cURL*/
private $_url;

/**
* @param string $mode 'live' or 'sandbox'
*/

public function __construct($mode = 'live')
{
if ($mode == 'live')
$this->_url = 'https://www.paypal.com/cgi-bin/webscr';

else
$this->_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
}

public function run()
{
$postFields = 'cmd=_notify-validate';

foreach($_POST as $key => $value)
{
$postFields .= "&$key=".urlencode($value);
}

$ch = curl_init();

curl_setopt_array($ch, array(
CURLOPT_URL => $this->_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields
));

$result = curl_exec($ch);
curl_close($ch);

echo $result;
}
}
?>


It doesn't echo "2" at index.php. I'm running this on my own computer with apache and an actual site pointing to my IP address.
Obvious questions first, you have PHP installed and a PHP handler in your apache config, right?
phpinfo() works. PHP Version 5.5.3-1ubuntu2. As for a PHP handler, not sure.

display_errors Off
display_startup_errors Off

I have also been trying to get those two to say On but changing php.ini and restarting apache doesn't change them. Which is ticking me off.
Hang on. Is this on Windows, or Linux, or?
Linux.
http://stackoverflow.com/questions/12573502/ where-is-php-ini-on-ubuntu

Google helps. Seems you might be updating one that it doesn't care about. I'll chalk it up to "reasons not to use Ubuntu" again.
Lol. You realize that's in my history already? :P I read that using php --ini will list my configuration files but not load them. Researched some more on google and found out that "service apache2 restart" is how you restart. But, I'm using ajenti to host my apache2. It's still all locally, just makes managing it easier. Regardless, "service apache2 restart" should work. But, I'm not 100% positive on that theory.

Where I went: http://stackoverflow.com/questions/8684609/ dude-wheres-my-php-ini

I did a fair amount of research already. And still so mad that it doesn't work.
Oh .... ajenti. You probably don't want to do that. But yes, you need to restart the apache process to get it to reload PHP configuration, as PHP is a shared library within that process.
Restarted it about 10 times. Even shutdown apache and started it up again.

Also, why shouldn't I use ajenti? Just curious.
Because it adds yet another layer (and so, bugs, incompatibilities) between you and the actual processes you wish to manage.

If the value isn't updating in phpinfo, then you're not editing the correct file, basically.
Was editing /etc/php5/cli/php.ini and not /etc/php5/apache2/php.ini. It works now. Now to test on...
done1
Fatal error: Call to undefined function curl_init() in /var/www/ipn/Paypal_IPN.php on line 29


I guess I need to install cURL?

phpinfo() says:
cURL Sterling Hughes

Under module authors. Not sure if that means that it's recognized or if it's just part of a predefined list of credits.

Edit: I ran "apt-get install php5-curl" and now the web page returns "done1INVALID2". It's working now. Thanks lol.