Gateway posting failed transactions to ProcessCallback
The gateway we have integrated with (eWay) sends a failed transaction back to the website but it's triggering ProcessCallback and clearing the cart out.
Hmm, it looks like you may be passing the wrong URL to the payment gateway to use as your return URL. The one you have pasted is the continue URL, but you should be returning "back" requests to the cancel URL.
The continue URL is reserved for successful transaction and so this is what is moving the order to the finalized state and clearing the current order.
If your payment gateway can't differentiate between redirects of successful payment and back requests then the best way this can really be handled is to send them to your callback URL instead and have that detect the type of request being made and have that redirect to the appropriate location. You can see an example of this approach in the Mollie payment provider https://github.com/vendrhub/vendr-payment-provider-mollie/blob/v2/dev/src/Vendr.PaymentProviders.Mollie/MollieOneTimePaymentProvider.cs#L313 (Please note, this is setup for the new v2 API, but the approach should still be valid).
Ah yes - looks like it is just how this gateway (eWay) handles it.
The initial screen you get, there is Cancel and Pay Now options - cancel does call the correct cancel link and takes me back the Cart correctly. Trying Pay Now and entering an intentionally invalid card it states the transaction has failed and auto redirects to the Vendr Continue option. Not good.
Based on that, I have now come up with the following - but it's not quite working. Well it's hitting the else portion and the CancelURL is tracing out as "/cart/" however when I get to the cart page, the cart is now empty. How can we avoid this so the user maintains their products in the cart?
But the cart session is still being cleared - is there any other logic that is resetting it or something else being called? There's nothing do that in our code or customisations...
Gateway posting failed transactions to ProcessCallback
The gateway we have integrated with (eWay) sends a failed transaction back to the website but it's triggering ProcessCallback and clearing the cart out.
The "back to site" link looks something along the lines of: https://thewebsite/umbraco/vendr/payment/continue/eway-payment-provider/f98c9bcc-ee3d-4705-a4cb-ea66525b55e2/ORDERNUMBER/f6c96c0e0afdd203a366837e920b588ddd8e4e32a3cdfcfefc9fcb1c17cb91d7?AccessCode=44DD7aIeOIMryiJNFbM6S8-NCwyqKkbZcGYTl8PjGXAFga4mfFrPuN4IDNyQQPzugrlGwwIrNipb-gGIx5gNvXJhyhMuL2JdzxuRFJ7Ccr3p8xnh7-6rh5mE-RqFbzsmvXA5KhodHQ5il-X5v0r2A==
And in our payment provider, we're not returning OK but are returning CallbackResult.BadRequest() - is there a way to not clear out the cart though?
Thank you
Hi Warren,
Hmm, it looks like you may be passing the wrong URL to the payment gateway to use as your return URL. The one you have pasted is the
continue
URL, but you should be returning "back" requests to thecancel
URL.The
continue
URL is reserved for successful transaction and so this is what is moving the order to the finalized state and clearing the current order.If your payment gateway can't differentiate between redirects of successful payment and back requests then the best way this can really be handled is to send them to your
callback
URL instead and have that detect the type of request being made and have that redirect to the appropriate location. You can see an example of this approach in the Mollie payment provider https://github.com/vendrhub/vendr-payment-provider-mollie/blob/v2/dev/src/Vendr.PaymentProviders.Mollie/MollieOneTimePaymentProvider.cs#L313 (Please note, this is setup for the new v2 API, but the approach should still be valid).Hope this helps
Matt
Ah yes - looks like it is just how this gateway (eWay) handles it. The initial screen you get, there is Cancel and Pay Now options - cancel does call the correct cancel link and takes me back the Cart correctly. Trying Pay Now and entering an intentionally invalid card it states the transaction has failed and auto redirects to the Vendr Continue option. Not good.
Will check out the Mollie source now, thank you.
Based on that, I have now come up with the following - but it's not quite working. Well it's hitting the else portion and the CancelURL is tracing out as "/cart/" however when I get to the cart page, the cart is now empty. How can we avoid this so the user maintains their products in the cart?
Thank you
Hmm, not that I think this is your issue, but you might want to review some of the older Mollie code here https://github.com/vendrhub/vendr-payment-provider-mollie/blob/48223135cc2715f802eea8f9f7d17ad65d70c87e/src/Vendr.PaymentProviders.Mollie/MollieOneTimePaymentProvider.cs#L335 for the right way to get a cancel URL. Whilst your redirect will send you to the cancel page, it's bypassing Vendr's cancel handling logic which should reset the order transaction info.
This said, I don't think this is the issue. From the code snippet though I can't really see what the issue is as it looks OK to me 🤔
Thanks for that - the URI is now returning as https://localhost:44373/umbraco/vendr/payment/cancel/eway-payment-provider/0cece81f-f249-42c5-a41a-1901ea15b379/NBB-0685-8439-0GGDF/94fc0c35e2efae2bc359807d7dd0e967b4e903222dbfa8f5738f0be51184fa55
But the cart session is still being cleared - is there any other logic that is resetting it or something else being called? There's nothing do that in our code or customisations...
is working on a reply...