mollie / magento2

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

Cart is not restored via GraphQL if a previous state was "PENDING" or "OPEN" #573

Closed joggienl closed 1 year ago

joggienl commented 1 year ago

Describe the bug

When in testing mode there are a couple of payment methods for which a pending or open state can be clicked. Like "pending" for PayPal and "open" for iDEAL.

If you click it you will be returned to the (configured) return url. At that point we call the mollieProcessTransaction, also to be able to get the current state payment state.

The cart is not restored. So the only thing a client can do is return to the payment screen to continue its payment (we stored the mollie_payment_url to be able to do so). If you select an error state you will be returned to the site again.

At that point I would expect the cart to be restored, but it isn't restored anymore.

Used versions

To Reproduce Steps to reproduce the behavior:

At this point your site will load the configured return url

The cart_id that was previously used with placeOrder is not restored.

At this point your site will load the configured return url again

Expected behavior

After the latest mollieProcessTransaction I would expect the cart to be restored.

Actual behavior

The cart is not restored after te latest canceled state.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

This behaviour is happening after we upgraded to 2.17.0. That version has a fix for an earlier reported bug: #562

Frank-Magmodules commented 1 year ago

Hello @joggienl,

Thanks for opening this issue. We’ve just released a new version, which gives more clarity for these cases. In the `mollieProcessTransaction` mutation we’ve added 2 new parameters: `redirect_to_cart` and `redirect_to_success_page`.

In some cases, PENDING is a valid state (for PayPal for example), and you can redirect the user to the success page, in other cases this state means you should redirect the user to the cart page. 

This parameter allows you to rely on this and redirect the user to the cart or success page depending on the status. Please note that those are always opposite of each, you don’t need both (but you can).

We are closing this issue now but please feel free to reopen the issue if this still occurs.

joggienl commented 1 year ago

hi @Frank-Magmodules, thanks for this update! I'll ask our backend team to update to the latest version.

I do have a couple of questions. I am not sure if it is al clear for me yet so I hope you can help me out here.

I am not sure if this would solve the bug I described (or tried to). PENDING and OPEN worked okay, the bug happened afterwords. At least I considered it as something that went wrong.

If Paypal is PENDING and you go back to the payment url, the next failure or canceled state would not restore the cart. A success state works fine. But if I understand correctly now, perhaps you should not be able to "continue" the payment flow if the status was PENDING? Does that even make sense? Note sure anymore now.

And one step further, if it is PENDING, does that always lead to a successful state, or could the payment still be canceled or failed or maybe even expire after being pending? Because if so, it does not make a lot of sense to go a success page. If I saw it correctly (have not double checked this) the orders with a PENDING state would finally just cancel out in Magento.

Frank-Magmodules commented 1 year ago

Hi @joggienl ,

Hopefully, these are the answers you are looking for!


Q: I am not sure if this would solve the bug I described (or tried to). PENDING and OPEN worked okay, the bug happened afterward. At least I considered it as something that went wrong.

A: From our perspective, there wasn't a bug but a wrong usage of the API. Hence we tried to make it more clear on when to redirect where.


Q: If Paypal is PENDING and you go back to the payment URL, the next failure or canceled state would not restore the cart. A success state works fine. But if I understand correctly now, perhaps you should not be able to "continue" the payment flow if the status was PENDING. Does that even make sense? Not sure anymore now.

A: The payment state should be used for more advanced cases. In most scenarios, the `redirect_to_cart` and `redirect_to_success_page` should be enough for a valid checkout flow.


Q: And one step further, if it is PENDING, does that always lead to a successful state, or could the payment still be canceled or failed or maybe even expire after being pending? Because if so, it does not make a lot of sense to go to a success page. If I saw it correctly (have not double-checked this) the orders with a PENDING state would finally just cancel out in Magento.

A: It does not have to be. It is not always possible to predict the outcome of a transaction as it in some cases can take days (ie bank transfer) before the transaction is finished. At that moment it is fine to show the success page to the customer, but the order will get updated the moment the exact status is known.


joggienl commented 1 year ago

Hey @Frank-Magmodules , appreciate the answers to my questions! Makes sense so far.

Once we have installed the update I will test everything out again.

Thanks!