News:

Support the VirtueMart project and become a member

Main Menu

Iveri Payment module - South Africa

Started by lenardw, October 16, 2006, 17:34:56 PM

Previous topic - Next topic

lenardw

Hi, does anybody out there know how to link iveri payment system to virtuemart? More info on iveri here.www.iveri.co.za
This is the example code they give. Any help will be great! Thank you in advance


<html>
   <head>
      <title>Your site</title>
   </head>
      
<form METHOD="POST" ACTION="https://backoffice.iveri.co.za/Lite/Authorise.asp" id=aForm name=aForm>

<Table>
   
<!-- Lite -->

<input type="hidden" id="Lite_Merchant_ApplicationID" name="Lite_Merchant_ApplicationID" value="CE642664-B6D0-47BC-827E-E2DC6884075C">
   <!-- Merchant should use his/her Test Application ID provided by iVeri untill such time that they go live -->
   
    <input type="hidden" id="Lite_Order_Amount" name="Lite_Order_Amount" value="499">
    <input type="hidden" id="Lite_Order_Terminal" name="Lite_Order_Terminal" value="Web">
    <input type="hidden" id="Lite_Order_AuthorisationCode" name="Lite_Order_AuthorisationCode" value="">
    <input type="hidden" id="Lite_Order_BudgetPeriod" name="Lite_Order_BudgetPeriod" value="0">
    <input type="hidden" id="Lite_Website_TextColor" name="Lite_Website_TextColor" value="#b9298b">
    <input type="hidden" id="Lite_Website_BGColor" name="Lite_Website_BGColor" value="#86001B">
    <input type="hidden" id="Lite_ConsumerOrderID_PreFix" name="Lite_ConsumerOrderID_PreFix" value="PPP">
    <input type="hidden" id="Lite_On_Error_Resume_Next" name="Lite_On_Error_Resume_Next" value="True">

<!-- products -->
    <input type="hidden" id="Lite_Order_LineItems_Product_1" name="Lite_Order_LineItems_Product_1" value="Donation product#1">
    <input type="hidden" id="Lite_Order_LineItems_Quantity_1" name="Lite_Order_LineItems_Quantity_1" value="1">
    <input type="hidden" id="Lite_Order_LineItems_Amount_1" name="Lite_Order_LineItems_Amount_1" value="35">

    <input type="hidden" id="Lite_Order_LineItems_Product_2" name="Lite_Order_LineItems_Product_2" value="Donation product#2">
    <input type="hidden" id="Lite_Order_LineItems_Quantity_2" name="Lite_Order_LineItems_Quantity_2" value="2">
    <input type="hidden" id="Lite_Order_LineItems_Amount_2" name="Lite_Order_LineItems_Amount_2" value="32">

   <!--
            The following url's are used as examples. They do not exist and cant be used for
            development or debugging.
                                 -->
    <input type="hidden" ID="Lite_Website_Successful_url" NAME="Lite_Website_Successful_url"

VALUE="http://www.iveri.co.za/Examples/iveri/Lite/Success.asp">
    <input type="hidden" ID="Lite_Website_Fail_url" NAME="Lite_Website_Fail_url" VALUE="http://www.iveri.co.za/Examples/iveri/Lite/Fail.asp">
    <input type="hidden" ID="Lite_Website_TryLater_url" NAME="Lite_Website_TryLater_url" VALUE="http://www.iveri.co.za/Examples/iveri/Lite/TryLater.asp">
    <input type="hidden" ID="Lite_Website_Error_url" NAME="Lite_Website_Error_url" VALUE="http://www.iveri.co.za/Examples/iveri/Lite/Error.asp">

<!-- Ecml start-->

    <!-- ShipTo -->
    <input type="hidden" id="Ecom_ShipTo_Postal_Name_Prefix" name="Ecom_ShipTo_Postal_Name_Prefix" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_Name_First" name="Ecom_ShipTo_Postal_Name_First" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_Name_Middle" name="Ecom_ShipTo_Postal_Name_Middle" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_Name_Last" name="Ecom_ShipTo_Postal_Name_Last" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_Name_Suffix" name="Ecom_ShipTo_Postal_Name_Suffix" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_Street_Line1" name="Ecom_ShipTo_Postal_Street_Line1" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_Street_Line2" name="Ecom_ShipTo_Postal_Street_Line2" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_Street_Line3" name="Ecom_ShipTo_Postal_Street_Line3" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_City" name="Ecom_ShipTo_Postal_City" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_StateProv" name="Ecom_ShipTo_Postal_StateProv" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_PostalCode" name="Ecom_ShipTo_Postal_PostalCode" value="">
    <input type="hidden" id="Ecom_ShipTo_Postal_CountryCode" name="Ecom_ShipTo_Postal_CountryCode" value="">
    <input type="hidden" id="Ecom_ShipTo_Telecom_Phone_Number" name="Ecom_ShipTo_Telecom_Phone_Number" value="">
    <input type="hidden" id="Ecom_ShipTo_Online_Email" name="Ecom_ShipTo_Online_Email" value="">

    <!-- BillTo -->
        <tr>
            <td>
                Name:
            </td>
            <td>
<SELECT id=Ecom_BillTo_Postal_Name_Prefix name=Ecom_BillTo_Postal_Name_Prefix>
    <option value="Mr." >Mr.</option>
    <option value="Mrs." >Mrs.</option>
    <option value="Miss." >Miss.</option>
    <option value="Ms." >Ms.</option>
    <option value="Prof." >Prof.</option>
    <option value="Dr." >Dr.</option>
    <option value="Sir." >Sir.</option>
</SELECT>
    <input type="text" id="Ecom_BillTo_Postal_Name_First" name="Ecom_BillTo_Postal_Name_First" value="John" size=8>
    <input type="hidden" id="Ecom_BillTo_Postal_Name_Middle" name="Ecom_BillTo_Postal_Name_Middle" value="">
    <input type="text" id="Ecom_BillTo_Postal_Name_Last" name="Ecom_BillTo_Postal_Name_Last" value="Doe" size=10>
            </td>
        </tr>   
       
    <input type="hidden" id="Ecom_BillTo_Postal_Name_Suffix" name="Ecom_BillTo_Postal_Name_Suffix" value="iVeri">
    <input type="hidden" id="Ecom_BillTo_Postal_Street_Line1" name="Ecom_BillTo_Postal_Street_Line1" value="">
    <input type="hidden" id="Ecom_BillTo_Postal_Street_Line2" name="Ecom_BillTo_Postal_Street_Line2" value="">
    <input type="hidden" id="Ecom_BillTo_Postal_Street_Line3" name="Ecom_BillTo_Postal_Street_Line3" value="">
    <input type="hidden" id="Ecom_BillTo_Postal_City" name="Ecom_BillTo_Postal_City" value="">
    <input type="hidden" id="Ecom_BillTo_Postal_StateProv" name="Ecom_BillTo_Postal_StateProv" value="">
    <input type="hidden" id="Ecom_BillTo_Postal_PostalCode" name="Ecom_BillTo_Postal_PostalCode" value="">
    <input type="hidden" id="Ecom_BillTo_Postal_CountryCode" name="Ecom_BillTo_Postal_CountryCode" value="">
    <input type="hidden" id="Ecom_BillTo_Telecom_Phone_Number" name="Ecom_BillTo_Telecom_Phone_Number" value="4457500">
        <tr>
            <td>
                Email:
            </td>
            <td>
                <input type="text" id="Ecom_BillTo_Online_Email" name="Ecom_BillTo_Online_Email" value="" size=20>
            </td>
        </tr>   

    <!-- ReceiptTo -->
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Name_Prefix" name="Ecom_ReceiptTo_Postal_Name_Prefix" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Name_First" name="Ecom_ReceiptTo_Postal_Name_First" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Name_Middle" name="Ecom_ReceiptTo_Postal_Name_Middle" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Name_Last" name="Ecom_ReceiptTo_Postal_Name_Last" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Name_Suffix" name="Ecom_ReceiptTo_Postal_Name_Suffix" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Street_Line1" name="Ecom_ReceiptTo_Postal_Street_Line1" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Street_Line2" name="Ecom_ReceiptTo_Postal_Street_Line2" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_Street_Line3" name="Ecom_ReceiptTo_Postal_Street_Line3" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_City" name="Ecom_ReceiptTo_Postal_City" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_StateProv" name="Ecom_ReceiptTo_Postal_StateProv" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_PostalCode" name="Ecom_ReceiptTo_Postal_PostalCode" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Postal_CountryCode" name="Ecom_ReceiptTo_Postal_CountryCode" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Telecom_Phone_Number" name="Ecom_ReceiptTo_Telecom_Phone_Number" value="">
    <input type="hidden" id="Ecom_ReceiptTo_Online_Email" name="Ecom_ReceiptTo_Online_Email" value="">

    <!-- Payment -->
    <input type="hidden" id="Ecom_Payment_Card_Name" name="Ecom_Payment_Card_Name" value="">
    <input type="hidden" id="Ecom_Payment_Card_Type" name="Ecom_Payment_Card_Type" value="">


        <tr>
            <td>
                Credit Card    Number:
            </td>
            <td>
                <input TYPE="text" ID="Ecom_Payment_Card_Number" NAME="Ecom_Payment_Card_Number" VALUE="" size="20">
                <small>Please type your credit card number without any spaces or hyphens</small>
            </td>
        </tr>
        <tr>
            <td>
                Expiry Date:
            </td>
            <td>
                <input type="hidden" id="Ecom_Payment_Card_StartDate_Day" name="Ecom_Payment_Card_StartDate_Day" value="00">
                <input type="hidden" id="Ecom_Payment_Card_StartDate_Month" name="Ecom_Payment_Card_StartDate_Month" value="07" size=2>
                <input type="hidden" id="Ecom_Payment_Card_StartDate_Year" name="Ecom_Payment_Card_StartDate_Year" value="1999" size=4><br>
                <input type="hidden" id="Ecom_Payment_Card_ExpDate_Day" name="Ecom_Payment_Card_ExpDate_Day" value="00">
                <input type="text" id="Ecom_Payment_Card_ExpDate_Month" name="Ecom_Payment_Card_ExpDate_Month" value="07" size=2>
                <input type="text" id="Ecom_Payment_Card_ExpDate_Year" name="Ecom_Payment_Card_ExpDate_Year" value="2001" size=4><br>
            </td>
        </tr>

    <input type="text" id="Ecom_Payment_Card_Verification" name="Ecom_Payment_Card_Verification" value="3">
    <input type="hidden" id="Ecom_Payment_Card_Protocols" name="Ecom_Payment_Card_Protocols" value="iVeri">

        <tr>
            <td>
                Invoice:
            </td>
            <td>
                <input TYPE="text" ID="Ecom_ConsumerOrderID" NAME="Ecom_ConsumerOrderID" VALUE="AUTOGENERATE" size="20">
            </td>
        </tr>

    <input type="hidden" id="Ecom_SchemaVersion" name="Ecom_SchemaVersion" value="">
    <input type="hidden" id="Ecom_TransactionComplete" name="Ecom_TransactionComplete" value="False">
<!-- Ecml end-->

<!—Lite Version-->
    <input type="hidden" id="Lite_Version" name="Lite_Version " value="2.0">
<!-- Version end-->
        <tr>
            <td><input TYPE="SUBMIT" NAME="Authorise" VALUE="Authorise"> </td>
            <td><input TYPE="RESET" NAME="Clear" VALUE="Clear"> </td>
        </tr>
    </table>
</center>
</form>

</body>
</html>

Charl Fourie

Hi there

I have written a payment module for iveri light which we have been using for the last 2 years or so.  However, two weeks or so ago, Iveri changed their processing system, effectively breaking my plugin.  The iveri payment system now works as follows:

  • You post all your fields to a specified location
  • Iveri reads the fields and then sends back html which contains a form with one hidden field, a cookie, and some javascript to post the form once it has been loaded. (The form points to a different location then the original url.  I have tried but could not get it to work.  Maybe they are checking for some heather which I havn't set.)

Below, find my source as it stands at the moment.  Maybe can somebody who also wants to use it get it to work.  (note that the files ps_iveri_lite.cfg.php and HtmlDissector.php should be in a sub-directory called iveri, as noted in the requirestatements in ps_iveri_lite.php)

Regards,

Charl Fourie

--------------------------------------------------------------------------------------------------------------------------
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

require_once(CLASSPATH.'payment/iveri/HtmlDissector.php');

class ps_iveri_lite {

    var $payment_code = "IVERL";
    var $classname = "ps_iveri_lite";
 
    /**
    * Show all configuration parameters for this payment method
    * @returns boolean False when the Payment method has no configration
    */
    function show_configuration() {
        return false;
    }
   
    function has_configuration() {
        return false;
    }
   
    /**
     * Returns the "is_writeable" status of the configuration file
     * @param void
     * @returns boolean True when the configuration file is writeable, false when not
     */
    function configfile_writeable() {
        return false;
    }
   
    /**
     * Returns the "is_readable" status of the configuration file
     * @param void
     * @returns boolean True when the configuration file is writeable, false when not
     */
    function configfile_readable() {
        return is_readable( CLASSPATH."payment/iveri/".$this->classname.".cfg.php" );
    }
     
    /**
     * Writes the configuration file for this payment method
     * @param array An array of objects
     * @return boolean True when writing was successful
     */
    function write_configuration( &$d ) {
        return false;
    }
   
    /**
     * Called by VirtueMart to process payment on a transaction.
     * @return boolean True if the transaction was successful
     */
    function process_payment($order_number, $order_total, &$d) {         
        $error = null;
        $tdata = $this->prepare_transaction_data($order_number, $order_total, $d);
        $result = $this->perform_payment_transaction($tdata, $error);
        return $this->evaluate_transaction_result($result, $error, $d);
    }
   
    /**
     * Compiles an array of the fields to be sent to Iveri for the transaction.
     * @return Array The fields to be sent to Ivery for the transaction.
     */
    function prepare_transaction_data($order_number, $order_total, &$d) {
        global $IVERI_STATIC_FIELDS;       

        require_once(CLASSPATH ."payment/iveri/".$this->classname.".cfg.php");
     
        $ps_vendor_id = $_SESSION["ps_vendor_id"];
        $auth = $_SESSION['auth'];
        $ps_checkout = new ps_checkout;
     
        // Get user billing information
        $dbbt = new ps_DB;
        $qt = "SELECT * FROM #__{vm}_user_info WHERE user_id=".$auth["user_id"]." AND address_type='BT'";
        $dbbt->query($qt);
        $dbbt->next_record();
        $user_info_id = $dbbt->f("user_info_id");
        if( $user_info_id != $d["ship_to_info_id"]) {
            // Get user billing information
            $dbst =& new ps_DB;
            $qt = "SELECT * FROM #__{vm}_user_info WHERE user_info_id='".$d["ship_to_info_id"]."' AND address_type='ST'";
            $dbst->query($qt);
            $dbst->next_record();
        }
        else {
            $dbst = $dbbt;
        }

        $transaction_data = array (
            // Customer Name and Billing Address
            'Ecom_BillTo_Postal_Name_Prefix' => substr($dbbt->f("title"), 0, 10),
            'Ecom_BillTo_Postal_Name_First' => substr($dbbt->f("first_name"), 0, 20),
            'Ecom_BillTo_Postal_Name_Middle' => substr($dbbt->f("middle_name"), 0, 20),
            'Ecom_BillTo_Postal_Name_Last' => substr($dbbt->f("last_name"), 0, 20),
            'Ecom_BillTo_Postal_Street_Line1' => substr($dbbt->f("address_1"), 0, 20),
            'Ecom_BillTo_Postal_Street_Line2' => substr($dbbt->f("address_2"), 0, 20),
            'Ecom_BillTo_Postal_Street_Line3' => '',
            'Ecom_BillTo_Postal_City' => substr($dbbt->f("city"), 0, 22),
            'Ecom_BillTo_Postal_StateProv' => substr($dbbt->f("state"), 0, 20),
            'Ecom_BillTo_Postal_PostalCode' => substr($dbbt->f("zip"), 0, 20),
            'Ecom_BillTo_Postal_CountryCode' => substr($dbbt->f("country"), 0, 20),
            'Ecom_BillTo_Telecom_Phone_Number' => substr($dbbt->f("phone_1"), 0, 30),
            'Ecom_BillTo_Online_Email' => substr($dbbt->f("user_email"), 0, 40),

            'Ecom_ReceiptTo_Postal_Name_Prefix' => substr($dbbt->f("title"), 0, 10),
            'Ecom_ReceiptTo_Postal_Name_First' => substr($dbbt->f("first_name"), 0, 20),
            'Ecom_ReceiptTo_Postal_Name_Middle' => substr($dbbt->f("middle_name"), 0, 20),
            'Ecom_ReceiptTo_Postal_Name_Last' => substr($dbbt->f("last_name"), 0, 20),
            'Ecom_ReceiptTo_Postal_Street_Line1' => substr($dbbt->f("address_1"), 0, 20),
            'Ecom_ReceiptTo_Postal_Street_Line2' => substr($dbbt->f("address_2"), 0, 20),
            'Ecom_ReceiptTo_Postal_Street_Line3' => '',
            'Ecom_ReceiptTo_Postal_City' => substr($dbbt->f("city"), 0, 22),
            'Ecom_ReceiptTo_Postal_StateProv' => substr($dbbt->f("state"), 0, 20),
            'Ecom_ReceiptTo_Postal_PostalCode' => substr($dbbt->f("zip"), 0, 20),
            'Ecom_ReceiptTo_Postal_CountryCode' => substr($dbbt->f("country"), 0, 20),
            'Ecom_ReceiptTo_Telecom_Phone_Number' => substr($dbbt->f("phone_1"), 0, 30),
            'Ecom_ReceiptTo_Online_Email' => substr($dbbt->f("user_email"), 0, 40),

            // Customer Shipping Address
            'Ecom_ShipTo_Postal_Name_Prefix' => substr($dbst->f("title"), 0, 10),
            'Ecom_ShipTo_Postal_Name_First' => substr($dbst->f("first_name"), 0, 20),
            'Ecom_ShipTo_Postal_Name_Middle' => substr($dbst->f("middle_name"), 0, 20),
            'Ecom_ShipTo_Postal_Name_Last' => substr($dbst->f("last_name"), 0, 20),
            'Ecom_ShipTo_Postal_Street_Line1' => substr($dbst->f("address_1"), 0, 20),
            'Ecom_ShipTo_Postal_Street_Line2' => substr($dbst->f("address_2"), 0, 20),
            'Ecom_ShipTo_Postal_Street_Line3' => '',
            'Ecom_ShipTo_Postal_City' => substr($dbst->f("city"), 0, 22),
            'Ecom_ShipTo_Postal_StateProv' => substr($dbst->f("state"), 0, 20),
            'Ecom_ShipTo_Postal_PostalCode' => substr($dbst->f("zip"), 0, 20),
            'Ecom_ShipTo_Postal_CountryCode' => substr($dbst->f("country"), 0, 20),
            'Ecom_ShipTo_Telecom_Phone_Number' => substr($dbst->f("phone_1"), 0, 30),
                       
            // Invoice Information
            'Ecom_ConsumerOrderId' => substr($order_number, 0, 20),
           
            // Transaction Data
            'Ecom_Payment_Card_ExpDate_Month' => $_SESSION['ccdata']['order_payment_expire_month'],
            'Ecom_Payment_Card_ExpDate_Year' => $_SESSION['ccdata']['order_payment_expire_year'],
            'Ecom_Payment_Card_Number' => $_SESSION['ccdata']['order_payment_number'],
            'Ecom_Payment_Card_Name' => $_SESSION['ccdata']['order_payment_name'],


            'Lite_Order_LineItems_Product_1' => 'Items for order number ' . substr($order_number, 0, 20),
            'Lite_Order_LineItems_Amount_1' => floor($order_total * 100),
            'Lite_Order_LineItems_Quantity_1' => 1,
            'Lite_Order_Amount' => floor($order_total * 100),
        );

        foreach ($IVERI_STATIC_FIELDS as $name => $value) {
            $transaction_data[$name] = $value;
        }
       
        return $transaction_data;
    }
   
    /**
     * Performs the physical payment transaction with Iveri.
     * @param Array $transaction_data The fields to be sent to Ivery for the
     *        transaction.
     * @param null $error If an error occurred during the transaction, this
     *        parrameter will be populated with the error description.
     * @return HtmlDissector The final reply returned by Iveri.
     */
    function perform_payment_transaction($transaction_data, &$error) {
       $end_result = null;
       $ps1 = $this->buildPostString($transaction_data);
       $session = $this->start_session();
       $result1 = $this->post($session, IVERI_URL1, $ps1, IVERI_REFERER, $error);
       
       if(empty($error)) {
          $ps2 = $this->buildPostString($result1, false);
          $end_result = $this->post($session, IVERI_URL2, $ps2, IVERI_URL1, $error);
       }
       
       $this->end_session($session);
       return $end_result;
    }
   
    /**
     * Evaluates & processes the result returned by Iveri for the transaction.
     * @param HtmlDissector $result The result returned by Ivery for the
     *        transaction that have just been performed.
     * @param String $error An error description if captured, otherwise null.
     * @param ?? $d The $d parameter passed into process_payment by
     *        VirtueMart
     * @return Boolean True if the transaction was successful.
     */
    function evaluate_transaction_result($result, $error, &$d) {
        global $PHPSHOP_LANG;
         
        if(!empty($error)) {
            $html = $error . "<br/><span class=\"message\">"
                .$PHPSHOP_LANG->_PHPSHOP_PAYMENT_INTERNAL_ERROR
                . " Iveri.com</span>";                   
            return false;
        }       
       
        if ($this->required_field_missing($result)) {
           $html = "payment gateway gave an invalid response."
               ."<br/><span class=\"message\">"
                .$PHPSHOP_LANG->_PHPSHOP_PAYMENT_INTERNAL_ERROR
                . " Iveri.com</span>";   
            return false;
        }

        if (!$result['LITE_PAYMENT_CARD_STATUS']) {
            $d["order_payment_log"]      = $PHPSHOP_LANG->_PHPSHOP_PAYMENT_TRANSACTION_SUCCESS.": ";
            $d["order_payment_log"]     .= $result['LITE_RESULT_DESCRIPTION'];
            $d["order_payment_trans_id"] = $result['ECOM_CONSUMERORDERID'];
            return true;
        }
        else {
            $d["error"]                  = $result['LITE_RESULT_DESCRIPTION'];
            $d["order_payment_log"]      = $result['LITE_RESULT_DESCRIPTION'];
            $d["order_payment_trans_id"] = $result['ECOM_CONSUMERORDERID'];
            return false;
        }
    }
   
    /**
     * Evaluates the result returned by Iveri and check if any required fields
     * are missing
     * @return boolean false if the result is null or if any fields are missing
     *         from the result.
     */
    function required_field_missing($result) {
       return empty($result)
         ||!array_key_exists('LITE_PAYMENT_CARD_STATUS', $result)
          ||!array_key_exists('LITE_RESULT_DESCRIPTION', $result)
          ||!array_key_exists('ECOM_CONSUMERORDERID', $result);
    }
   
    /**
     * Sets up a new curl session
     */
    function start_session() {
       $session = curl_init();
        curl_setopt($session, CURLOPT_HEADER,         0);
        curl_setopt($session, CURLOPT_POST,           1);
        curl_setopt($session, CURLOPT_FOLLOWLOCATION, 0);
        curl_setopt($session, CURLOPT_FAILONERROR,    true);
        curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($session, CURLOPT_COOKIEFILE,     "");
        return $session;       
    }
   
    /**
     * Destroys a curl session
     */
    function end_session($session) {
       if ($session) {
          curl_close($session);
       }
    }

   /**
    * Does a post to the given curl session.
    */
    function post($session, $url, $poststring, $referer, &$error) {
        curl_setopt($session, CURLOPT_URL,        $url);
        curl_setopt($session, CURLOPT_REFERER,    $referer);
        curl_setopt($session, CURLOPT_POSTFIELDS, $poststring);
           
        $result = curl_exec($session);
        $error = curl_error($session);
        $dissector = new HtmlDissector($result);
        return $dissector->getHiddenInputValues();
    }
   
   /**
    * Converts a name-value array to a valid html post string.
    */
    function buildPostString($formdata, $encoded = true) {
        $poststring = '';
        if ($encoded) {
            foreach($formdata AS $key => $val) {
                $poststring .= urlencode($key) . "=" . urlencode($val) . "&";
           }
        } else {
            foreach($formdata AS $key => $val) {
                $poststring .= $key . "=" . $val . "&";
           }
        }
        // strip off trailing ampersand
        $poststring = substr($poststring, 0, -1);   
        return $poststring;   
    }
}

--------------------------------------------------------------------------------------------------------------------
<?php
* @copyright (C) 2005 Charl Fourie

class HtmlDissector {
   var $contents;
   
   function HtmlDissector($contents) {
      $this->contents = str_replace('\n', '', $contents);
   }
   
   function getInputTags() {
      preg_match_all('/<input\s.*?>/i', $this->contents, $results);
      return $results;
   }   
   
   function getHiddenInputTags() {
      $input_tags = $this->getInputTags();
      $results = Array();
      foreach($input_tags[0] as $tag) {
         if (preg_match('/type\s*=\s*(\'|")hidden(\'|")/i', $tag) > 0) {
            array_push($results, $tag);
         }
      }
      return $results;
   }

    function getHiddenInputValues() {
        $tags = $this->getHiddenInputTags();
        $nameValues = array();

        foreach ($tags as $tag) {
            $name = trim($this->getAttributeValue("name", $tag));
            if (strlen($name) == 0) continue;
            $value = $this->getAttributeValue("value", $tag);
            $nameValues[$name] = $value;
        }
       
        return $nameValues;
    }

    function getAttributeValue($name, $tag) {
        $regex1 = '/[\s]' . $name . '[\s]*=[\s]*["\'][-\]\\_!@#$%^&*()_+=[|}'
          . '{;:\/?.,\w\s]*(?=["\'])/i';
        $regex2 = '/[\s]' . $name . '[\s]*=[\s]*["\']/i';

        preg_match_all($regex1, $tag, $matches);
        if (count($matches[0]) != 1) return '';

        // The second regex is included because php4 does not seem to support
        // reqular expressions with variable sized lookbacks.
        return preg_replace($regex2, "", $matches[0][0]);
    }
}
?>
----------------------------------------------------------------------------------------------------------------
        <?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

define ('IVERI_URL1',    'https://backoffice.iveri.co.za/Lite/Transactions/New/Authorise.aspx');
define ('IVERI_URL2',    'https://backoffice.iveri.co.za/Authorise.aspx');
define ('IVERI_REFERER', 'http://www.yoursite.co.za/administrator/components/com_virtuemart/classes/payment/ps_iveri_lite.php');

$IVERI_STATIC_FIELDS = array (
    'ECOM_PAYMENT_CARD_PROTOCOLS' => 'iVeri',
    'ECOM_PAYMENT_CARD_VERIFICATION' => '',
    'LITE_VERSION' => '2',
    'ECOM_PAYMENT_CARD_TYPE' => '',
    'ECOM_PAYMENT_CARD_NAME' => '',
    'Ecom_TransactionComplete' => 'False',
    'ECOM_SCHEMAVERSION' => '',
    'LITE_MERCHANT_APPLICATIONID' => 'YOUR-MERCHANT-CODE-HERE',
    'LITE_ORDER_TERMINAL' => 'Web',
    'LITE_ORDER_AUTHORISATIONCODE' => '',
    'LITE_ORDER_BUDGET_PERIOD' => '0',
    'Lite_ConsumerOrderID_PreFix' => 'XX',
    'LITE_AUTHORISATION' => '',
    'LITE_ON_ERROR_RESUME_NEXT' => 'TRUE',
    // The following 4 fields are fake urls added to satisfy Iveri requirements
    'LITE_WEBSITE_SUCCESSFUL_URL' => 'http://www.blah.co.za/success.php',
    'LITE_WEBSITE_FAIL_URL' => 'http://www.blah.co.za/fail.php',
    'LITE_WEBSITE_TRYLATER_URL' => 'http://www.blah.co.za/trylater.php',
    'LITE_WEBSITE_ERROR_URL' => 'http://www.blah.co.za/error.php',
    'Ecom_Payment_Card_StartDate_Day' => '0',
    'Ecom_Payment_Card_StartDate_Month' => '7',
    'Ecom_Payment_Card_StartDate_Year' => '1999',
    'Ecom_Payment_Card_ExpDate_Day' => '0'
)
?>



Julian

Thanks for the kickstart on the iVeri gateway. I've managed to get it working.
The code is too long to include here so I've attached a txt file that contains all the info.

Julian Titshall
www.prosyscom.co.za



[attachment cleanup by admin]

Trent Murgatroyd

#3
Hey guys.
Been wanting to do something like this for ages, but haven't gotten a round tuit.
Thanx a million for the work, but...

I have tried the code unsuccessfully.(Everything is set up OK,  I get this error..)

3. Your transaction could not be processed due to missing information.
An error(2) occurred: Your transaction could not be processed due to missing information.

backoffice.iveri.co.za/Lite/Transactions/New/Authorise.aspx


I'm probably doing something silly, and am not a code fundi, so any assistance appreciated.

Thanx again for the efforts

Charl Fourie

#4
Hi there

I have created and released a payment module for Paygate (a South African payment gateway) in February 2007 which works well.  The problem with Ivery is that the expected way to use their gateway is to redirect the browser off your site to theirs.  Due to that they frequently tend to make changes to their backend which breaks payment processors which fakes this process in the background.  I used Ivery before and had to make changes to my payment module 3 times in a 2 year span after changes that they made.

The following link should take you to the right place for the Paygate module... http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=25522.0

Marquis

Hi,

Has anyone done any work on the iVeri Enterprise payment module for VirtueMart and wouldn't mind sharing with us?

Thanks!

Rhino13

If any body needs a Iveri Enterprise gateway here it is :)

[attachment cleanup by admin]

Skabenga


ronin75

Hey guys i'm hoping someone can assist me, i see someone had the same problem back in 2007 but there is no concrete reply to his post. i'm trying to incorporate iVeri Lite into virtuemart but keep getting the following error message:
3. Your transaction could not be processed due to missing information.
An error(2) occurred: Your transaction could not be processed due to missing information.

backoffice.iveri.co.za/Lite/Transactions/New/Authorise.aspx
Fatal error: Call to undefined function Your transaction could not be processed due to missing information.<br>()

i've used the iVeri Lite payment module written by Charl Fourie. your assistance would be greatly appreciated thanks...

portico

Hey Guys,

Did anyone manage to solve this error:
"3. Your transaction could not be processed due to missing information.
An error(2) occurred: Your transaction could not be processed due to missing information."?