-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect buyer to error url instead of continue url when Mollie payment status is failed #4
Redirect buyer to error url instead of continue url when Mollie payment status is failed #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the whole I think this is a good solution. It is annoying that Mollie don't work like other payment providers keeping them at the gateway to retry payment, but Mollie does like to do things differently.
I've just requested one small update to pass the failure reason through to the error page such that this can be handled by the implementor.
Ultimately I think on the error page the implementor is going to need to check for this and also check the current order to make sure it's one that can be reprocessed, but I'm not sure there is much we can do about that.
Maybe we should also add some docs on this specific subject to help folks who need to handle this.
if (mollieOrder.Embedded.Payments.Last()?.Status == MolliePaymentStatus.Failed) | ||
{ | ||
// Mollie redirects user here when the payment failed | ||
result.HttpResponse.Headers.Location = new Uri(ctx.Urls.ErrorUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the mollie docs it looks like they send a failure reason https://docs.mollie.com/docs/handling-errors-with-mollie-components I think we should look to add this to the ErrorUrl
as a query string parameter such that folks can display a suitable error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattbrailsford if I add a query parameter to the ctx.Urls.ErrorUrl
, will it be passed to the error page in payment provider setting? Won't the ctx.Urls.ErrorUrl
will be consumed by umbraco commerce?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. So we could append query params to ctx.Urls.ErrorUrl
but by default you are right, they wouldn't automatically pass through. But payment providers have a GetErrorUrl(PaymentProviderContext context)
method which you can override to resolve the local error URL for that route to navigate to. In this method then you could check context.Request
to check the query string on the ctx.Urls.ErrorUrl
and if there is a reason
param, then append it to the local URL returned from GetErrorUrl
. Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated mollie payment provider to add mollieFailureReason
to error url's query params.
…mollieFailureReason to the query parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better to me. Lets just make utils internal so we aren't exposing more public APIs
Currently, when using mollie test api to mimic the failed payment status, the buyer is sent back to the "continue url" and their cart is emptied just like when they did a successful payment. But, mollie payment provider does not create any order in the backoffice so basically that failed payment is lost in the wind.
This PR redirects buyer to the "error url" instead so the buyer knows about their fail payment, their cart is intact and they can try to do the payment again. With this approach, using the back button to go back to a not-cached checkout review page and do the payment again may actually work, at least with the demo store.