Debugging PayPal IPN in Magento

Debugging PayPal IPN in Magento © by kakaopor/sxc

Probably one of the most used payment options (gateways) within Magento, and most likely every other cart system is the PayPal. This payment gateway is built into the default Magento installation. All you need to do is to punch in few configuration options under “System > Configuration > Payment methods“ and you are ready to go.

Great thing about the PayPal – Magento relation is the IPN feature of the PayPal itself. By definition IPN stands for Instant Payment Notification. Its a feature of PayPal that allows you to integrate your PayPal payments with your website’s back-end operations, so you get immediate notification and authentication of the PayPal payments you receive.

Luckily IPN itself is supoorted in Magento by default.

All this is great until you hit the wall with getting your orders not to update their status as they should. For instance, PayPal can send your Magento a certain IPN message and your Magento might not respond to it accordingly. This is the scenario where you need to get your hands dirty and start debugging.

A good starting point might be the Mage_Paypal_IpnController located under the app/code/core/Mage/Paypal/controllers/IpnController.php file. Within it there is only one action called indexAction(). There are merely a few lines of code inside this action which makes it pretty easy to understand. As you can see, it merely checks if the POST data exists and if it does then it passes it along to the Mage_Paypal_Model_Ipn model and its processIpnRequest() method located under the app/code/core/Mage/Paypal/Model/Ipn.php file, around line 98.

So how do you see your full IPN message withouth going into the PayPal admin interface each time? You can simply replace the indexAction() of Mage_Paypal_IpnController from:

public function indexAction()
	if (!$this->getRequest()->isPost()) {
	try {
		$data = $this->getRequest()->getPost();
		Mage::getModel('paypal/ipn')->processIpnRequest($data, new Varien_Http_Adapter_Curl());
	} catch (Exception $e) {

into something like:

public function indexAction()
	if (!$this->getRequest()->isPost()) {
		Mage::log("PayPal IPN no POST data, at ".time().".", null, "paypal_ipn_blank.log");
	try {
		$data = $this->getRequest()->getPost();
		Mage::log("PayPal IPN POST data: ".print_r($data, true).".", null, "paypal_ipn.log");
		Mage::getModel('paypal/ipn')->processIpnRequest($data, new Varien_Http_Adapter_Curl());
	} catch (Exception $e) {
		Mage::log("PayPal IPN error: ".$e->getMessage().".", null, "paypal_ipn_error.log");

This will get your IPN related stuff nicely separated into special log files making them easier to debug. From here you can proceed to the processIpnRequest() method of the Mage_Paypal_Model_Ipn model doing similar until you reach the point where you might spot your bug in the Magento or your custom code that possibly broke the IPN functionality on Magento side.

Surely some of you will apply different, possibly better method, this is just one way of handling it.

Hope some of you find it useful.

p.s. This article was written with Magento version in mind. Other versions of Magento might have things (models/controllers) in different places.


You made it all the way down here so you must have enjoyed this post! You may also like:

How To Connect Google Analytics 4 To Magento 2 Bojan Mareljic
Bojan Mareljic, | 35

How To Connect Google Analytics 4 To Magento 2

3 best open-source eCommerce platforms in 2021 Zrinka Antolovic
Zrinka Antolovic, | 7

3 best open-source eCommerce platforms in 2021

eCommerce Returns Management – a simple solution from the Fashion industry Zrinka Antolovic
Zrinka Antolovic, | 12

eCommerce Returns Management – a simple solution from the Fashion industry


  1. Hello, i am creating the mobile, app. i have added the paypal module in app , and i am using the magneto. i am getting paid by paypal and returing the paypal transaction id. but i dont know how to set that id with magneto order (order either created by coding or Order creatind by magneto soap api v1) can you help me? so payal update the order directly when payment is done.

  2. Hi Dear,

    I need your help for how can I customize the PayPal payment notification email which is received by merchant. I want to display my website URL in that email.

  3. Did anyone managed to figure out how to fix IPN issue in latest Magento release All of our orders are stuck in Pending Payment, and information Magento give s to setup IPN does not work!

  4. How to fix this please help me …

    exception ‘Exception’ with message ‘PayPal IPN postback failure. See paypal_unknown_ipn.log for details.’ in \app\code\core\Mage\Paypal\Model\Ipn.php:156
    Stack trace:
    #0 \app\code\core\Mage\Paypal\Model\Ipn.php(114): Mage_Paypal_Model_Ipn->_postBack(Object(Varien_Http_Adapter_Curl))
    #1 \app\code\core\Mage\Paypal\controllers\IpnController.php(43): Mage_Paypal_Model_Ipn->processIpnRequest(Array, Object(Varien_Http_Adapter_Curl))
    #2 \app\code\core\Mage\Core\Controller\Varien\Action.php(419): Mage_Paypal_IpnController->indexAction()
    #3 \app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch(‘index’)
    #4 \app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
    #5 \app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
    #6 \app\Mage.php(683): Mage_Core_Model_App->run(Array)
    #7 \index.php(87): Mage::run(”, ‘store’)
    #8 {main}

  5. Dear Friend,

    I am using magneto and Themeforest shopper theme v 1.1 which is available to download, I am updating my site

    to this theme right now I am working on my localhost xampp on windows xp.

    The problem i am facing is this that i tried to set up PayPal payment option on the admin panel as paypal standard but

    paypal option is not visible on the payment option in the theme where we do payment.

    I have integrated cc avenue and it is working fine as i have to made changes after downloading the kit form the cc

    avenus as per the pdf document provided by them.

    There are other option which are visible in the front end when i select yes option on the admin panel like :- saved

    cc, cash on payment etc but only pay pal is not visible in the front.

    Just to add in i have used all different currency like Indian Rupee, USD, Pound etc but still paypal option is not

    visible, I want to use pay pal for all the currency even for Indian Rupee is it possible.

    I am attaching an attachment showing options but no Paypal and I am using USD as a currency option.

    Need help as i am trying to change to this theme of shopper by this month of may.

    Photo Attached : –


  6. Well, we seem to be having issues with the PayPal IPN being stuck on ‘Retrying’ when our customers make purchases through Ebay. PayPal is sending the notification but our listener is not recognizing the order ID since it was not made on the site so it does not respond back. Wondering if anyone can lead me in the right direction to add something to the listener to respond back to PayPal saying ‘OK’. After four days of ‘retrying’, paypal shuts the IPN off.


  7. Thanks for the tip, we had a couple orders that didn’t update in Magento but were successful. They were causing the exception “PayPal IPN postback failure.” so after tracing the stack, they were being caused in the Ipn Model in the _postBack function here: if ($response != ‘VERIFIED’) {

    So I also suggest adding in this log: just before that line: Mage::log(“PayPal IPN Post back debug: “.print_r($this->_debugData, true), null, “paypal_ipn_postback.log”);

  8. As allways, thank you for quality articles.

    Andy – You pretty much just saved my life! I was going insane over this! And found out that the registered e-mail was with a capital first letter.. jesus… How stupid is this.

    anyways, thanks!

  9. I have found this error in exception log when i install ( copy ) it..It makes the whole site down. Please help..!!

    Mage_Core_Exception’ with message ‘Mage registry key “_singleton/Empty_Cart_Model_Observer” already exists’ in /var/www/vhosts/

  10. Thanks Branko – again.
    This helped me find my error in code, since there is no other way of debugging IPN, and it helps to be able to see what is happening. I agree with Tomislav – a good example of Mage::log usage!

  11. What a completely useless article.

    Since no default paypal gateway updates the order status to ‘complete’ upon a successful IPN verification, maybe you could have shown us something more specific instead of super basic debugging techniques.

  12. Hey everyone!

    Well after few ours into this im going crazy this is whats happening, i have imported all my products to magento , all seamed to be fine in the front and back office, until some paypal orders starting to arrive. For some reason when checking out, some products don’t appear in the description list of the paypal website checkout like no items. Not even the shipping is there… but this is not happening on all products, so i went to de specific product they bought check everything and did not see anything out of the ordinary, clicked saved then i saw category tree checked list disappear, i re-checked the categories hit save and then try to do a purchase with this product and bam! Details where passed to paypal website checkout….. i know is super weird can someone please help me? i have 10,000 products.

    paypal log shows this difference

    after saving the products this appears on the variables

    [item_number_1] => 461994
    [item_name_1] => PINK SUGAR
    [quantity_1] => 2
    [amount_1] => 11.81
    [item_number_2] => Vous avez le choix entre: – La Poste – Colis Standard, Livraison entre 7 et 12 jours
    [item_name_2] => Livraison
    [quantity_2] => 1
    [amount_2] => 15.00

  13. One tip that a few of our customers have fallen foul of:

    your paypal email address as registered with paypal and your paypal email address as entered into the Magento backend are case sensitive.

    So you if you register with paypal as

    you must enter the exact same info into the magento backend.

    Drove me slightly mad the 1st time I came across this.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.