Closed Skullsneeze closed 6 months ago
@LucianTuriacArnia Can you have a look at this?
Yes, I am looking into this issue. I will provide updates as I find them.
We have implemented the CommandInterface Plugin to set the status of nearly all payment methods to 'pending' until we process the push. This ensures that the amount has been captured. Below is a comparison of an order placed with a credit card: with the plugin, the status is 'New/Pending', and without the plugin, it's 'Processing/Processing'.
The issue arises randomly because sometimes the push arrives either before or simultaneously with the transaction response. For certain payment methods, we delay processing the push until we receive the transaction response. However, for iDEAL, we cannot apply the same logic.
My solution is to skip setting the status in CommandInterface if the order has total_paid = grand_total.
Total Paid is set during the Push, and the order is saved afterward. However, we still need to check if the object from CommandInterface contains the updated values.
I created the next PR: https://github.com/buckaroo-it/Magento2/pull/831/files
Hi @LucianTuriacArnia ,
I would suggest to not compare total due and total paid like this, because they can be float or string values, and it is risky to compare float values like this. It's safer to check that the difference is is less than a threshold:
if ($order->getGrandTotal() - $order->getTotalPaid() < 0.001) {
Hi @boldhedgehog ,
Thank you, you are right, I will update the code.
@LucianTuriacArnia , One more thing: it is a known Magento issue caused by the same race condition, when 2 requests are updating one order at the same moment, the orders gets invoiced, the status is changed to Processing, the items are updated etc, but the total due and total paid are not updated, so this check will not work. Example, this order is paid and the status of the order is Processing:
@boldhedgehog on the Push processor we saved the order and we update the total_paid app/code/Buckaroo/Magento2/Model/Push.php:1285 and CommandInterface::updateOrderStateAndStatus is called after I don't think it is the same case, but I will check.
@LucianTuriacArnia this is another issue, indeed. My point was that the check of total paid might now always work.
@Skullsneeze I propose implementing the fix using the following steps:
Apply the fix to your environment: https://github.com/buckaroo-it/Magento2/pull/831/files
If the issue persists, please send us the logs.
Uncomment line 137: $order = $order->loadByIncrementId($order->getIncrementId()); to load the order from the database.
If the issue persists after the above change, send us the logs again.
If the problem continues, also apply this fix to ensure total_paid is updated in the database on Push: https://github.com/buckaroo-it/Magento2/pull/832
@Skullsneeze Please do not apply this "patch" this will ruin you order taxes. The patch prevents data from being saved in the sales_order_tax
and sales_order_tax_item
tables
@stefanfr Thanks for bringing this to our attention. We've tested the system with and without the patch. So far, we haven't encountered any issues with the saving of taxes in the sales_order_tax and sales_order_tax_item tables as you mentioned.
To assist you better, could you please provide more details about the specific payment method you tested and share your tax configuration settings? This will help us narrow down the issue and address it more effectively.
Additionally, I'll be sharing an example of the test scenario we performed. Taxes.pdf
@LucianTuriacArnia we have this patch working on Production for a while with no such issues mentioned by @stefanfr
I suppose, he mean this part:
Thank you @boldhedgehog @stefanfr , loading order using repository will fix the issue $order = $this->orderRepository->get($order->getId());
Due to limited feedback on the first version, I haven't had the opportunity to thoroughly analyze the commented code. Your insights on this issue are valuable, and I appreciate your collaboration.
This issue was resolved with the following pull request: https://github.com/buckaroo-it/Magento2/pull/859
For certain orders we are seeing the state and status being updated from processing to pending after a successful payment has been pushed.
I have not been able to find a direct cause, but based on the debug logs I do see the following:
1. Start of order push is logged
2. The Push is successful and the current order state + status is logged:
3. Order state + status is updated:
4. Final debug log from the Push is logged (indicating success):
5. (This is where the issue begins I believe) CommandInterface plugin is called:
6. The order state + status is updated to Pending:
It seems that steps 5 and 6 are not occurring for all orders, but I can't find any logic as to why that would happen. I also don't see the logic in forcing the state and status here, so would also be interested in knowing why this is happening.