Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need to update a payment module - how?


devink

Recommended Posts

Hi,

 

the SecureHosting module, released in January 2003, doesn't work with the current release of OsCommerce. Are there any guidelines on how it needs to be upgraded?

 

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

 // Class Constructor
 function securehosting() {
	 $this->code = 'securehosting';
	 $this->title = MODULE_PAYMENT_SECUREHOSTING_TEXT_TITLE;
	 $this->description = MODULE_PAYMENT_SECUREHOSTING_TEXT_DESCRIPTION;
	 $this->enabled = ((MODULE_PAYMENT_SECUREHOSTING_STATUS == 'True') ? true : false);
	 $this->form_action_url = 'https://www.secure-server-hosting.com/secutran/secuitems.php';
 }

 // Class Methods
 function javascript_validation() {
	 return false;
 }

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

 function pre_confirmation_check() {
	 return false;
 }

 function confirmation() {
	 return false;
 }

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

	 if(MODULE_PAYMENT_SECUREHOSTING_CURRENCY == 'Selected Currency') {
   $my_currency = $currency;
	 }else{
   $my_currency = substr(MODULE_PAYMENT_SECUREHOSTING_CURRENCY, 5);
	 }
	 
	 if (!in_array($my_currency, array('GBP', 'EUR', 'USD'))) {
   $my_currency = 'GBP';
	 }
	 
	 $process_button_string = tep_draw_hidden_field('filename', MODULE_PAYMENT_SECUREHOSTING_SHREF.'/os_template.html') .
    	 tep_draw_hidden_field('shreference', MODULE_PAYMENT_SECUREHOSTING_SHREF) .
    	 tep_draw_hidden_field('checkcode', MODULE_PAYMENT_SECUREHOSTING_CC) .
    	 tep_draw_hidden_field('shippingcharge', number_format($order->info['shipping_cost'], 2)) .
    	 tep_draw_hidden_field('transactiontax', number_format($order->info['tax'], 2)) .
    	 tep_draw_hidden_field('transactionamount', number_format($order->info['total'], 2)) .
    	 tep_draw_hidden_field('transactioncurrency', $my_currency) .
    	 tep_draw_hidden_field('cardholdersemail', $order->customer['email_address']) .
    	 tep_draw_hidden_field('bill_name', $order->billing['firstname'] . ' ' . $order->billing['lastname']) .
    	 tep_draw_hidden_field('bill_addr_1', $order->billing['street_address']) .
    	 tep_draw_hidden_field('bill_addr_2', $order->billing['suburb']) .
    	 tep_draw_hidden_field('bill_city', $order->billing['city']) .
    	 tep_draw_hidden_field('bill_state', $order->billing['state']) .
    	 tep_draw_hidden_field('bill_post_code', $order->billing['postcode']) .
    	 tep_draw_hidden_field('bill_country', $order->billing['country']['title']) .
    	 tep_draw_hidden_field('bill_tel', $order->customer['telephone']) .
    	 tep_draw_hidden_field('ship_name', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']) .
    	 tep_draw_hidden_field('ship_addr_1', $order->delivery['street_address']) .
    	 tep_draw_hidden_field('ship_addr_2', $order->delivery['suburb']) .
    	 tep_draw_hidden_field('ship_city', $order->delivery['city']) .
    	 tep_draw_hidden_field('ship_state', $order->delivery['state']) .
    	 tep_draw_hidden_field('ship_post_code', $order->delivery['postcode']) .
    	 tep_draw_hidden_field('ship_country', $order->delivery['country']['title']) .
    	 tep_draw_hidden_field('success_url', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .
    	 tep_draw_hidden_field('failure_url', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

	 $secuitems='';
	 $osize = sizeof($order->products);
	 for ($i=0; $i<$osize; $i++) {
   $this_item='['.$order->products[$i]['model'].'||';
   $this_name=$order->products[$i]['name'];
   $size = sizeof($order->products[$i]['attributes']);
   if((isset($order->products[$i]['attributes'])) && ($size > 0)){
  	 $this_name.=' (';
  	 for ($j=0; $j<$size; $j++) {
     $this_name.= $order->products[$i]['attributes'][$j]['option'] . ':' . $order->products[$i]['attributes'][$j]['value'] . ' ';
  	 }
  	 $this_name.=')';
   }
   $prod_total=$order->products[$i]['final_price']*$order->products[$i]['qty'];
   $this_item.=$this_name.'|'.$order->products[$i]['final_price'].'|'.$order->products[$i]['qty'].'|'.$prod_total.']';
   $secuitems.=$this_item;
	 }

	 $process_button_string .= tep_draw_hidden_field('secuitems', $secuitems);
	 return $process_button_string;
 }

 function before_process() {
	 return false;
 }

 function after_process() {
	 return false;
 }

 function output_error() {
	 return false;
 }

 function check() {
	 if(!isset($this->_check)){
   $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_SECUREHOSTING_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 SecureHosting', 'MODULE_PAYMENT_SECUREHOSTING_STATUS', 'True', 'Do you want to accept securehosting payments?', '6', '3', '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 ('SH Reference', 'MODULE_PAYMENT_SECUREHOSTING_SHREF', 'SH20????', 'Your securehosting sh reference', '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 ('Check Code', 'MODULE_PAYMENT_SECUREHOSTING_CC', '123456', 'Your securehosting checkcode', '6', '4', now())");
	 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 ('Currency', 'MODULE_PAYMENT_SECUREHOSTING_CURRENCY', 'GBP', 'The currency to use for credit card transactions', '6', '6', 'tep_cfg_select_option(array(\'GBP\',\'USD\',\'EUR\'), ', now())");
 }

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

 function keys() {
	 return array('MODULE_PAYMENT_SECUREHOSTING_STATUS', 'MODULE_PAYMENT_SECUREHOSTING_SHREF', 'MODULE_PAYMENT_SECUREHOSTING_CC', 'MODULE_PAYMENT_SECUREHOSTING_CURRENCY');
 }
}
?>

Many Thanks,

 

Steve

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...