Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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 05:17 AM.

  • #2
    New Coder
    Join Date
    Mar 2011
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Mar 2011
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is another php script i used to show a pay page keep in mind you wouldn't want this all in one file, this is just an example.

    PHP Code:
    <html>
    <head>
        <title>Pay Page Merchant Direct</title>
    </head>

    <body>
    <form method="post" action="<?php echo $xml;?>">
    <table border='1' cellpadding='2' cellspacing='1' width='600'>
    <tr>
    <td>
    <table border='0' cellpadding='2' cellspacing='0' width='100%'>
    <tr>
    <td align='center' colspan='2'><B>SandBox XML Test Page</B></td>
     </tr>
    <tr>
    <td align='right'>Post URL:</td><td><b><em>https://test.internetsecure.com/process.cgi<em></b></td>
    </tr>
    <tr>
     <td align='right'>GatewayID: </td><td><input type="text" size="7" name="gatewayid" value="1006"></td>
    </tr>
    <tr>
     <td align='right'>TransType:</td><td><input type="text" size="4" name="transtype" value="00"></td>
    </tr>
    <tr>
     <td align='right'>Products:</td><td><input type="text" size="100" name="products" value="1.00::1::001::sandbox test transaction codingforum::"></td>
    </tr>
    <tr>
     <td align='right'>Name:</td><td><input type="text" size="80" name="name" value="Test Tester"></td>
    </tr>
    <tr>
     <td align='right'>Company:</td><td><input type="text" size="80" name="company" value="InternetSecure"></td>
    </tr>
    <tr>
     <td align='right'>Address:</td><td><input type="text" size="80" name="address" value="22 Test Rd"></td>
    </tr>
    <tr>
     <td align='right'>City:</td><td><input type="text" size="20" name="city" value="Oakville"></td>
    </tr>
    <tr>
     <td align='right'>State/Province:</td><td><input type="text" size="4" name="state" value="ON"></td>
    </tr>
    <tr>
     <td align='right'>ZipCode:</td><td><input type="text" size="10" name="zipcode" value="L6L1J5"></td>
    </tr>
    <tr>
     <td align='right'>Country:</td><td><input type="text" size="4" name="country" value="CA"></td>
    </tr>
    <tr>
     <td align='right'>Phone:</td><td><input type="text" size="14" name="phone" value="905-555-1221"></td>
    </tr>
    <tr>
     <td align='right'>eMail:</td><td><input type="text" size="40" name="email" value=""></td>
    </tr>
    <tr>
     <td align='right'>Credit Card:</td><td><input type="text" size="20" name="card" value="4715000000000040"></td>
    </tr>
    <tr>
     <td align='right'>2 digit Month:</td><td><input type="text" size="6" name="month" value="12"></td>
    </tr>
    <tr>
     <td align='right'>4 digit Year:</td><td><input type="text" size="6" name="year" value="2021"></td>
    </tr>
    <tr>
     <td align='right'>CVV/CVN:</td><td><input type="text" size="6" name="cvv" value="354"></td>
    </tr>
    <tr>
     <td align='right'><input type="submit" name="submit" id="submit" value="submit"></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    <?php
    $posturl 
    $_POST["url"];
    $gatewayid $_POST["gatewayid"];
    $transtype $_POST["transtype"];
    $products $_POST["products"];
    $name $_POST["name"];
    $company $_POST["company"];
    $address $_POST["address"];
    $city $_POST["city"];
    $state $_POST["state"];
    $zipcode $_POST["zipcode"];
    $country $_POST["country"];
    $phone $_POST["phone"];
    $email $_POST["email"];
    $card $_POST["card"];
    $month $_POST["month"];
    $year $_POST["year"];
    $cvv $_POST["cvv"];
    $city $_POST["city"];


    // The XML Request
          
    $xml "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
          
    $xml .= "<TranxRequest>\n";
          
    $xml .= "<GatewayID>"$gatewayid ."</GatewayID>\n";
          
    $xml .= "<Products>"$products ."</Products>\n";
          
    $xml .= "<xxxName>"$name ."</xxxName>\n";
          
    $xml .= "<xxxCompany>"$company ."</xxxCompany>\n";
          
    $xml .= "<xxxAddress>"$address ."</xxxAddress>\n";
          
    $xml .= "<xxxCity>"$city ."</xxxCity>\n";
          
    $xml .= "<xxxState>"$state ."</xxxState>\n";
          
    $xml .= "<xxxZipCode>"$zipcode ."</xxxZipCode>\n";
          
    $xml .= "<xxxCountry>"$country ."</xxxCountry>\n";
          
    $xml .= "<xxxPhone>"$phone ."</xxxPhone>\n";
          
    $xml .= "<xxxEmail>"$email ."</xxxEmail>\n";
          
    $xml .= "<xxxCard_Number>"$card ."</xxxCard_Number>\n";
          
    $xml .= "<xxxCCMonth>"$month ."</xxxCCMonth>\n";
          
    $xml .= "<xxxCCYear>"$year ."</xxxCCYear>\n";
          
    $xml .= "<CVV2>"$cvv ."</CVV2>\n";
          
    $xml .= "<CVV2Indicator>1</CVV2Indicator>\n";
          
    $xml .= "<xxxTransType>"$transtype ."</xxxTransType>\n";
          
    $xml .= "</TranxRequest>\n";

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

    // Pass xxxRequestMode=X and xxxRequestData equals 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 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 Request XML:</strong></em><br \>"
          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 Response:</strong></em><br \>";
          echo 
    str_replace('>','&gt;',str_replace('<','&lt;',str_replace('><',"&gt;\n&lt;",$response))).'</pre><br \>';
    ?>
    Last edited by fulltiltphil; 07-30-2013 at 10:21 PM. Reason: the php script didn't look right

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The POST URL in this Example script is for InternetSecure Sandbox environment.
    https://test.internetsecure.com/process.cgi

    The POST URL for InternetSecure's Production Environment is https://secure.internetsecure.com/process.cgi make sure you use the correct Gateway ID, InternetSecure doesn't create Sandbox accounts for every production Gateway ID so the Gateway ID numbers will be different.

    For addition information refer to the InternetSecure Help Library.
    https://www.internetsecure.com/Elavo....asp?page=HELP

    The link Below will explain Setting up the connection to InternetSecure with Merchant Direct.
    https://www.internetsecure.com/Elavo...?page=HOW3&q=2

    The link Below will show the Transaction Request format for XML for Merchant Direct.
    https://www.internetsecure.com/Elavo...?page=XML5&q=2

    The link Below will show the Transaction Response format for XML for Merchant Direct.
    https://www.internetsecure.com/Elavo...?page=XML6&q=2

  • #6
    New Coder
    Join Date
    Mar 2011
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the code above will work in the one file for you to test the process but don't use it in your production environment this way.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •