<?
$DEBUG=1;

if ($DEBUG>=1) {
ini_set(display_errors,1);
}
$responsexml=<<<EOF
<?xml version="1.0"?>
<QGWRequest>
<Details>
<gwLogin>your gwid</gwLogin>
<RestrictKey>the RestrictKey</RestrictKey>
<ResponseType>Response</ResponseType>
<post_back_url>your url</post_back_url>
</Details>
<TransactionRequest>
<trans_method>CC</trans_method>
<ccnum>5454545454545454</ccnum>
<ccmo>12</ccmo>
<ccyr>2010</ccyr>
<amount>10.00</amount>
<BADDR1>1212 15th St NW</BADDR1>
<BZIP1>99999</BZIP1>
</TransactionRequest>
</QGWRequest>
EOF;

$header = "POST /cgi/xml.php HTTP/1.1\n";
$header.= "Host: https://secure.quantumgateway.com\n";
$header.= "Content-Length: ".strlen($responsexml)."\n";
$header.= "Content-type: text/xml; charset=UTF8\n";
$header.= "Connection: close; Keep-Alive\n\n";
$header.= $responsexml;

$gatewayurl="https://secure.quantumgateway.com/cgi/xml.php";

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$gatewayurl);

curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$header);

$getresponse=curl_exec($ch);

// Do some basic error trapping
if (curl_errno($ch)) {
print curl_error($ch);
curl_close($ch);
} else {
curl_close($ch);
}

if ($DEBUG>=2) {

$the_postback2=htmlentities($getresponse);
$the_postback=$getresponse;
echo $the_postback2 . "<br /><br />";

}

if(preg_match("/APPROVED/i","$getresponse")) {
#Do your APPROVED routine
} else {
#either decline or error.
}

?>