View Single Post
Old 06-04-2012, 03:53 PM   PM User | #1
fulltiltphil
New Coder

 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
fulltiltphil is an unknown quantity at this point
Smile InternetSecure Merchant Direct cURL PHP

I've seen lot's of questions regarding InternetSecure and Merchant Direct using cURL PHP. Below is working code that works, I received this from one of the Tech Integrated reps at InternetSecure you only get this code if you ask so here it is for all to use. This is for Merchant Direct and make sure to pay attention to the commented parts so you add your Gateway ID and understand how it works.

PHP Code:

<?php

// The XML Request

      
$xml "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

      
$xml .= "<TranxRequest>\n";

      
$xml .= "<GatewayID>40001</GatewayID>\n"// put your Gateway ID in the place of 40001

      
$xml .= "<Products>1.00::1::001::Test Transaction cURL PHP::</Products>\n";

      
$xml .= "<xxxName>John Smith</xxxName>\n";

      
$xml .= "<xxxCompany>InternetSecure</xxxCompany>\n";

      
$xml .= "<xxxAddress>2201 Tester Rd</xxxAddress>\n";

      
$xml .= "<xxxCity>Oakville</xxxCity>\n";

      
$xml .= "<xxxProvince>ON</xxxProvince>\n"// Can also be xxxState

      
$xml .= "<xxxPostal>N3R1S3</xxxPostal>\n"// Can also be xxxZipCode

      
$xml .= "<xxxCountry>CA</xxxCountry>\n";

      
$xml .= "<xxxPhone>905-555-1221</xxxPhone>\n";

      
$xml .= "<xxxEmail>service@internetsecure.com</xxxEmail>\n";

      
$xml .= "<xxxCard_Number>4715**********40</xxxCard_Number>\n"// put in a Real Credit Card number or replace * with zeros for the test card number

      
$xml .= "<xxxCCMonth>01</xxxCCMonth>\n"// put in valid Expiry Month must be 2 digits

      
$xml .= "<xxxCCYear>2015</xxxCCYear>\n"// put in valid Expiry Year must be 4 digits

      
$xml .= "<CVV2>876</CVV2>\n"// Put in the CVV/CVN number from the pack of the Credit Card

      
$xml .= "<CVV2Indicator>1</CVV2Indicator>\n";

      
$xml .= "<xxxTransType>00</xxxTransType>\n";

      
$xml .= "</TranxRequest>\n";

 

// Production Post URL

                
$url "https://secure.internetsecure.com/process.cgi";

// Sandbox Post URL, only available upon request.

              //  $url = "https://test.internetsecure.com/process.cgi"; 

// Pass Request Mode   X with the XML Request URL encoded

                
$postData "xxxRequestMode=X&xxxRequestData=".URLEncode($xml);

// Get the curl session object

$session curl_init();

// Pass the Content-Type=application/x-www-form-urlencoded

$header[] = "Content-Length: ".strlen($postData);

$header[] = "Content-Type: application/x-www-form-urlencoded";

// Set the POST options.

curl_setopt($sessionCURLOPT_SSL_VERIFYPEERfalse);

curl_setopt($session,CURLOPT_URL,$url);

curl_setopt ($sessionCURLOPT_POSTtrue);

curl_setopt ($sessionCURLOPT_POSTFIELDS$postData);

curl_setopt($sessionCURLOPT_HEADERtrue);

curl_setopt($sessionCURLOPT_HTTPHEADER$header);

curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);

// Close the session and Print to screen transaction Data

$response curl_exec($session);

curl_close($session);

      echo 
"<pre><em><strong>Transcation Request XML:</strong></em><br \>";

      echo 
"<strong>Receipt Number : </strong>"$TRX ."<br \>";  // use this line to display the Receipt Number

      
echo "<strong>GUID: </strong>"$GUID ."<br \>";  // use this line to display the GUID

      
echo str_replace('>','&gt;',str_replace('<','&lt;',str_replace('><',"&gt;\n&lt;",$xml))).'</pre><br \>';  // use this line to display the XML only

      
echo "<pre><em><strong>Transcation Request URL encoded:</strong></em><br \>";

      echo 
str_replace('>','&gt;',str_replace('<','&lt;',str_replace('><',"&gt;\n&lt;",$postData))).'</pre><br \>';

      echo 
"<pre><em><strong>Transcation Response:</strong></em><br \>";

      echo 
str_replace('>','&gt;',str_replace('<','&lt;',str_replace('><',"&gt;\n&lt;",$response))).'</pre><br \>';

?>

Last edited by Inigoesdr; 06-05-2012 at 04:17 AM..
fulltiltphil is offline   Reply With Quote