Jump to content

Integrating PHP form with a payment engine


llau34

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 $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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by llau34
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.