Magento2: Paypal Payments Pro IPN keeping payments marked as Pending Payment

Created on 20 Sep 2018  ·  87Comments  ·  Source: magento/magento2

Preconditions

  1. Magento CE 2.2.6
  2. PHP v7.1.19-1
  3. Ubuntu 17.10

Steps to reproduce

  1. Set up Paypal Payments Pro Hosted Solution on a clean install of Magento CE 2.2.6
  2. Send a payment using Credit / Debit Card through the solution checking out as guest. EDIT: Both Paypal payments and Credit / Debit card payments through express checkout and payments pro are experiencing the same issue.

Expected result

  1. Expected, when Paypal sends the IPN to Magento, for Magento to then mark the payment from "Pending Payment" to "Processing"

Actual result

  1. IPN is returning back to Magento successfully, as per screenshots below, but Magento is keeping the payment marked as "Pending Payment"
    9a28fafd9acbef5ddf8f5574c61
    0ef721c20a5f97b34c188fa086b

I have pasted below our debug data relating to this transaction:
https://pastebin.com/Tzg39rjb

As seen in the screenshots, #1 is from Magento showing that the IPN was received and customer was notified, but payment status was not changed. And screenshot #2 is from Paypal IPN history showing that IPN was delivered successfully.

Paypal Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.2.x Reproduced on 2.3.x

Most helpful comment

Its crazy this is still an issue a year on and no one is assigned to it

All 87 comments

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

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

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-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@Sharpy310 do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [x] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label G1 Passed will be added to the issue automatically. Please, edit issue description if needed, until label G1 Passed appears.
  • [x] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add G2 Passed label to the issue by yourself.

  • [x] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [x] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [x] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [x] 6. Add label acknowledged once verification is complete.

  • [x] 7. Make sure that automatic system confirms that report is acknowledged.

Please note I have also replicated this issue using Paypal express payments and Paypal Pro payments using the Website Payments Pro Hosted Solution through Magento

Hi @Sharpy310 I'm able to reproduce following steps you described, I'm have processing status, But also i'm not able to test with Website Payments Pro Hosted Solution. Maybe problem related to this service.

Hi @engcom-backlog-nazar thanks for getting back to me on this, I have checked Paypal status and all their services are running normally, but looking at what's happening is Magento is receiving the IPN notification, but it's not updating the status of the order to processing.
What other information can I send to try to debug this?

@Sharpy310 I'm still not able to reproduce i'm always have processing status, can you reproduce with test credentials on vanilla instance ?

@Sharpy310 Seems like this is identical -> https://github.com/magento/magento2/issues/17349 isnt it ?

@engcom-backlog-nazar Can I double check that you have set up the Paypal solution "Website Payments Pro Hosted Solution" - because I have just disabled that and enabled the "Websites Payments Standard" option and put a payment through and it's worked absolutely fine, but as soon as I put it through "Websites Payments Pro Hosted Solution" it fails.
6bf3676f4788e7fa2311b7efa16

@engcom-backlog-nazar The bug #17349 does appear to be similar, as it's an issue with the IPN but looking at that ticket they are using Paypal Express Checkout, we are using Website Payments Pro Hosted. Both are through Paypal, but are different modules. So I am unsure if they use the same IPN interface as each other or not.

@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-95131, MAGETWO-95132 were created

Having the same problem with the Customweb_SaferpayCw extension. The order and its payment history get updated on succes with the transaction and payment ID, but the sales_order.state, sales_order.status and sales_order_status_history.status stay on 'pending_payment'.

This prevents the Xtento_OrderExport extension from exporting those orders. Not funny.

My current temporary fix consists of a query (1 min cron), which sets those entries to 'processing', if the sales_order_status_history.comment contains a phrase typical for a succesful payment transaction. But that is only a temporary solution.

UPDATE sales_order JOIN sales_order_status_history ON sales_order.entity_id = sales_order_status_history.parent_id SET sales_order.state = 'processing', sales_order.status = 'processing', sales_order_status_history.status = 'processing' WHERE (sales_order_status_history.comment LIKE '%ID de transaction%' OR sales_order_status_history.comment LIKE '%Transaktions-ID:%') AND sales_order.state = 'pending_payment';

@magento-engcom-team It would be really nice, if you post the patch/fix as soon as possible. I guess there are going to be more and more shops having a similar problem with their payments after updating to 2.2.6. Caused by a huge variety of payment extensions, who have external payment pages to do the payment.

And I don't really want any of thoses extension providers (especially those, we use) to implement crazy workarounds in their extensions to cope with the current situation. Which they probably have to do now anyways.

@jhruehl I've just slightly modified your SQL just to match for anyone using Paypal Payments Pro, not the best workaround, but it works. I've done the same and put it on a 1 minute cron. I have also added it to update the sales_order_grid table so that you can see it on the main orders page.

UPDATE sales_order JOIN sales_order_status_history ON sales_order.entity_id = sales_order_status_history.parent_id JOIN sales_order_grid ON sales_order.entity_id = sales_order_grid.entity_id SET sales_order.state = 'processing', sales_order.status = 'processing', sales_order_status_history.status = 'processing' , sales_order_grid.status = 'processing' WHERE (sales_order_status_history.comment LIKE '%IPN Completed%' OR sales_order_status_history.comment LIKE '%Transaction ID%') AND sales_order.state = 'pending_payment';

Having the same issue.
For us it seems to be caused by the following commit:
https://github.com/magento/magento2/commit/f39138b6dc504f93dae9697ad45d11d57f1aaf1f#diff-68f9035e0545c5442dde19b0ba0fa9b4R38

@jasper-multisafepay any fix from your end?

@albsa Workarounds are possible (like setting the state before calling registerCaptureNotification)
But this seems to be a M2 core problem, so I would currently advise waiting for an official patch.

experiencing the same issue here after upgrading from 2.2.5 > 2.2.6

IPN notifications are returning a 200 OK to PayPal but the order status is not updating.

We are experiencing the same issue with different payment providers. After updating from M2.2.5 to M2.2.6 the order status is not changing after the order is successfully paid. Looks like a M2.2.6 issue to me.

We have this issue with payment providers MultiSafePay and Pay. I also found an issue at Mollie with the same issue.

Will there be a fix soon?

The issue seems to be a generic issue which affects all payment gateways / methods which process payments after the order has been created.

We have just updated from 2.2.3 to 2.2.6 and are experincing the same issue - paypal express payments work fine - payments via Website Payments Pro Hosted Solution are not moving to processing despite ACK="success" in the IPN.

I am experiencing the same issue with 2.2.6 and Website Payments Pro.

Note, when Payment Review is on, and a transaction is manually approved in PayPal, followed by 'Get payment update' in Magento, the Order Status changes immediately to 'Complete'.

With Payment review off, a successful transaction results in an Invoice being raised, but order status is 'Pending Payment'.

We have the same problem with Nexi Xpay payment method...

Same issue on Magento 2.2.6 and Paypal Payments Pro.
I'll try @Sharpy310 solution in staging

Today I’m not receive IPN, or get it randomly for some orders.
Did PayPal make some changes?

is there any comment from @magento-engcom-team or this new adobe policy to ignore this sort of dicsussion?

As there is still no solution for this, we will inform at Magento support through Enterprise. I will report the outcome if there is still no fix in the meantime.

Upgraded to 2.2.6 and having the same issue.
Paypal Website Payment Pro orders staying in the pending_payment state and not gettin sent through to processing. @magento-engcom-team what you saying?

I try @Sharpy310 solution but not working!!!
I' cant export my order to currier because of this state, it doesn't accept pending_payment.
I'm struggling. Please give as a solution

@Sharpy310 solution will only work for pay pal pro - if you are not getting IPN Completed or Transaction ID in your order comment history, they you need to adjust the sql to match your circumstances. You want to be sure you are getting paid and and the IPN is working, otherwise your issue is different to this thread.

I'm using Paypal pro hosted solution.
Order is payed
Here a screenshot of an order marked as pending

ipn
ipn_complete

whats the order history look like?

ipn_complete

try the following sql query - @Sharpy310 solution was for english - becareful of the " around completed if you are putting the query into something else - if you need other help please pm as this isn't really relevent to the main thread

UPDATE sales_order JOIN sales_order_status_history ON sales_order.entity_id = sales_order_status_history.parent_id JOIN sales_order_grid ON sales_order.entity_id = sales_order_grid.entity_id SET sales_order.state = 'processing', sales_order.status = 'processing', sales_order_status_history.status = 'processing' , sales_order_grid.status = 'processing' WHERE (sales_order_status_history.comment LIKE '%IPN "Completed"%' OR sales_order_status_history.comment LIKE '%ID transazione%') AND sales_order.state = 'pending_payment';

Thanks @mattyl,
in the meantime I also noticed that there were no quotes in @Sharpy310 query.

thank you so much @mattyl

For PayPal Advanced the SQL solution wasn't sufficient as the user would still get a payment declined error. Even though the card would get charged, the user would receive an error stating their payment was declined. Thus leading to multiple card charges...

For now, we have changed line 38 of vendor/magento/module-sales/Model/Order/Payment/State/RegisterCaptureNotificationCommand.php from:
$state = $order->getState() ?: Order::STATE_PROCESSING; to $state = Order::STATE_PROCESSING; as it was before the update.

Are there any updates on this issue?

It's important that a fix is put in place for this as it's going to disturb the way a lot of people using Paypal Web Hosting Pro process there orders.

The SQL script on a cron job workaround is less than ideal and out of scope for a lot of people that use Magento.

Would we be likely to see a fix for this in Magento 2.2.7 ?

@neilcarpenter007 I've not heard anything as of yet from Magento or the Community team, we're still running the cron as a workaround whilst waiting for the @magento-engcom-team to get a fix up, an update on the status of this would be much appreciated as surely this should be a high priority issue as it's affecting 100% of people using this specific payment module?

Problem reproduced on 2.2.6 on different payment method.

The order history is correct but the order status is not updated :

6 nov. 2018 07:44:41 Processing
Payment Successfully completed
6 nov. 2018 07:44:41 Pending
Payment is authorised waiting for capture

In my Magento 2.2.6 php 7.1.22 is Reproduced only on Paypal Host Pro Solution.
Not affected Amazon Pay or Bank Payment nor COD

This is the only thing stopping me putting the shop live so an update on the fix would be fantastic! Thanks in advance

Numan201's solution worked for me with paypal Payments Pro Hosted Solution. Very easy to do and just took the line from the same file of version 2.2.5

Is anyone getting the multiple IPN requests and IPN warnings when using Numan201's solution?

Sent from my iPhone

On 8 Nov 2018, at 14:14, garyhiggins1970 notifications@github.com wrote:

Numan201's solution worked for me with paypal Payments Pro Hosted Solution. Very easy to do and just took the line from the same file of version 2.2.5


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Not me, just looked through some orders and not seen any issues?

I should have stated in the original post that I expect this fix should solve the issue with other payment methods as well as it appears to be a issue in the core.

I don't understand what that the Magento team is trying to do with that change introduced in 2.2.6 (https://github.com/magento/magento2/commit/f39138b6dc504f93dae9697ad45d11d57f1aaf1f#diff-68f9035e0545c5442dde19b0ba0fa9b4R38).

Made the change suggested by numan201 and works perfectly! Life saver! Thanks @numan201

In our case, this problem also affected the Ingenico ePayments (Ingenico_OPS) module.

Reverting the change to the first line of the method \Magento\Sales\Model\Order\Payment\State\RegisterCaptureNotificationCommand::execute seemed to resolve the issue.

That is, changing line 38 of vendor/magento/module-sales/Model/Order/Payment/State/RegisterCaptureNotificationCommand.php from

$state = $order->getState() ?: Order::STATE_PROCESSING;

to

$state = Order::STATE_PROCESSING;

We used the composer-patches Composer plugin to apply this temporary fix, which we will remove once Magento releases a fix.

We applied Numan201's fix, looks to be working OK (PayPal Hosted Pro).

Doesn't look like it's fixed in 2.3 according to release notes & line 38 of vendor/magento/module-sales/Model/Order/Payment/State/RegisterCaptureNotificationCommand.php is the same as 2.2.6

is there any fix for this?
I experience this issue after updating from 2.1.7 to 2.2.7.

this is very frustrating issue because it happened on the livesite.
many orders stuck on "pending payment" and I found few duplicate order with same status (pending payment but invoice status is paid)
screenshot_20190108_171609
screenshot_20190108_171653
and we keep receiving "payment transaction failed" notification with reason :"approved"
what does it mean?
screenshot_20190108_172204
please fix this magento
magento CE 2.2.7

@harimayco we applied the change suggested by numan201 and works perfectly for us on 2.2.6 ! Life saver! Thanks @numan201

@zipnfc I am glad I was able to help.

Any update on a fix for this? Surprised the issue being so important for many was allowed to be carried from version 2.2.7 to 2.3

Unfortunately the file update from @numan201 does not seem to work in version 2.3 as although the status has changed from 'Processing Payment' it is now 'Suspected Fraud' even though the payment has gone into PayPal with a 200 IPN response and transaction ID updated to Magento. Tried 2 x different cards same each time.

Hi @PathToLife. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • [x] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [x] 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

I've found that orders are saved as pending_payment in the IPN function _registerPaymentCapture()

https://i.imgur.com/9oaxTUS.png

I'm not sure exactly where we should set order status for completed payments, but i found conventions in the same file (\Magento\Paypal\Model\Ipn.php) that does:

_registerPaymentReversal() {$this->_order->setStatus($orderStatus);}

Currently cross referencing with express paypal and invoicing functions to see difference..

@DS2987 did you definitely find the fix did not work on 2.3? Just checking as going to start testing 2.3 this week?

@zipnfc Yes I confirm in version 2.3 although the status has changed from 'Processing Payment' it is now 'Suspected Fraud' even though the payment has gone into PayPal with a 200 IPN response and transaction ID updated to Magento. A proper fix for this issue rather than a workaround would be great.

@PathToLife The origin of the issue is not specifically linked to Paypal, but it extends to anything using the registerCaptureNotification command. It has already been identified in two previous comments by @jasper-multisafepay and @numan201

Take a look at the highlighted line: https://github.com/magento/magento2/commit/f39138b6dc504f93dae9697ad45d11d57f1aaf1f#diff-68f9035e0545c5442dde19b0ba0fa9b4R38

I'd say that reverting that change should fix the issue. The only thing before doing it would be to understand why that modification was done in the first place...

I just wanted to update, I had this very same issue using PayPal pro hosted solution using magento 2.3 and Numan's fix worked for me, order successfully goes to Processing, I saw some users reported with 2.3 it went to suspected fraud but this was not the case for me.

@ajheaton90 - thank so much for confirming this - I will now give this a go. We just put the new Magento 2 shop live (zipnfc.com) at the weekend on 2.2.6 and everything is working perfectly. Really pleased with it but will test on 2.3 now!

Same issue on Magento 2.3.1 with Payplug module using $payment->registerCaptureNotification(...)

Has it been fixed in 2.3.2?
I upgraded last week from 2.2.6 and from now on, all sales are still "Pending payment" with Paypal Express Checkout.

I also noticed this is not possible to manually change the Status of an order. In the drop down list, I can only see "Pending Payment" as an option ... !

Any fix released for this issue? we stuck on 2.2.8 and 2.3.2

Its crazy this is still an issue a year on and no one is assigned to it

Following these steps solved the issue for me.

Step1: Login to paypal

Step2: In the Profile menu on the top right, click Profile and Settings .

Step3: click My selling tools .

Step4: Click the Update link in the Instant payment notifications row , in the Getting paid and managing my risk section.

Step5: Click Choose IPN Settings to specify your listener's URL and activate the listener.

Step6: Specify the URL for your listener in the Notification URL field .
i.e https://domainname.com/paypal/ipn/index.

Step7: Click Receive IPN messages (Enabled) to enable your listener.

Step8: Click Save .

Step9: Click Back to Profile Summary to return to the Profile after activating your listener. You also can click Edit settings to modify your notification URL or disable your listener. You can click Turn Off IPN to reset your IPN preferences.

For now, we have changed line 38 of vendor/magento/module-sales/Model/Order/Payment/State/RegisterCaptureNotificationCommand.php from:
$state = $order->getState() ?: Order::STATE_PROCESSING; to $state = Order::STATE_PROCESSING; as it was before the update.

Thank you @numan201 , working on Paypal Payments Pro Hosted Solution on Magento 2.3.x.

For now, we have changed line 38 of vendor/magento/module-sales/Model/Order/Payment/State/RegisterCaptureNotificationCommand.php from:
$state = $order->getState() ?: Order::STATE_PROCESSING; to $state = Order::STATE_PROCESSING; as it was before the update.

Thank you @numan201 , working on Paypal Payments Pro Hosted Solution on Magento 2.3.x.

Good to hear. Working fine on Magento 2.3.2 with PayPal Advanced as well.

It seems like the Paypal account region is playing game aswell. I guess for some EU countries there is 3rd party module that working fine.

I have the same problem with Mollie no success with updating order status.
Payment Status = Paid -- and the -- Order Status = Pending Payment
I try to change ( $state = Order::STATE_PROCESSING; ) but untill now no success.
Magento 2.3.2 - Mollie 1.5

This is was my fix at the start of the year:
https://github.com/magento/magento2/pull/20870/commits/8c26699dcf9a659c6976fb66329a46781657d90a

In app/code/Magento/Paypal/Model/Ipn.php
protected function _registerPaymentCapture($skipFraudDetection = false)
add this line

$this->_order->setStatus($this->_order->getConfig()->getStateDefaultStatus(
            \Magento\Sales\Model\Order::STATE_PROCESSING));

No sure why travis failed on it.. been ok for us but we've been extra careful, please use at own risk!

I have had a nice talk with a expert from Mollie today - and now it works like a charm.

https://redirectdetective.com -- check if your website is redirecting good. (that is in 1 hop)

Our nginx redirected www to non www -- and afterwards redirect again to https.
The webhook return from Mollie fails if there are too many redirects.

This issue is still no resolved.
I am still unable to manually change the status of the orders... In the dropdown list, there is only 1 option available: "Pending Payment" !!!!

I can confirm this is still happening in 2.3.3.
Going to re try @numan201 suggestion in 2.3.3.

I can also confirm this is happening in 2.3.3

@numan201 fix worked for me in 2.3.2 however on upgrading to 2.3.3 we now have Pending Payment status for orders received even thought he details of the payment are on the order.

It also looks like the fix that worked in 2.3.2 is already present in 2.3.3 so I am at a loss with how to proceed with this

For now, we have changed line 38 of vendor/magento/module-sales/Model/Order/Payment/State/RegisterCaptureNotificationCommand.php from:
$state = $order->getState() ?: Order::STATE_PROCESSING; to $state = Order::STATE_PROCESSING; as it was before the update.

@joni-jones

(MAGETWO-88244: PayPal orders status display always as Processing)
Could you please handle Website Payments Pro Hosted Solution with regards to your commit back in Apr 2018 here?

https://github.com/magento/magento2/commit/f39138b6dc504f93dae9697ad45d11d57f1aaf1f#diff-68f9035e0545c5442dde19b0ba0fa9b4R38

Experiencing the issue again now in 2.3.3. Our orders are not exporting via API because they have Pending Payment status. Please, can someone resolve this?

do we need to create a new issue for this?

Just had to redo numans fix in 2.3.2.

can anyone confirm if the fix still works in 2.3.3?

in my situation payments from Paypal Express are coming through correctly and have a status of Processing. Paypal Web Payments Pro are coming through as Pending Payment which is incorrect however the payment does show in the order information.

In 2.3.2 numan201's fix worked and resulted in both Paypal Express and Web Payments Pro having the corret 'Processing' Status

in 2.3.3 the fix already seems to be present in the code however Web Payments Pro orders are not showing the correct status

Has anyone managed to find a fix for this? Getting 'Pending Payment' status in 2.3.3.

I have opened a new issue with hope that this will trigger a response
https://github.com/magento/magento2/issues/25659

Closed as 25659 new one with more details information.

We are getting the same issue with PayPal Pro on Magento 2.3.5-p1, any solution?

@numan20 fix worked for me in 2.3.5-p1

@nomis11uk can you please let us know which fix works for you? Can you please share solutions with us?

Was this page helpful?
0 / 5 - 0 ratings