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.49k stars 9.3k forks source link

Paypal Payments Pro IPN keeping payments marked as Pending Payment #18148

Closed Sharpy310 closed 4 years ago

Sharpy310 commented 6 years ago

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.

magento-engcom-team commented 6 years ago

Hi @Sharpy310. 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-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?

magento-engcom-team commented 6 years ago

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:

Sharpy310 commented 6 years ago

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

ghost commented 6 years ago

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.

Sharpy310 commented 6 years ago

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?

ghost commented 6 years ago

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

ghost commented 6 years ago

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

Sharpy310 commented 6 years ago

@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

Sharpy310 commented 6 years ago

@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.

magento-engcom-team commented 6 years ago

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

jhruehl commented 6 years ago

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';

jhruehl commented 6 years ago

@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.

Sharpy310 commented 6 years ago

@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';

Jasper-MultiSafepay commented 6 years ago

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

albsa commented 6 years ago

@jasper-multisafepay any fix from your end?

Jasper-MultiSafepay commented 6 years ago

@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.

xceed-will commented 5 years ago

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.

Esteraa commented 5 years ago

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?

thomashunziker commented 5 years ago

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

mattyl commented 5 years ago

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.

dphilipps commented 5 years ago

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'.

sedax90 commented 5 years ago

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

tanolalano commented 5 years ago

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

tanolalano commented 5 years ago

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

mattyl commented 5 years ago

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

albsa commented 5 years ago

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.

thedoofus commented 5 years ago

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?

tanolalano commented 5 years ago

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

mattyl commented 5 years ago

@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.

tanolalano commented 5 years ago

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

ipn ipn_complete

mattyl commented 5 years ago

whats the order history look like?

tanolalano commented 5 years ago

ipn_complete

mattyl commented 5 years ago

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';

tanolalano commented 5 years ago

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

thank you so much @mattyl

numan201 commented 5 years ago

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.

thedoofus commented 5 years ago

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 ?

Sharpy310 commented 5 years ago

@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?

ghost commented 5 years ago

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

tanolalano commented 5 years ago

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

zipnfc commented 5 years ago

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

garyhiggins1970 commented 5 years ago

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

80Cube commented 5 years ago

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.

garyhiggins1970 commented 5 years ago

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

numan201 commented 5 years ago

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).

zipnfc commented 5 years ago

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

aadmathijssen commented 5 years ago

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.

80Cube commented 5 years ago

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

harimayco commented 5 years ago

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

harimayco commented 5 years ago

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

zipnfc commented 5 years ago

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