mollie / magento2

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

Inconsistent Order Status Change with Mollie Payment Links (Admin Panel Only) #788

Closed youwe-erik closed 4 months ago

youwe-erik commented 5 months ago

Describe the bug In Magento, orders with a "Canceled" status are typically considered final. However, a specific inconsistency occurs when using the "Mollie: Payment Link" payment method within the Admin area. In this scenario, a canceled order can transition back to a "Pending payment" status only when the order is created through the Admin panel. This behavior is confusing for store owners as it deviates from the standard flow.

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Go to Admin area
  2. Create an order
  3. Open the order and click the payment link.
  4. Ignore the payment link for more than 15 minutes
  5. Click "Fetch Status" in the Admin area.

The order is now canceled and can be opened again by clicking the Payment link again.

Expected behavior An order's status should only be marked as "Canceled" after the payment window associated with the Mollie payment link has expired, regardless of whether the order was created through the Admin panel or the storefront. This aligns with the expected lifecycle of a canceled order and prevents confusion for store owners.

Actual behavior (Admin Panel):

Actual behavior (Storefront):

Potential impact:

Frank-Magmodules commented 5 months ago

Thank you for opening this issue and providing such a detailed description @youwe-erik . It's much appreciated. I'll investigate this with the team and get back to you with a game plan.

Frank-Magmodules commented 5 months ago

Hi There @youwe-erik ,

Thank you for opening this issue. I understand that this behavior can be confusing, but what you are describing is actually expected. Please note that the situation you mentioned is quite uncommon. The actual order process only begins when a customer clicks on the payment link, at which point the expiration time starts running.

If we allowed canceled orders to remain canceled, it would create confusion for customers regarding how to proceed with payment. Therefore, we decided to "uncancel" the order, but only if there is sufficient stock available for the products in the order. I hope this clarifies the situation. If you have any further questions, please feel free to ask!

youwe-erik commented 5 months ago

Hello @Frank-Magmodules ,

Thank you for your response! The point is, there is no reason to set the order to canceled in Magento when you click the "Fetch Status" button at that time. It should keep the status "Pending Payment" unless the order is actually canceled in Mollie as well.

The issue is not about the canceled orders reverting to "Pending Payment", it's about the behavior of canceling the orders at all at that point.

Could you please help us understand why this behavior is intended to be different when placing an order through the Admin area and through the storefront.

Frank-Magmodules commented 4 months ago

Hi @youwe-erik

This is a bit hard to explain, but let’s try: The problem you are describing is only relevant to orders placed through the orders API. Any method can support the orders API, but only a few require it. When an order is placed through the orders API, you get an order object, but this also contains a payments API object. This payments API object will expire quite fast, in 15 minutes. But this doesn’t cancel the orders API object. The order object has a way longer expiration. When that gets canceled, the webhook gets triggered and the order in Magento gets canceled.

Now, when clicking the “Fetch Status” button in the backend, you are simulating an incoming webhook. This checks the state of the order and payment objects. As the payment object is canceled, the whole order gets canceled, as expected. This leads to the behavior you are seeing.

In a normal flow this doesn’t happen, the expiration is way higher. Because you are intervening with the order, this behavior starts to occur.

@youwe-erik, please feel free to share your thoughts and ideas on how we can improve this. Your opinion and vision are very much appreciated!

youwe-erik commented 4 months ago

Hey @Frank-Magmodules ,

Thank you very much for your explanation! It's clear to me now how this makes sense from the Mollie side of things. However from a Magento perspective orders typically cannot go from a canceled state back into an open state. Once they are canceled a new order should be created.

To prevent this from being an issue, I would like to suggest changing the behavior of the module so that the order is only canceled by the webhook when both the Mollie payment and the Mollie order object are canceled. In practice this means that "Fetch Status" (and any other webhooks) will only cancel the order in Magento if both the Mollie payment and Mollie order object are canceled.

Please let me know if you have any questions.

Frank-Magmodules commented 4 months ago

Hi @youwe-erik,

Thanks for your response. I understand your perspective and it sounds logical to do. However, the process of receiving order updates and processing them correctly is a delicate process with many spinning wheels.

We try to make a solution for your cases, but that would interfere with a solution that exists to handle specific cases. As your case is very specific, and only user-triggered, we decided to decline this request. We are also closing this issue hereby. Feel free to re-open if you have further questions or comments.

Please note that this issue is expected to be resolved once we migrate away from the Orders API, which is likely to happen in the next 6-9 months.

youwe-erik commented 4 months ago

Hi @Frank-Magmodules

Thank you for your response. Too bad but understandable. Can you please share some more information about the impact for us as the users of this module about migrating away from the Orders API?

Frank-Magmodules commented 4 months ago

HI @youwe-erik , Sure! I will take care of that once I have more definitive information on this. Thank you for your understanding!

fjbender commented 4 months ago

Within Magento, the change should be handled transparently, meaning all Magento Core functionality that currently triggers Mollie functionality will continue to work the same way (e.g. the process chain for marking orders as shipped on Mollie's side). Things like Payment Links are a bit of a special case here.

Downstream, e.g. in account software, the reporting might change slightly.

We will share more detailed information and migration guides in the course of the year.