Jump to content

PHP Curl


Teamwolf2000

Recommended Posts

Hi,

 

I am currently finishing a intergration with a third party payment gateway and my own bespoke shopping cart.

 

Currently:-

My checkout process page adds all the order and customer data to my database tables. There is an HTML form in the HTML of that page that is submitted by javascript onload that posts the required data I have already collected to the Payment Gateway. On sucsessfull payment, the Order in the database is flaged as paid. Process completed.

 

It all works fine, But I dont like using javascript to post the form and I dont like having the form data visable. I had a look around and it seems I should be using Curl to post the data to the Payment Gateway.

 

I can get my curl script to work and post all the data to the payment gateway, but...

 

It is returning the HTML and displaying it in the page. I would really like it to post to the payment page and follow it to it. The Payment gatway page is on https and my page is not. So is asks for payment details on http not https.

 

Does anyone know what i should do to make Curl go to the page rather than display it?

 

Here is the Curl code, I have not put the details in for security reasons. But it all works and displays the page.

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://$URL");

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");

curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");

curl_exec ($ch);

curl_close ($ch);

 

 

 

Any suggestions would be great.

 

Thanks very much.

 

TW

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.