Paypal IPN listener with Zend Framework

Below is a fully working code for creating a Paypal Instant Payment Notification listerner using Zend Framework:

* Handle paypal response and return true if ok
* @return bool
function isPaypalIPNMsgValid()
$client = new Zend_Http_Client(PAYPAL_IPN_URL, array(
 'maxredirects' => 0,
 'timeout'      => 250,
 'rfc3986_strict' => false)); //not rfc3986_strict necessary to be replicate with paypal input message

 global $data;
 $data['cmd'] = '_notify-validate';
 foreach ($_POST as $key => $value) { // 'cmd' arg must be first => we add other POST entries after it
  $data[$key] = $value;

 $response = $client->request('POST'); // query paypal for transaction informations

 if ($response->isSuccessful() && $response->getBody() == 'VERIFIED') {
  return true; // OR to handle only some IPN message types: return isset($data['txn_type']) && in_array($data['txn_type'], array('express_checkout', 'web_accept'));
 return false;

if (!isPaypalIPNMsgValid()) {


One Comment Trackback URL | Comments RSS

  1. Thanks Says:

    Thanks for a very understandable code; nice work 🙂

Post a Comment

Your email is never published nor shared. You're allow to say what you want...

Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/remydamo/websites/qc4blog/www/wp-content/plugins/sweetcaptcha-revolutionary-free-captcha-service/library/sweetcaptcha.php on line 81

Warning: fsockopen() [function.fsockopen]: unable to connect to (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/remydamo/websites/qc4blog/www/wp-content/plugins/sweetcaptcha-revolutionary-free-captcha-service/library/sweetcaptcha.php on line 81