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.4k stars 9.29k forks source link

Paypal some orders fail with main.CRITICAL: Wrong order ID: #15427

Open BezV8 opened 6 years ago

BezV8 commented 6 years ago

When using paypal express integration as the payment method on Magento 2.2.2 a small number of orders fail after the payment has been taken by paypal. No order is registered in Magento, but paypal takes payment and sends a confirmation to both customer and store owner.

Looking in the logs the error which seems to be associated with these orders failing is: main.CRITICAL: Wrong order ID: "000000222". {"exception":"[object] (Exception(code: 0): Wrong order ID: \"000000222\". at .../vendor/magento/module-paypal/Model/Ipn.php:140)"}

Preconditions

  1. Magento 2.2.2
  2. Paypal Express Checkout set as Payment method.

Steps to reproduce

  1. Customer Places Order
  2. Directed to PayPal page and payment taken
  3. Redirected to site, order fails and is not logged in Magento.

Expected result

  1. Once payment has been taken and the customer has been redirected back to the site order is registered with magento.

Actual result

  1. Payment is taken.
  2. Paypal redirects to site and sends confirmation email with correct order number.
  3. Order is not registered in magento.
  4. Order ID skips failed order (next order number is incremented from failed order, orders list in backend has a gap where failed order would have been).
nigeriangirl commented 4 years ago

Having this issue on 2.3.0 for all orders

t-eichmann commented 4 years ago

Can confirm the problem for 2.3.1 on all Paypal orders.

t-eichmann commented 4 years ago

Can confirm the problem for 2.3.1 on all Paypal orders.

As it turned out for us, the problem was not in the Magento code. We have a custom payment method with an observer listening to the sales_order_payment_save_before event. In the observer we Injected an instance of Magento\Webapi\Controller\Rest\InputParamsResolver and called its resolve method without checking if the route name is empty. If the route name is not empty this causes an exception, because the route could not be found, but this exception was somehow not logged. We added an additional check for a non-empty route name and now the Paypal problem doesn't occur anymore. Hope this might be helpful for someone having a similar problem.

shauldover commented 4 years ago

Having same issue in 2.3.2

daschenbrener commented 4 years ago

Same here in 2.3.2, is there anyone working on this @magento-engcom-team as this is also affecting the payflo pro as well.

daschenbrener commented 4 years ago

Hi all,

Magento support have highlighted the following as fixing this issue.. 547f453

@magento-engcom-team what release line is this going to be tagged in please?

@craigcarnell did this work for you?

TonyRutherford1 commented 4 years ago

@magento-team Any update on this issue?

shauldover commented 4 years ago

So far no solution here. In the mean time had to disable PayPal express, and offer only credit card payments, store- configuration- sales- payment method / payment pro- configure / PayPal express checkout-Advance Setting) Payment applicable from specific countries, and no countries selected.

djamps commented 4 years ago

@shauldover does this only affect Paypal Express or all forms of paypal (e/g credit cards on your site via payflow/payments pro)? Due to the nature of the issue (DB deadlocks) it would surprise me if this issue is specific to any payment method.

shauldover commented 4 years ago

@djamps Only PayPal Express. Credit card through payflow working fine.

pizzo90 commented 4 years ago

Same issue here confirmed on 2.2.8

Any updates?

dschmidthawk commented 4 years ago

I'm having the same issue in Magento 2.3.2 using PayPal Standard. PayPal is sending client notifications that " Please check your server that handles PayPal Instant Payment Notifications (IPN). IPNs sent to the following URL(s) are failing:"

daschenbrener commented 4 years ago

im migrating all my magento client from magento. this platform is ridiculously poor and a money pit of a platform. Good luck!

djamps commented 4 years ago

We haven't gotten a DB deadlock on orders in over a month since doing two things (not sure which is more affective).

  1. Switch to async order grid in admin
  2. And in my.cnf: transaction-isolation = READ-COMMITTED

We still get an occational deadlock on the cron process but this is small potatos compared to orders failing. I recommend the following module to help in some of these cases:

https://github.com/cadencelabs/magento2-deadlockRetry

However, we still have get occasional uncaptured/missing paypal express orders (wrong order ID in log, ect). With no evidence of deadlock, it turns out these are all international orders and the failure is triggered by a missing state/province in the customer's paypal account.

minhducnho commented 4 years ago

Does anyone have any solution to fix this error?

kerlama commented 4 years ago

Apparently not.

phongphanmage commented 4 years ago

This issue comes from your third-party module. Kindly re-check all your module which customized the order flow. I fixed it with condition check Order Object in Observer. if ( $order )

olgaIskra commented 4 years ago

The solution is to store guest data in a timely manner: module-checkout/Model/GuestPaymentInformationManagement.php public function savePaymentInformation( $cartId, $email, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); /* @var Quote $quote / $quote = $this->cartRepository->getActive($quoteIdMask->getQuoteId());

if ($billingAddress) { $billingAddress->setEmail($email); $quote->removeAddress($quote->getBillingAddress()->getId()); $quote->setBillingAddress($billingAddress); $quote->setCustomerEmail($email); $quote->setDataChanges(true);

} else { $quote->getBillingAddress()->setEmail($email); } $this->cartRepository->save($quote); $this->limitShippingCarrier($quote); $this->cartRepository->save($quote);

$this->paymentMethodManagement->set($cartId, $paymentMethod); return true;

}

danci1973 commented 4 years ago

I think this would be the correct patch for 2.3.0 (all credits to @olgaiskra):

--- clean/GuestPaymentInformationManagement.php   2019-09-20 14:25:56.696734848 +0200
+++ new/GuestPaymentInformationManagement.php      2019-09-23 08:48:37.286939940 +0200
@@ -137,6 +137,7 @@
         \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
         \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
     ) {
+       //O Romanovskaja Agenda 20.09.2019 changed for Pay Pal Guest working
         $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
         /** @var Quote $quote */
         $quote = $this->cartRepository->getActive($quoteIdMask->getQuoteId());
@@ -145,12 +146,14 @@
             $billingAddress->setEmail($email);
             $quote->removeAddress($quote->getBillingAddress()->getId());
             $quote->setBillingAddress($billingAddress);
+            $quote->setCustomerEmail($email);
             $quote->setDataChanges(true);
         } else {
             $quote->getBillingAddress()->setEmail($email);
         }
         $this->limitShippingCarrier($quote);
-
+        $this->cartRepository->save($quote);
+        
         $this->paymentMethodManagement->set($cartId, $paymentMethod);
         return true;
     }
Priya-V-Panchal commented 4 years ago

Hi,

Has anyone found the solution for this issue?

Thanks

dschmidthawk commented 4 years ago

If this issue is severe enough for developers to create extensions to mitigate the effects, why hasn't this been resolved? Very frustrating.

shauldover commented 4 years ago

yes, this is a painful one. I also facing it on a 2.3.3 version.

  1. disable Magento_PaypalReCaptcha and it might solve the issue. For me it solve the issue for credit card processing, but the PayPal express is still a problem.
  2. To "remove" temporarily paypal express just select "no Countries" in Admin set up of PayPal Pro / express.
lexiconnect commented 4 years ago

Seeing this on multiple installations of Magento 2.3.3. Tried all the above fixes an none of them appear to fix the issue.

PatrickVisserNZ commented 4 years ago

Problem also exists on Magento 2.3.2. error... main.CRITICAL: The "10000003523" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"10000003523\" order ID is incorrect. Verify the ID and try again. at /home/xxx/public_html/vendor/magento/module-paypal/Model/Ipn.php:143)"} []

multipasko commented 4 years ago

Problem also exists on Magento 2.3.2. error... main.CRITICAL: The "10000003523" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The "10000003523" order ID is incorrect. Verify the ID and try again. at /home/xxx/public_html/vendor/magento/module-paypal/Model/Ipn.php:143)"} []

Exactly the same issue on our Magento 2.3.1 instance. It seems to happen randomly.

ilnytskyi commented 4 years ago

Found out that if any module intercepts this method \Magento\Sales\Model\Order\Payment\State\CommandInterface::execute and when that plugin failed then order is not placed in magento. What interesting that, $order->getId() in that method returns null that's why some 3rd extensions can fail can cause this issue. For some reason 3rd module can intercept any of this class instead of the interface \Magento\Sales\Model\Order\Payment\State\RegisterCaptureNotificationCommand \Magento\Sales\Model\Order\Payment\State\AuthorizeCommand \Magento\Sales\Model\Order\Payment\State\CaptureCommand \Magento\Sales\Model\Order\Payment\State\OrderCommand

UPD: you can try to restore those orders based on saved quotes for them if there enough data, here is SQL

SELECT DISTINCT quote.entity_id as quote_id, reserved_order_id, quote.store_id as store_id, quote.created_at, ord.entity_id
FROM quote
       inner join quote_item item on quote.entity_id = item.quote_id and quote.reserved_order_id IS NOT NULL
       inner join quote_payment payment on quote.entity_id = payment.quote_id and payment.method = 'paypal_express' and
                                           payment.additional_information like '%paypal_express_checkout_token%'
       left join sales_order as ord on ord.quote_id = quote.entity_id
where ord.entity_id is null;
multipasko commented 4 years ago

can be related ? https://github.com/magento/magento2/issues/25862

shauldover commented 4 years ago

Although that previously we thought it is only related to PayPal Express payment only and we disabled it, it it showing now also on credit card payment (PayPal pro). not on every order. Anyone got possible fix?

djamps commented 4 years ago

Everything we've done so far which have eliminated deadlocks occuring during orders and greatly reduced deadlocks overall:

In Magento: Asynchronous grid = on Flat products and categories = on Async indexing = on Production mode enabled always Install Cadence_DeadlockRetry

In my.cnf transaction-isolation = READ-COMMITTED (along with other optimizations)

Beef up your server's CPU and disk speed (IOPS) as much as possible. This is very important, even for low traffic sites. Fast SSD's on dedicated hardware/instances are a must.

Switched to authorize.net for CC orders (mainly due to double auth fees with the payflow integration) - see https://github.com/magento/magento2/issues/6542 - no more missing CC orders either.

At this point we aren't seeing any order related mysql deadlocks, but we are still seeing very occasional "wrong order ID" in the system log and a corresponding missing paypal order. What gives?

We determined this remaining issue is poor CURL error handling in the payflow module. A VERY occasional connection issue with paypal with no attempt to retry and no traceback thrown. If this happens during order processing after the first API call (several API calls are made) you are left with a missing/incomplete order. You'll have a payment, a quote with valid order ID, but no corresponding order.

We wrote a command line module to programatically complete these orders. We could even take it one step further and grep the exception log for "Wrong order ID: "$n" and automate it.

Ideally, there should at least be N retries when CURL exceptions occur (similar to what the Cadence_DeadlockRetry module does for mysql deadlocks). We briefly attempted this but found magento's payflow integration too dense and co-dependant with other core modules to override completely.

;TLDR

This entire issue has at least two causes. MySQL deadlocks which are a way of life with magento, and poor exception handling in the payflow module. Neither of these issues are trivial to expose in testing, so the devs are not going to spend time with this.

The payflow integration in it's current state across all magento2 versions is a steaming pile. Switch to something else for payments (at least for CC's), if you can.

mortenbm commented 4 years ago

Hi @djamps Would you mind sharing your command line module to complete the missing orders? Would be greatly appreciated!

We wrote a command line module to programatically complete these orders. We could even take it one step further and grep the exception log for "Wrong order ID: "$n" and automate it.

ruipns commented 3 years ago

Hey So I use 2.3.5-p1 and something like this happens. I just can't understand one thing, I use massiveGRID so I easily do a environment clone, change the url and it's working as a test one. The curious thing is that in live site this happens, all the info appears in quote tables but the order itself is not created at all, but, in the clone environment all works fine. So I thought of 2 option or it was cloudflare or all the customers online that gives more load. With this I paused cloudflare, all kept the same, no order at all and the error. With the customers idk what to do, I installed Cadence_DeadlockRetry to see if it helped but no luck. I'm not sure if here it's the same cause but the errors surely is.

Anyone got news on this?

Thanks

davidduong90 commented 3 years ago

In my case, after some hours debug and check files debug.log, exception.log, payment.log, I found the issue is Numeric value out of range: 167 Out of range value for column 'sequence_value' at row 1, query was: INSERT INTOsequence_invoice_1() VALUES ()

Then I go to table sequence_invoice_1 and have changed type of "sequence_value" from int(10) to bigint(20). Now, it works fine.

Our customer have a lot order migration from Magento 1 to Magento 2. That is an issue. Hope it can help someone.

Alothemes - Happy Coding!

vseager commented 3 years ago

We have just had the issue on 2.3.5-p2:

[2020-11-12 12:35:51] main.CRITICAL: The "1000426282" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426282\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:36:05] main.CRITICAL: The "1000426282" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426282\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:36:26] main.CRITICAL: The "1000426282" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426282\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:37:08] main.CRITICAL: The "1000426282" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426282\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:38:30] main.CRITICAL: The "1000426282" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426282\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:38:31] main.CRITICAL: The "1000426283" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426283\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:38:33] main.CRITICAL: The "1000426283" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426283\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:39:44] main.CRITICAL: The "1000426283" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426283\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:40:36] main.CRITICAL: The "1000426284" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426284\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:40:38] main.CRITICAL: The "1000426284" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426284\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:40:49] main.CRITICAL: The "1000426284" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426284\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:41:06] main.CRITICAL: The "1000426283" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426283\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:41:12] main.CRITICAL: The "1000426284" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426284\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
[2020-11-12 12:41:54] main.CRITICAL: The "1000426284" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"1000426284\" order ID is incorrect. Verify the ID and try again. at /vendor/magento/module-paypal/Model/Ipn.php:146)"} []
Berman59 commented 3 years ago

Did anyone ever find out why this is happening? Am getting this randomly, not very often on 2.3 as well.

tprocter-ldg commented 3 years ago

Replicating on 2.3.5 - "The "xxxxxxxxxxx" order ID is incorrect. Verify the ID and try again."

JithinJay commented 3 years ago

HI @magento-devops WE have faced the same issue in 2.3.1 EE, we are planning to upgrade to 2.4.2 EE does this fixed in 2.4.2 ?

krivtsuna commented 3 years ago

I got the same issue on 2.4.2, anyone know how to fix it?

amiddio commented 3 years ago

I have confirmed that this is happening on Magento 2.3.7!

djamps commented 3 years ago

HI @magento-devops WE have faced the same issue in 2.3.1 EE, we are planning to upgrade to 2.4.2 EE does this fixed in 2.4.2 ?

Please see my long post above, this is an issue across all versions, and it has certainly not been fixed. The same crappy payflow module without proper exception handling exists to this day.

kerlama commented 3 years ago

And its certainly not going to be, anytime soon.

On Mon, Jul 12, 2021, 18:32 djamps @.***> wrote:

HI @magento-devops https://github.com/magento-devops WE have faced the same issue in 2.3.1 EE, we are planning to upgrade to 2.4.2 EE does this fixed in 2.4.2 ?

Please see my long post above, this is an issue across all versions, and it has certainly not been fixed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/15427#issuecomment-878423109, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7X6ICFORSJNYVR576FUGTTXMKLDANCNFSM4FBCO2JQ .

github-jira-sync-bot commented 2 years ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 2 years ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-991 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

JKair commented 2 years ago

It even happening in Magento 2.4.3.

Grumag commented 2 years ago

Getting an average of 1 per day per site of these errors on 2.3.5-p2. So no one has any sort of a solution? Customers are seeing the erros "Something wrong. Please try again" when click on "Place Order":

[2021-09-23 15:47:30] main.CRITICAL: Placing an order with quote_id 17ephb7mJnLdfcnwpvPzqkHGoRFd3mpc is failed: Something wrong. Please try again. [] []

jrson83 commented 2 years ago

Having the same issue on Magento 2.3.6.

The issue is ALWAYS happening with two of 50 "Virtual Proucts" (Downloads). I tried deleting the products, but even if I delete the products and create a new one, it is happening on every order.

Paypal IPN fails and is sending an email with a notice "Instant Payment deactivated" to the customer.

[2021-10-13 12:59:08] main.CRITICAL: The "000007083" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"000007083\" order ID is incorrect. Verify the ID and try again. at /var/www/html/vendor/magento/module-paypal/Model/Ipn.php:147)"} []

neddy236 commented 2 years ago

bump :)

ghost commented 2 years ago

same issue on 2.4.3-p1

twvictor commented 1 year ago

Having the same issue on the latest Magento version 2.4.5-p1. I recently upgraded magento from 2.4.1 to 2.4.5-p1, and made some test orders, then the issue happened occasionally. Unfortunately I can not reproduce it, but I can provide some details for solving this problem. The system log as following:

issue-log

Magento system is writing the same error for the order ID 000000434 again and again, but actually it has created the order ID 000000435 for this transaction. In my papal account, the order ID for the transaction is 000000434, magento 000000435 for the same transaction number instead. So the problem is that order ids in magento and paypal for the transaction should be same, but different instead. I think wrong order ID passed to paypal system, then it sends the IPN with wrong order ID again and again. At the same time, the issue seems be related to the paypal express review step, when you make the payment using paypal express checkout on product or shopping cart page, you login your paypal account, click continue, it should be redirected to the paypal/express/review page, but for the order with this error, I remember, the order was placed directly, your are redirected to the suscess page without review step, and the shopping cart was not cleared after purchase. Since I'm not a professional programmer, hope this will help for the issue.