Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Alternative Cybersource setup


tim1281

Recommended Posts

Hi everyone,

 

I've noticed a lot of people looking for help setting up cybersource and I've posted in a couple of threads offering assistance to those that needed it. After helping 6 or 7 people now via email I thought I'd just post how I got cybersource working with my store.

 

Now this is more of a "hack" then an actual contribution. I use paysystems as my payment processor and they switched their system to use cybersource a while back so I pretty much just hacked my pre-installed paysystems contribution to keep my store up and running with minimal down time.

 

If you want to do all the processing on your server then this isn't for you. I use the Hoster Order Page on cybersource and just customized the payment entry and post process pages via the cybersource interface so it looks like you're still on my site (ie. adding headers & footers that pull graphics, etc. from my site).

 

So here is how I did it. You will need to have this paysystems module installed as I made my modifications on a preinstalled version of it (http://www.oscommerce.com/community/contributions,1194/category,all/search,paysystems). Once you make the changes to the files, the admin portion of the paysystems module will be useless since Cybersource doesn't use any of that information. This "mod" could be much nicer but I was focused on getting the thing to work correctly instead of making an official contribution for oscommerce :)

 

In any case, here is how it goes.

 

Login to the cybersource control panel and click the "Settings" menu item. Then in the left side menu click "Security Keys". What you want to do is "Generate HOP Script". Choose PHP (obviously) and download the script it generates for you.

 

Now what I did on my site was place the HOP.php file outside the wwwroot directory so it is not accessible via a browser. The file has some sensitive information so I did that to play it safe.

 

Once you have the HOP.php file uploaded to the server you'll want to edit checkout_confirmation.php. In that file, add the following line:

 

include("/home/your_site_directory_here/HOP.php");

 

under require('includes/application_top.php');

 

Replace the your_site_directory_here thing with the directory your site is in or what ever the path to the HOP file ends up being.

 

In that same file, find the the following line:

 

echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');

 

below that line put this line:

 

InsertSignature(number_format($order->info['total'], 2));

 

Save the file and upload it to the site.

 

I've included my modified paysystems.php below, it belongs in the catalog/includes/modules/payment directory. You can look through it to see the changes but you should be able to upload the file as is and have it work. The two big changes I made were the form action URL:

 

$this->form_action_url = 'https://orderpage.ic3.com/hop/orderform.jsp';

 

and also the $process_button_string section. In the $process_button_string I have this line towards the bottom:

 

tep_draw_hidden_field('orderPage_transactionType', 'sale') .

 

You can change 'sale' to something else (there is a reference guide available in the cybersource control panel). By setting it to sale you don't have to login to the cybersource control panel to approve each sale, it automatically captures the amount and send you the deposit. You can also edit the look and options of the order page via the control panel (adding header/footer, choosing which info the customer has to enter, etc.).

 

That should be it. There really aren't too many changes to be made. Should take you all of 10 minutes. If you have any questions let me know.

 

<?php
/*
 $Id: paysystems.php,v 1.2a 2003/04/23                 Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class paysystems {
   var $code, $title, $description, $enabled;

// class constructor
   function paysystems() {
     global $order;

     $this->code = 'paysystems';
     $this->title = MODULE_PAYMENT_PAYSYSTEMS_TEXT_TITLE;
     $this->description = MODULE_PAYMENT_PAYSYSTEMS_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_PAYMENT_PAYSYSTEMS_SORT_ORDER;      
     $this->enabled = ((MODULE_PAYMENT_PAYSYSTEMS_STATUS == 'True') ? true : false);

     if ((int)MODULE_PAYMENT_PAYSYSTEMS_ORDER_STATUS_ID > 0) {
       $this->order_status = MODULE_PAYMENT_PAYSYSTEMS_ORDER_STATUS_ID;
     }

     if (is_object($order)) $this->update_status();

     $this->form_action_url = 'https://orderpage.ic3.com/hop/orderform.jsp';
   }

// class methods
   function update_status() {
     global $order;

     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYSYSTEMS_ZONE > 0) ) {
       $check_flag = false;
       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYSYSTEMS_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
       while ($check = tep_db_fetch_array($check_query)) {
         if ($check['zone_id'] < 1) {
           $check_flag = true;
           break;
         } elseif ($check['zone_id'] == $order->billing['zone_id']) {
           $check_flag = true;
           break;
         }
       }

       if ($check_flag == false) {
         $this->enabled = false;
       }
     }
   }

   function javascript_validation() {
     return false;
   }

   function selection() {
     //return false;
     return array('id' => $this->code,
                  'module' => $this->title);
    }
 
   function pre_confirmation_check() {
     return false;    
   }

   function confirmation() {
     return false;
   }

   function process_button() {
     global $order, $customer_id, $currencies;
    

 for ($i=0; $i<sizeof($order->products); $i++) {

   if ($i==0)
   
   {
       $products_list = $products_list. "" .$order->products[$i]['name'];
     }else{
       $products_list = $products_list . ", " . $order->products[$i]['name'];
      }
   }

     $process_button_string = tep_draw_hidden_field('comments',$products_list) .
                              tep_draw_hidden_field('billTo_firstName', $order->customer['firstname']) .
                              tep_draw_hidden_field('billTo_lastName', $order->customer['lastname']) .
                              tep_draw_hidden_field('billTo_company', $order->customer['company']) .
                              tep_draw_hidden_field('billTo_street1', $order->customer['street_address']) .
                              tep_draw_hidden_field('billTo_city', $order->customer['city']) .
                              tep_draw_hidden_field('billTo_state', $order->delivery['state']) .
                              tep_draw_hidden_field('billTo_postalCode', $order->customer['postcode']) .
                              tep_draw_hidden_field('billTo_country',$order->customer['country']['iso_code_2']) .
                              tep_draw_hidden_field('billTo_phoneNumber', $order->customer['telephone']) .
                              tep_draw_hidden_field('billTo_email', $order->customer['email_address']) .
                              tep_draw_hidden_field('shipTo_firstName', $order->delivery['firstname']) .
                              tep_draw_hidden_field('shipTo_lastName', $order->delivery['lastname']) .
                              tep_draw_hidden_field('shipTo_street1', $order->delivery['street_address']) .
                              tep_draw_hidden_field('shipTo_city', $order->delivery['city']) .
                              tep_draw_hidden_field('shipTo_state', $order->delivery['state']) .
                              tep_draw_hidden_field('shipTo_postalCode', $order->delivery['postcode']) .
                              tep_draw_hidden_field('shipTo_country', $order->delivery['country']['iso_code_2']) . 
                              tep_draw_hidden_field('orderPage_transactionType', 'sale') .                            

     $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id());

     return $process_button_string;

   }

   function before_process() {
     global $HTTP_GET_VARS;

     if ($HTTP_GET_VARS['cc_status'] != 'pass') {
       tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_PAYSYSTEMS_TEXT_ERROR_MESSAGE), 'SSL', true, false));
     }
   }

   function after_process() {
  return false;
   }

   function output_error() {
     global $HTTP_GET_VARS;

     $output_error_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n" .
                            '  <tr>' . "\n" .
                            '    <td class="main"> <font color="#FF0000"><b>' . MODULE_PAYMENT_PAYSYSTEMS_TEXT_ERROR . '</b></font><br> ' . stripslashes($HTTP_GET_VARS['cc_val']) . ' </td>' . "\n" .
                            '  </tr>' . "\n" .
                            '</table>' . "\n";

     return $output_error_string;
   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYSYSTEMS_STATUS'");
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Paysystems Module', 'MODULE_PAYMENT_PAYSYSTEMS_STATUS', 'True', 'Do you want to accept Paysystems payments?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Paysystems Login', 'MODULE_PAYMENT_PAYSYSTEMS_LOGIN', '3800', 'Login used for Paysystems payments', '6', '2', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Paysystems E-Mail Client', 'MODULE_PAYMENT_PAYSYSTEMS_EMAIL', '0', 'Should Paysystems e-mail the customer too? 0=NO, 1=YES', '6', '3', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Paysystems E-Mail Merchant', 'MODULE_PAYMENT_PAYSYSTEMS_EMAIL_MERCHANT', '1', 'Should Paysystems e-mail you? 0=NO, 1=YES', '6', '4', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYSYSTEMS_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '5', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYSYSTEMS_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_PAYSYSTEMS_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     $keys = array('MODULE_PAYMENT_PAYSYSTEMS_STATUS', 'MODULE_PAYMENT_PAYSYSTEMS_LOGIN', 'MODULE_PAYMENT_PAYSYSTEMS_EMAIL', 'MODULE_PAYMENT_PAYSYSTEMS_EMAIL_MERCHANT', 'MODULE_PAYMENT_PAYSYSTEMS_ZONE', 'MODULE_PAYMENT_PAYSYSTEMS_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYSYSTEMS_SORT_ORDER');

     return $keys;
   }
 }
?>

 

- Tim

Edited by tim1281
Link to comment
Share on other sites

Hey,  were you able to set your oscommerce receipt pages up properly also with Cybersource to also register with the Oscommerce DB to track orders and send the customer an Oscommerce generated order email.

 

In your hosted order page setup on cybersource, set the receipt URL to:

 

http://www.yourdomain.com/catalog/checkout...?cc_status=pass

 

That way the customer will be brought back to your site and register the sale on oscommerce. I actually just embedded that link on a receipt page on cybersource since doing a automatic redirect brings up the "you are going to an unsecure site" dialog but having a customer click a link to the receipt page didn't do that (in my tests anyway). The only problem with my method is some people don't read and end up not clicking the link although so far that hasn't happened very often. :)

Link to comment
Share on other sites

Yeah the setup below seems to make the most sense for receipt pages.

 

Cybersource also seems pretty difficult to test/debug order processing. any suggestions? I contacted support and they told me I have to enter a valid credit card number to test. but could just authorize payments under the "authorization" transaction type in which money wouldn't be drafted from my credit card account but just authorized. I guess this is the best we can do at this moment.

 

Thanks for your help.

 

g.

 

 

 

 

In your hosted order page setup on cybersource, set the receipt URL to:

 

http://www.yourdomain.com/catalog/checkout...?cc_status=pass

 

That way the customer will be brought back to your site and register the sale on oscommerce.  I actually just embedded that link on a receipt page on cybersource since doing a automatic redirect brings up the "you are going to an unsecure site" dialog but having a customer click a link to the receipt page didn't do that (in my tests anyway).  The only problem with my method is some people don't read and end up not clicking the link although so far that hasn't happened very often. :)

Link to comment
Share on other sites

  • 5 months later...

I have a relatively new install of osCommerce. I am trying to install your solution, but the "paysystems" module doesn't seem to be working. It says "Paysystems" under Payment Method on my "Payment Information" step of checkout, but there are no buttons or anything.

 

I started looking at applying the same concept of your modifications of "paysystems" to the payment module "cc", but have gotten lost pretty quick.

 

I'm unfortunately new to both PHP and osCommerce. Any suggestions would be greatly appreciated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...