Web Hosting Talk







View Full Version : PHP question - CURL + CDGCommerce


Entity
05-25-2004, 09:20 PM
Arghhh...enough headaches, finally time to ask a question.

I've setup a secure server and am attempting to set up my payment processing (my merchant account is through CDGCommerce with CDGGateway) such that the entire process is transparent to my clients -- they never see off-site URLs, etc. According to Chris, I need to set up a PHP script that gathers the necessary data (order/payment form). This script then needs to post the data to the secure.paymentclearing.com link provided by CDGCommerce. I've tried doing this in a multitude of ways, but I keep getting this error message. Also according to Chris, I am then supposed to set up my ret_addr to be a secure script on my site that will "echo out the name/value pairs being sent back to it." I have yet to get to that point, though, due to this error message:

For your protection, your session has expired. Please close this window and log in again.
If you are seeing this message unexpectedly, you may need to delete your browser cookies and try again.



<?

# paymentprocessor.php -- handles posting everything to the payment processor on CDGCommerce's side.

foreach($_POST as $k => $v)
{
$v = urlencode($v);
$postedfields[] = "{$k}={$v}";
}

$urlstring = join("\n", $postedfields);
$urlstring = ereg_replace("\n", "&", $urlstring);

$ch = curl_init("https://secure.paymentclearing.com/cgi-bin/rc/ord.cgi");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;

?>
Evidently there is something I've got to be missing. Anyone know what it might be? I'm at my wit's end over here.

I should mention that I only added the CURLOPT_FOLLOWLOCATION header so I could see if some sort of error message was being generated; without that flag set, all I get is a "1" echoed to the screen.

Rob

cdgcommerce
05-26-2004, 04:05 PM
Hi Rob,

I will work on some sample PHP code for you to integrate into this using the HTML API.

Entity
05-26-2004, 04:12 PM
Thanks Chris. You -- and your Company -- rock. :D

Rob (one very happy customer)

Entity
05-28-2004, 06:57 PM
Any updates Chris? I followed the instructions here (http://www.phpfreaks.com/tutorials/49/0.php) but still had no luck. :(

Rob