mollie / Magento

Mollie Payments for Magento 1.x
https://www.mollie.com/
BSD 2-Clause "Simplified" License
39 stars 30 forks source link

Klarna payment issue #191

Closed c-gross closed 3 years ago

c-gross commented 3 years ago

We switched to mollie as our main payment module. But we have issues with klarna payments.

If an order has more than 1 product, only the 1st shipped item gets transmitted to mollie to get invoiced. I also found an php error in the exception.log

2020-11-02T14:39:31+00:00 ERR (3): Mollie_Mpm_Exceptions_KlarnaException in /var/www/.../htdocs/app/code/community/Mollie/Mpm/Model/Client/Orders.php:222

Our ERP systme is sending orderitem shipments one by one to magento.

Magento 1.9.2.4 CE Mollie 5.6.1

c-gross commented 3 years ago

I started to reproduce it on my local with a copy of the live DB. I removed the shipment and qty_shipped entries and triggert the shipment info via API like our ERP system does.

The Mollie Observer is coming to the point that it's already pushed to Mollie. error: {"error":true,"msg":"Shipment already pushed to Mollie"}

I also found log entries like this in the live mollie.log 2020-11-03T09:49:50+00:00 DEBUG (7): success: {"success":false,"status":"shipping","orderid":"1639148","type":"webhook"} 2020-11-03T09:49:50+00:00 DEBUG (7): error: {"error":true,"msg":"Shipment already pushed to Mollie"} 2020-11-03T09:49:52+00:00 DEBUG (7): error: {"error":true,"msg":"Shipment already pushed to Mollie"} 2020-11-03T09:49:52+00:00 DEBUG (7): tracking: Added DHL shipping for ord.... 2020-11-03T09:49:53+00:00 DEBUG (7): error: {"error":true,"msg":"Shipment already pushed to Mollie"}

But in Mollie it's showing that these order items are not shipped. Always only 1 item, the rest stays unshipped.

Looks like the problem is, that we get the shipment with trackingcode info one by one from the warehouse. So we create the shipment for an item and add the other items to it. And Mollie expects that everything is getting shipped at once and can't be added to the shipment anymore, if it's the same trackingcode?

c-gross commented 3 years ago

Since I'm not sure if this project gets still maintained I made an rewrite for Mollie_Mpm_Model_Client_Orders to allow multiple shipment submits for the same shipmentId. Did some tests and seems to work and testing now in production.

Frank-Magmodules commented 3 years ago

Hi @c-gross, thank you for the issue report. The module is still maintained. Tried to reproduce the issue, but on a vanilla Magento installation we are not able to reproduce this issue. Looks like this is due to the way the ERP is creating the shipment. Can you create a PR for the fix you implemented so we can look at this?

c-gross commented 3 years ago

It's not a big change. In Mollie_Mpm_Model_Client_Orders createShipment() I removed the check if the $mollieShipmentId already exists (line 463-468). Might not be the best way but we had so many orders with just a part be invoiced that we needed a quick solution.

As I already mentioned. Our ERP system is sending the shipment for each orderitem as a single request. When a orderitem gets scanned to be shipped it's added to a queue in the warehouse system and all few mins it's sending the shipment updates as single requests to Magento. Thats something we can't change now before christmas for sure.

The Mollie plugin needs to get all orderitems be shipped at once or with different shipments/tracking code. If we set an orderitem shipped and 1sec later the next orderitem of the same order gets shipped, the plugin says already no. That shipment already exists and skips the update to Mollie and will never charge any other orderitem of that order except the 1st orderitem. Means we need to check every order manually in Mollie. With my small change it seems to work fine now.

Frank-Magmodules commented 3 years ago

HI @c-gross, thank you for your detailed reply on this issue. We have created an internal task for this issue as well as your solution and we will try to come back on this as soon as possible. Thank you suggestion and details on this!

Frank-Magmodules commented 3 years ago

Hi @c-gross,

After a discussion with our team, we decided to not follow up on this issue as this is a rare use case. The normal flow in Magento assumes that the shipment is complete when submitted. Your use case deviates from this as you create a shipment, submit it and then later update the shipment and submit again.

When disabling the check on this it might work for you, but we suspect this will give errors on parts of the extension with other use cases. We are closing this issue now but please feel free to reopen the issue if you have other thoughts about this.