iTransact Catalog Payment Module README

Author: TriciaB (info@barestyle.com) - and Mike Sumsion at iTransact.com (tep_dev@itransact.com)

PLEASE READ!!  I would appreciate feedback, bug reports, etc. 

Included files for catalog:
  - README_catalog_itransact_split (this file)
  - itransact_split.php - Put in catalog/includes/languages/english/modules/payment/
  - itransact_split.php - Put in catalog/includes/modules/payment/
  - itransact_split.sql - For creating the required table for storing itransact results

TO DO: 	Currently supports only one address, which is for billing.  Need to grab the current
	default address for billing and the specified shipping address.  iTransact handles them
	both, but I wanted to get this to those who want to use it as-is.

	I would like to give users the option to disable the customer/merchant email sent by TEP
	and put the option in admin.  If anyone has done this, please let me know.

CATALOG INFO (See separate admin README)

  As a disclaimer, this module is basically "complete" but will improve.  I've commented my
  work so you'd know what I was doing.  This module has been tested with Preview Release 2.2-CVS.
  I'm sure you can get it to work with 2.1, but that's up to you.

  This TEP payment module will work with iTransact.com's "Split Form" processing.
  The Split Form enables the merchant to process credit card transactions securely
  without the need for a secure server.  Basic customer information is received within
  TEP (name, address, etc.) and the remainder is obtained on iTransact's secure server.
  I plan to create a module for their other products as well...but time is limited.  :)
  I've been able to work with iTransact to get them to create a Split Form page specifically
  for TEP users.  This helps to maintain the look-and-feel of your catalog.  They've agreed
  to host TEP users' stylesheet so that it can be accessed locally on their secure server.  
  However, if you are using the default TEP stylesheet, you don't need to do anything.  iTransact
  will default to this.  Kinda cool.  They've been very helpful.  If you like what they've done,
  drop them an email to tep_dev@itransact.com.  [As it turns out, iTransact's offices are in the
  same building I'm now in.  Worked out quite well.  ;) ]

  You can set up a test account with iTransact by visiting:
  https://secure.itransact.com/merchant/test.html
  You will be given a 5-digit gateway ID and instructions.
 
  I had to make some variables in other PHP pages global to make this work.  I also had to
  create a new array in "checkout_confirmation.php" so that product attributes wouldn't
  have to be pulled from the db again.  (See below).

  For this module to work, you must do the following.  When finished, install the iTransact admin
  stuff and activate the iTransact module.  (If you have the general "cc" TEP module active, de-activate it.)

  1. Put the files, listed above, in their correct directories.

  2. Use the included itransact_split.sql file to create the "orders_itransact_auth" table.  This table will
     contain the information posted back from iTransact after a transaction.  Some of the fields
     in this table are not used in this module, but will be used in future iTransact modules/updates.
     To import, use:
	mysql catalog < ./itransact_split.sql

  3. In catalog/checkout_process.php you can disable the email that is sent by TEP.  This isn't required,
     but the TEP email isn't needed since iTransact sends out a nicely formatted email from your store.
     To do this, find the line that sends the mail and just disable it with //.  
	tep_mail($customer_name, $customer_values['customers_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email_order), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');

  4. In catalog/login.php - make $customer_id a GLOBAL variable, unless it's done already in your version.  (If there's a way around this, let me know.)

  5. In catalog/checkout_confirmation.php - make $products a GLOBAL variable, unless it's done already in your version.

  6. In catalog/checkout_confirmation.php - create a new global ARRAY called $attributes_for_itransact, unless it's already there.  
     This arrary captures the attributes of each product, such as size, color, etc. for use
     in the email sent out by iTransact.  You don't HAVE to add this array, but it's a
     nice feature.  To add it, make the following changes.  If you're familiar with diffs, 
     you'll understand this.  Otherwise, I've noted NEW lines with "+".  No lines were removed.

@@ (Original) @@
    //------display customer choosen option --------
    $attributes_exist = '0';
    if ($products[$i]['attributes']) {
      $attributes_exist = '1';
      reset($products[$i]['attributes']);
      while (list($option, $value) = each($products[$i]['attributes'])) {
        $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
        $attributes_values = tep_db_fetch_array($attributes);
        echo '<br><small><i>&nbsp;-&nbsp;' . $attributes_values['products_options_name'] . '&nbsp;:&nbsp;' . $attributes_values['products_options_values_name'] . '</i></small>';
      }
@@ (End Original) @@

@@ (Changes) @@
    //------display customer choosen option --------
    $attributes_exist = '0';
    if ($products[$i]['attributes']) {
      $attributes_exist = '1';
      reset($products[$i]['attributes']);
+   $num = 0;
      while (list($option, $value) = each($products[$i]['attributes'])) {
        $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
        $attributes_values = tep_db_fetch_array($attributes);
+	$attributes_for_itransact['name'][$i . $num] .= $attributes_values['products_options_name'];
+	$attributes_for_itransact['value'][$i . $num] .= $attributes_values['products_options_values_name'];
+   $num++;
        echo '<br><small><i>&nbsp;-&nbsp;' . $attributes_values['products_options_name'] . '&nbsp;:&nbsp;' . $attributes_values['products_options_values_name'] . '</i></small>';
      }
@@ (End Changes) @@

