Use cURL to send a request to the payment gateway.
Submit form as POST request to external site from controller
I'm using Quickpay as payment service provider on a project, and I've come across a problem I haven't experienced before.
Quickpay wants a form submitted via POST request to be able to display their payment page.
At first this seemed very simple, but I have since realized that on my payment page, when the user hits "Pay", I'll need to first do some processing myself (saving the billing address and generating checksum) before I have the data needed for the Quickpay form that will be submitted to their site for the payment form to be displayed.
I thought I could just redirect the user after doing my processing by returning a redirect()->post() or similar, but there is no way that I have been able to find to redirect to an external site as POST from within a Laravel controller (or route).
Then I thought I'd use curl to post the form, but that's not redirecting the browser obviously. Finally, I thought of using AJAX to process the form and then generating a "fake" form to be posted, but this is quite combersome, since it conflicts with the dependency injected validation that I'm using and my custom AJAX handling...
Do I really have to write all that AJAX JS? Or has someone found an easier way to achieve this?
I can provide a link to the page if that helps, but I'd rather not post it here.
Any help is greatly appreciated.
Please or to participate in this conversation.