I think there are two possibilities here, one is where you need to do something before a payment provider does it's normal thing, in which scenario the payment provider still want to render a payment form.
In this scenario, I think you might need to introduce a middle page such that on the final checkout screen you post back to your controller to do it's thing, then this renders a view that renders the Payment Form, but instead of rendering a button, you render some JS to auto submit the form (I have an example of this if you need it as this is essentially what we do on the Vendr.net site)
The second is where you are integrating your own provider that isn't fitting into the payment provider interface and so you are wanting to bypass the rendering of the payment form entirely and redirect straight from your controller.
In this case, we don't have the right method exposed yet, but there is a workaround. Essentially an order needs it's transaction initializing before being redirected to the gateway. This is normally done by the Payment Form renderer and as such is currently internal. We do have an open issue to expose this method for such occasions but we haven't managed to resolve it just yet. That said, there is a work around on the issue for calling the method via reflection https://github.com/vendrhub/vendr/issues/102
It's not ideal, but it might at least get you working and we'd love the feedback to see if this does the trick.
Mostly dealing with scenario 2, but I applied the javascript option from scenario 1 and that works perfectly with a trigger to the hidden submit button.
Pre-Processing of order without calling PaymentForm
Hey Matt
Quick one, if for some or other reason (third party providing payment gateway integration) we can't call this form
because we need to call a surface controller to do some stuff first then send off to third party.
How can we get the necessary things tied up in the surface controller that would have been taken care of by this call.
We not able to get order numbers and I am sure it is as a direct result of this.
Thanks
Hi Francis,
I think there are two possibilities here, one is where you need to do something before a payment provider does it's normal thing, in which scenario the payment provider still want to render a payment form.
In this scenario, I think you might need to introduce a middle page such that on the final checkout screen you post back to your controller to do it's thing, then this renders a view that renders the Payment Form, but instead of rendering a button, you render some JS to auto submit the form (I have an example of this if you need it as this is essentially what we do on the Vendr.net site)
The second is where you are integrating your own provider that isn't fitting into the payment provider interface and so you are wanting to bypass the rendering of the payment form entirely and redirect straight from your controller.
In this case, we don't have the right method exposed yet, but there is a workaround. Essentially an order needs it's transaction initializing before being redirected to the gateway. This is normally done by the Payment Form renderer and as such is currently internal. We do have an open issue to expose this method for such occasions but we haven't managed to resolve it just yet. That said, there is a work around on the issue for calling the method via reflection https://github.com/vendrhub/vendr/issues/102
It's not ideal, but it might at least get you working and we'd love the feedback to see if this does the trick.
I hope this helps
Matt
Thanks Matt
Mostly dealing with scenario 2, but I applied the javascript option from scenario 1 and that works perfectly with a trigger to the hidden submit button.
Much appreciated.
Awesome!
In case it helps, this is the JS we use for auto submitting our form https://gist.github.com/mattbrailsford/d92e1e1bbfb71e27d55faefb1096da04 (it's worth knowing that some payment providers use javascript and the onsubmit attribute so this checks for such a scenario)
/Matt
Thanks Matt
Much appreciated will keep this I am sure it will come in handy again.
Hey Matt
Sorry another one, busy today :)
So after updating to the latest version of vendr the reflection for initializing an order does not work any more.
It comes back as null.
Has the method name or something changed?
Thanks
Hey Francis,
Yea, check the changelog, it got made public in 1.2.5 :)
https://vendr.net/docs/core/changelog/
Matt
Ah nice should have checked the log :D
Thanks Matt
is working on a reply...