Many of our cleints reported this issue who are using Magento version 1.6.x, 17.x and 1.8x. We received complaints saying that their customers did pay full amount of order in PayPal but order status is still showing pending payment in Magento backend. This is a big issue especially for those who are using bookkeeping system synchronized with Magento. Generally booking system would update itself once Magento order status changes and when invoice is generated. In above case none of them is happening and order status shows pending payment.  The user has to manually trace this order in PayPal then follow up with customer and then have to manually enter in their bookkeeping system. This sounds lengthy and hassling process after spending so much time and money in integration.

To get more information about issue lets first check how Magento works with PayPal. Actually it’s a lot similar how PayPal works with any other standard Ecommerce platforms.

  • When customer clicks on place order from checkout, Magento creates an order in system with status pending payment. Invoice is not created at this stage.
  • Magento then sends order information to PayPal (With customer info, product info, shipping info ..etc)
  • Customers are either redirected to PayPal site in case of express checkout or stay on Magento site in case of hosted pro solution.
  • When customers are done with payment PayPal sends a notification to Magento which is called INP (Instant payment notification) with random number (key, transaction id, message id).
  • When IPN is send to Magento then it will not process it directly. It sends back message to PayPal in order to verify that IPN which is called post back.
  • PayPal confirms that post back by sending message “Verified”. Once Magento gets this confirmation message it creates invoice in system and changes the order status to “Processing”.

In our case the issue was at step 5. The callback to Paypal was failing it was giving various error like

[postback_to] => https://www.paypal.com/webscr
[postback_result] => HTTP/1.1 500 Internal Server Error
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 284
Expires: Thu, 18 Feb 2016 22:40:38 GMT
Date: Thu, 18 Feb 2016 22:40:38 GMT
Connection: close
Strict-Transport-Security: max-age=63072000

<HTML><HEAD>
<TITLE>Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error – Read</H1>
The server encountered an internal error or misconfiguration and was unable to
complete your request.<P>
Reference&#32;&#35;3&#46;8855434d&#46;1455835238&#46;47ac536f
</BODY></HTML>

[exception] => PayPal IPN postback failure. See paypal_unknown_ipn.log for details.
[__pid] => 31140
)

We had a long discussion with paypal support about this and finally found that its actually issue of callback url used in old magento PayPal module.  Call back URL was “https://www.paypal.com/webscr” and on our review of latest Magento source code we found new url which is “https://www.paypal.com/cgi-bin/webscr”.  We changed this url  in appcodecoreMagePaypalModelConfig.php. That’s it 🙂 It solved our issue of pending payment.