mollie / magento2

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

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

Open youwe-erik opened 2 weeks ago

youwe-erik commented 2 weeks 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 2 weeks 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 1 week 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 1 week 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 6 days 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 6 days 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.