Alec van Niekerk
08/08/2022, 11:52 AMnotification_url and return_url
2. If the transaction is successful the payment gateway POSTs to notification_url
3. If the payment gateway receives a 200 from above POST it redirects the user to return_url
Solidus provides an easy way to write a custom payment method by allowing - among other things - the developer to add a partial for the custom payment method. This works really well for on site payments or payments that will be captured manually.
In my case I've setup it up like this:
• In the partial I'm overriding the checkout_form_payment form's action attribute to point to the payment gateway's site instead of the checkout_controller
• I've added a custom controller which serves as the endpoint for the payment gateway's notification_url where I capture payment source details and progress the state of the order like it would have happened in the original checkout_controller
• I return the user to the /checkout/confirm (since this is the next state) page via the return_url upon successful transaction
My issues with that workflow are:
• capturing the payment happens before the user has "confirmed" the order, so a scenario can play out where the user successfully completes the transaction on the payment gateway's site, closes their browser, and then the order isn't really "completed"
• I can take another path and simply update the order all the way to "completed" when the payment gateway sends notification of a successful transaction, but then the user doesn't get to "confirm" the order after reviewing it (we skip the /checkout/confirm page)
Ideally I would like to only redirect to the payment gateway when the user confirms the order. As far as I can tell there is no "neat and tidy" way of overriding the confirmation portion of the checkout workflow like the payment method part. I know I could just override the entire _confirm partial, but as I would like to add the payment gateway as a gem for others to use, I'm guessing this isn't necessarily the best route to take.
Could anyone shed any advice on a better way to handle this kind of off-site custom payment method?
Thanks!ccarruitero
08/08/2022, 6:02 PMAlec van Niekerk
08/08/2022, 6:17 PMconfirm partial.
I'll dig around a little more.ccarruitero
08/08/2022, 6:50 PMAlec van Niekerk
08/08/2022, 7:01 PMconfirm partial as opposed to adding an additional step.
On second thought, perhaps I could add an additional step, have the new step's partial just render the confirm partial but with the overriding js included, and then mark the order as completed on successful transaction.ccarruitero
08/08/2022, 11:10 PM