mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
98 stars 50 forks source link

Order email is sent multiple times and status of order stays 'Wait on payment' #721

Closed gerben86 closed 7 months ago

gerben86 commented 7 months ago

Describe the bug A customer paid via iDeal (status on Mollie dashboard is 'betaald'), but the order in Magento has the status 'Wacht op betaling'. We see this error in the error-log:

Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler()
#1 vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(4067): trigger_error()
#2 [internal function]: Magento\Framework\DB\Adapter\Pdo\Mysql->__destruct()
#3 {main}
  thrown in vendor/magento/framework/App/ErrorHandler.php on line 62" while reading response header from upstream, client: 34.76.90.110, server: boschruitenwissers.nl, request: "POST /mollie/checkout/webhook/?isAjax=1&orderId%5B%5D=xxxxxxxxxxxxxxxxxVTZLd0FScUloNVVzcW1Fc2FlZE1xNmduNnlBR1k2MTA0SDNP HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm-nieuweruitenwissers.nl.sock:", host: "www.nieuweruitenwissers.nl"

We see this is in the magento system.log at the original transaction/order:

Stack trace:
vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): MyParcelNL\Magento\Observer\SalesOrderStatusHistoryObserver->execute()
vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()
vendor/magento/framework/Event/Manager.php(65): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()
generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()
vendor/magento/framework/Model/AbstractModel.php(832): Magento\Framework\Event\Manager\Proxy->dispatch()
vendor/magento/framework/Model/ResourceModel/Db/VersionControl/AbstractDb.php(56): Magento\Framework\Model\AbstractModel->afterSave()
vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(402): Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb->processAfterSaves()
vendor/magento/module-sales/Model/Order/Status/HistoryRepository.php(99): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save()
vendor/mollie/magento2/Service/Order/OrderCommentHistory.php(57): Magento\Sales\Model\Order\Status\HistoryRepository->save()
vendor/mollie/magento2/Service/Order/SendOrderEmails.php(80): Mollie\Payment\Service\Order\OrderCommentHistory->add()
vendor/mollie/magento2/Model/Client/Payments.php(435): Mollie\Payment\Service\Order\SendOrderEmails->sendOrderConfirmation()
vendor/mollie/magento2/Model/Mollie.php(369): Mollie\Payment\Model\Client\Payments->processTransaction()
vendor/mollie/magento2/Service/OrderLockService.php(75): Mollie\Payment\Model\Mollie->Mollie\Payment\Model\{closure}()
vendor/mollie/magento2/Model/Mollie.php(379): Mollie\Payment\Service\OrderLockService->execute()
vendor/mollie/magento2/Controller/Checkout/Webhook.php(107): Mollie\Payment\Model\Mollie->processTransactionForOrder()
vendor/magento/framework/Interception/Interceptor.php(58): Mollie\Payment\Controller\Checkout\Webhook->execute()
vendor/magento/framework/Interception/Interceptor.php(138): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->___callParent()
vendor/magento/framework/Interception/Interceptor.php(153): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->Magento\Framework\Interception\{closure}()
generated/code/Mollie/Payment/Controller/Checkout/Webhook/Interceptor.php(23): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->___callPlugins()
vendor/magento/framework/App/Action/Action.php(111): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->execute()
vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
vendor/magento/framework/Interception/Interceptor.php(138): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->___callParent()
vendor/magento/framework/Interception/Interceptor.php(153): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->Magento\Framework\Interception\{closure}()
generated/code/Mollie/Payment/Controller/Checkout/Webhook/Interceptor.php(32): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->___callPlugins()
vendor/magento/framework/App/FrontController.php(245): Mollie\Payment\Controller\Checkout\Webhook\Interceptor->dispatch()
vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(75): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
pub/index.php(65): Magento\Framework\App\Bootstrap->run()
{main} [] []

Each time Mollie tries to update the order status a new order mail is sent to the customer.

We see in the Mollie dashboard that Mollie gets a 500 when trying to update the order status:

21 november 2023 om 07:39
Aanroepen webhook mislukt met statuscode 500 (Internal Server Error)
21 november 2023 om 07:31
Aanroepen webhook mislukt met statuscode 500 (Internal Server Error)
21 november 2023 om 07:27
Aanroepen webhook mislukt met statuscode 500 (Internal Server Error)
21 november 2023 om 07:25
Aanroepen webhook mislukt met statuscode 500 (Internal Server Error)
21 november 2023 om 07:24
Aanroepen webhook mislukt met statuscode 500 (Internal Server Error)
21 november 2023 om 07:24
Notificatie e-mail naar ....@... gestuurd
21 november 2023 om 07:24
iDEAL-betaling betaald
21 november 2023 om 07:24

I can send the mollie.log on request, that information is more sensitve :)

How can this error be fixed so that the payment status in Magento is up to date?

It looks like that this issue is identical: https://github.com/myparcelnl/magento/issues/772

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior The order gets a normal status that it's paid.

Actual behavior Order keeps status 'Wachten op betaling' and sends the order email for each retry to the customer.

Frank-Magmodules commented 7 months ago

Hi There @gerben86 ,

Thank you for opening this issue. The error does occur when the Mollie webhook is being called, but the stack trace indicates that the exception happens in the code of the MyParcel plugin. Unfortunately, the exact error that happened is not shown in your logs, so we can’t say what is exactly failing over there.

This indicates that this is a problem outside of the Mollie code. The webhook is being called multiple times due to the fact that it returns an error. The system calling the webhook will then retry, but each time with an expanding time in between.

gerben86 commented 7 months ago

Hi @Frank-Magmodules ,

Thanks for your fast response!

The issue is indeed at MyParcel: https://github.com/myparcelnl/magento/issues/772, but they are not that fast as you are ;) I didn't notice that, because also the retries failed.

I'll close this issue.

Frank-Magmodules commented 7 months ago

Hehe Thanks @gerben86! ;-) Have a great day ahead!