Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
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
Old 06-07-2012, 04:59 PM   PM User | #2
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
If you attempt to use this code without changing the Gateway ID you will get an access denied you can request a shared test account and InternetSecure will send you a setup email and whitelist your IP address. If you have a gateway ID replace the 40001 with your Gateway ID. Read the commented parts in the php file.
fulltiltphil is offline   Reply With Quote
Old 06-19-2012, 09:44 PM   PM User | #3
dramsay
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
dramsay is an unknown quantity at this point
thanks for posting this fulltiltphil!

Do you have any documentation or a link to where I could get some information on how to implement this script?

Thanks
dramsay is offline   Reply With Quote
Reply

Bookmarks

Tags
internetsecure, merchant direct

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:14 AM.


Advertisement
Log in to turn off these ads.