llau34 Posted January 10, 2014 Share Posted January 10, 2014 Hi there,I'm using a PHP based CMS called Joomla in conjunction with Fabrik forms and I'm trying to integrate the form with a new payment engine. The issue I'm having is that the only way for the form to POST properly is to hardcode the form's action parameter to the payment server's URL, by passing Fabrik's form processing, but unfortunately we lose our database record.If we don't hardcode the form's action parameter and doing things within the framework of the CMS and "Fabrik", the form will use a submission plug-in which handles the redirect to the payment's server using a PHP header funciton to redirect the user to the payment server URL, but the problem here is the payment server URL seems to only recognize it as a GET request and we end up losing the POST parameters. Is there a way to redirect a user to an external URL while POSTing the parameters as well?Thank you kindly, InC Quote Link to comment https://forums.phpfreaks.com/topic/285248-integrating-php-form-with-a-payment-engine/ Share on other sites More sharing options...
Skewled Posted January 10, 2014 Share Posted January 10, 2014 You could send the information along in a URL encoded string if you wanted, or you could just send it over GET. If you put something together and post up some code I'm sure someone here will help you, but you gotta give something to get something. Quote Link to comment https://forums.phpfreaks.com/topic/285248-integrating-php-form-with-a-payment-engine/#findComment-1464676 Share on other sites More sharing options...
jcbones Posted January 10, 2014 Share Posted January 10, 2014 cURL is the most common way to do what you are asking. Quote Link to comment https://forums.phpfreaks.com/topic/285248-integrating-php-form-with-a-payment-engine/#findComment-1464771 Share on other sites More sharing options...
llau34 Posted January 10, 2014 Author Share Posted January 10, 2014 $post_data= ""; foreach($_POST as $key => $val ){ $post_data .= "&$key=$val"; } $options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $post_data, CURLOPT_VERBOSE => 1 ); $ch = curl_init($paymentServerURL); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt_array($ch,$options); curl_close($ch); Using the cURL code above, it's still not redirecting me with the post data, unless I create the php header() function afterwards, which results in the same problem mentioned above with the payment server not recognizing our payment query. Is it because the cURL is just posting the request to the server, but when I redirect I lose the posted data for some reason or is it because that we're posting to an external URL outside of the Joomla application that the server does not seem to be receiving the posted data? Quote Link to comment https://forums.phpfreaks.com/topic/285248-integrating-php-form-with-a-payment-engine/#findComment-1464794 Share on other sites More sharing options...
jcbones Posted January 11, 2014 Share Posted January 11, 2014 If it were me, I would not re-direct after a cURL call. Instead process the cURL, and wait for the server response. Depending on that response, I would then either: A throw an error back to the user, or B Throw a success back to the user, AND record it to the database. Most payment gateway's have API's to help with this, along with full documentation to guide you in the process. Quote Link to comment https://forums.phpfreaks.com/topic/285248-integrating-php-form-with-a-payment-engine/#findComment-1464801 Share on other sites More sharing options...
llau34 Posted January 14, 2014 Author Share Posted January 14, 2014 (edited) This payment gateway is Desjardins and they require you to redirect your customers to their website for the payment and they would enter their information there and get redirected back to our site. The easiest way would be to hard code the "action" url to point to their page, but once we redirect them their we lose our application's record in our system which ends up having to do a bit of work getting it back into our database during the order process. If we go the cURL way, I thought we could POST the data to the server, and the follow redirects would take us to their page with our posted data, but it looks like once we go "outside" our application we lose our posted data as well. I just thought that it was possible to use cURL... Their documentation doesn't really take into account customized forms or CMS environments. It should be a fairly straightforward task, but it's not turning out that way. Edited January 14, 2014 by llau34 Quote Link to comment https://forums.phpfreaks.com/topic/285248-integrating-php-form-with-a-payment-engine/#findComment-1465137 Share on other sites More sharing options...
jazzman1 Posted January 14, 2014 Share Posted January 14, 2014 I'm sure someone here will help you, but you gotta give something to get something. Quote Link to comment https://forums.phpfreaks.com/topic/285248-integrating-php-form-with-a-payment-engine/#findComment-1465143 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.