Magento 1.8 PayPal IPN – Fixing 500 Error in Notifications

ipnmagento-1.8paypal-standard

I am facing an issue with Paypal IPN message in Magento 1.8.1. When I placed the order with Paypal the Order status still shows Pending even I have set the IPN notification URL to http://www.devdomain.com/paypal/ipn/. Also try to place the IPN script in my root folder but no success. 🙁

I am using Paypal Standard. When I see inside the Paypal it shows 500 error in IPN history page.

Please advise how I can resolve this issue.

Best Answer

Finally I found the solution after reviewing in deep. This was cause to due "USER Agent" HTTP Header in request. You can update this on Ipn.php file. Just replace the below line from this function on app/code/core/Mage/Paypal/Model/Ipn.php (Don't apply on core file. Add it on local dir)

protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)

at line 143 (in magento 1.8.1)

$httpAdapter->write(Zend_Http_Client::POST, $this->_config->getPaypalUrl(), '1.1', array(
                'Connection: close',
            ), $sReq);

replace with

$httpAdapter->write(Zend_Http_Client::POST, $this->_config->getPaypalUrl(), '1.1', array(
                'Connection: Close', 'User-Agent: your_company_name'
                ), $sReq);
Related Topic