magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

PayPal IPN's not working correctly. Paypal showing Error 500 #30335

Closed alakhdeveloper closed 3 years ago

alakhdeveloper commented 3 years ago

Preconditions (*)

  1. Magento 2.3.5
  2. PHP v7.3
  3. Ubuntu 17.10

Steps to reproduce (*)

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

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.

When paypal tries to update the order status on magento, PayPal will hit the IPN url: https://www.example.com/paypal/ipn

When paypal hits the IPN url, Magento is throwing a 500 Error.

On Magento, the file that is being hit by the IPN URL is "vendor/magento/module-paypal/Controller/Ipn/Index.php"

Here is the function in the Magento Ipn/Index.php:

/**

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

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

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.

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(

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.

Expected result (*)

  1. Expected, when Paypal hit the IPN url https://www.example.com/paypal/ipn to Magento, for Magento to then mark the payment from "Pending Payment" to "Processing". Magento should not throw 500 error.

Actual result (*)

  1. Paypal IPN throwing 500 error.

The issue is with the PayPal IPNs. Paypal IPN is showing a 500 error. When I dig into the code, I found Paypal is hitting the IPN URL and the invoice_id (order increment id) is not found.. However in the admin interface, the order_id exists, but it's throwing a 500 error response.

Magento seems to have a bug with the Paypal IPN.

Please help me look into it.

m2-assistant[bot] commented 3 years ago

Hi @alakhdeveloper. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

alakhdeveloper commented 3 years ago

Summary of the issue 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. When the paypal hit the IPN url EX: url: https://www.example.com/paypal/ipn

Magento is throwing a 500 Error

Information on your environment We are using Magento 2.3.5

Steps to reproduce 1) Install the vanilla Magento 2) add the product in admin 3) configure the Paypal Payments Pro 4) Go to the frontend, and add the product in cart. 5) Go to the checkout page, and Place order with the Paypal Credit Card. 6) Go to the paypal IPN History and check all the IPN status showing 500 Error 7) Also, when you try to capture the funds in Magento it throws a "Field format error: ORIGID missing". You then have to capture the funds in Paypal for an IPN to feed back to Magento to complete the order.

Expected and actual results Once the order Placed with Magento by customers. Then the paypal IPN history didn't show the 500 Error. The IPN url show work properly.

Please help

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!