0

Magento 2.3.5 seems to have a bug with the Paypal IPN.

  1. When the customer place an order through checkout, the Credit Card order is processed through paypal. The order is created successfully as expected in the Magento backend and in paypal. This includes the payment record which captures the funds.
  2. When paypal tries to update the order status on magento, PayPal will hit the IPN url: https://www.example.com/paypal/ipn
  3. When paypal hits the IPN url, Magento is throwing a 500 Error.
  4. On Magento, the file that is being hit by the IPN URL is "vendor/magento/module-paypal/Controller/Ipn/Index.php"
  5. Here is the function in the Magento Ipn/Index.php: /**
  • Instantiate IPN model and pass IPN request to it

  • @return void */ public function execute() {

    if (!$this->getRequest()->isPost()) { return; }

    try { $data = $this->getRequest()->getPostValue(); $this->_ipnFactory->create(['data' => $data])->processIpnRequest(); // This is where the 500 error is being thrown. $incrementId = $this->getRequest()->getPostValue()['invoice']; $this->_eventManager->dispatch( 'paypal_checkout_success', [ 'order' => $this->orderFactory->create()->loadByIncrementId($incrementId) ] );

    } catch (RemoteServiceUnavailableException $e) { $this->_logger->critical($e); $this->getResponse()->setStatusHeader(503, '1.1', 'Service Unavailable')->sendResponse(); /** @todo eliminate usage of exit statement */ // phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage exit; } catch (\Exception $e) { $this->_logger->critical($e); $this->getResponse()->setHttpResponseCode(500); } }

  1. As you can see, the line: "$this->_ipnFactory->create(['data' => $data])->processIpnRequest();" - This is where the 500 error is being thrown.

  2. When I comment out this line that is throwing the 500 Error, the function no longer throws the 500 error.

  3. I have checked the IPN "processIpnRequest" function and everything looks fine with the code. I am not sure why the "processIpnRequest" function is throwing the 500 error. This is the Magento core code.

  4. When paypal first hits the IPN url, the parameters include a $0 amount and no invoice id. The second time paypal hits the IPN url, the parameters include the $amount of the order and an Invoice ID. In the system.log file, I see an error "The invoice ID is not available". So i added: $incrementId = $this->getRequest()->getPostValue()['invoice']; // add a check for the invoice id "order_increment_id" to get rid of "The invoice ID is not available" error in system.log file. if(empty($incrementId)){ return $this; } $this->_eventManager->dispatch(

  5. Now if I try to process the invoice of the order in Magento, I get "Field format error: ORIGID missing". The only way to complete the order is to capture in Paypal and have the IPN feed back to the order in Magento.

Please let me know if you have any insight.

  • 500 errors should be logged into your webserver error log. There should also be a detailed error message what went wrong (for example "PHP Fatal Error: ...". Based on this, you can either solve this yourself or add the logs to your question. – simonthesorcerer Oct 6 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.