Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hello,

 

I modified the original CC module to use it with a local bank (banco mercantil). Everything seems to work correctly, but at the very end the transaction is not stored in the database and the cart order remains open. Could someone help me find out where the problem is. This is the code:

 

<?php

/*

$Id: banco_mercantil.php 10567 2009-05-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2007 osCommerce

 

Released under the GNU General Public License

*/

//error_reporting(E_ALL);

 

class banco_mercantil {

var $code, $title, $description, $enabled;

 

// class constructor

function banco_mercantil() {

global $order;

 

$this->code = 'banco_mercantil';

$this->title = MODULE_PAYMENT_MERCANTIL_TEXT_TITLE;

$this->public_title = MODULE_PAYMENT_MERCANTIL_TEXT_PUBLIC_TITLE;

$this->description = MODULE_PAYMENT_MERCANTIL_TEXT_DESCRIPTION;

$this->sort_order = MODULE_PAYMENT_MERCANTIL_SORT_ORDER;

$this->enabled = ((MODULE_PAYMENT_MERCANTIL_STATUS == 'True') ? true : false);

$this->form_action_url = 'http://www.mytest.com:8080/mercantil/A_merc.jsp';

//$this->form_action_url = 'http://mytest.com/mercantil_test.php';

 

if ((int)MODULE_PAYMENT_MERCANTIL_ORDER_STATUS_ID > 0) {

$this->order_status = MODULE_PAYMENT_MERCANTIL_ORDER_STATUS_ID;

}

 

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

}

 

// class methods

function update_status() {

global $order;

 

if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_MERCANTIL_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_MERCANTIL_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 array('id' => $this->code,

'module' => $this->public_title);

}

 

function pre_confirmation_check() {

return false;

}

 

function confirmation() {

 

/* global $order;

// GST print_r($order);die();

for ($i=1; $i<13; $i++) {

$expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));

}

 

$today = getdate();

for ($i=$today['year']; $i < $today['year']+10; $i++) {

$expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));

}

 

$confirmation = array('fields' => array(array('title' => 'Al continuar, será enviado al punto de pago del Banco Mercantil',

'field' => tep_draw_hidden_field('invoiceNumber', $order->total)),

array('title' => MODULE_PAYMENT_MERCANTIL_TEXT_CREDIT_CARD_EXPIRES,

'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year))));

print_r ($confirmation); die();

return $confirmation;*/

return false;

}

 

function process_button() {

global $order;

tep_db_query('INSERT INTO banco_mercantil SET whatever = 1');

$res = tep_db_query('SELECT LAST_INSERT_ID()');

$insert_id = '';

$row = mysql_fetch_array($res);

$insert_id = str_pad($row[0],6,0,STR_PAD_LEFT);

//die($insert_id);

$process_button_string = '';

$params['invoiceNumber'] = $insert_id;

$params['totalAmount'] = $order->info['total'];

foreach ($params as $key => $value) {

$process_button_string .= tep_draw_hidden_field($key, $value);

}

//die($process_button_string);

return $process_button_string;

}

 

function before_process() {

return false;

}

 

function after_process() {

return false;

}

 

function get_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_MERCANTIL_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

echo('en check');

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 ('Activar Módulo Banco Mercantil', 'MODULE_PAYMENT_MERCANTIL_STATUS', 'True', 'Desea aceptar pagos a traves del punto Banco Mercantil?', '6', '0', '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 ('Split Credit Card E-Mail Address', 'MODULE_PAYMENT_MERCANTIL_EMAIL', '', 'If an e-mail address is entered, the middle digits of the credit card number will be sent to the e-mail address (the outside digits are stored in the database with the middle digits censored)', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Mostrar en qué orden.', 'MODULE_PAYMENT_MERCANTIL_SORT_ORDER', '0', 'En qué posición desea mostrar este módulo. Números pequeños se muestra más arriba.', '6', '0' , 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 ('Zona de Pago', 'MODULE_PAYMENT_MERCANTIL_ZONE', '0', 'Si se selecciona una zona, activa este método de pago sólo para esa zona.', '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 ('Estatus de la orden por defecto', 'MODULE_PAYMENT_MERCANTIL_ORDER_STATUS_ID', '0', 'Elija el estatus por defecto de las compras hechas con este módulo', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");

tep_db_query("CREATE TABLE `banco_mercantil` (`order_id` INT(8) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT, `whatever` INT(11) DEFAULT NULL, PRIMARY KEY (`order_id`)) ENGINE=MYISAM DEFAULT CHARSET=latin1");

}

 

function remove() {

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

tep_db_query("DROP TABLE `banco_mercantil`");

}

 

function keys() {

return array('MODULE_PAYMENT_MERCANTIL_STATUS', 'MODULE_PAYMENT_MERCANTIL_EMAIL', 'MODULE_PAYMENT_MERCANTIL_ZONE', 'MODULE_PAYMENT_MERCANTIL_ORDER_STATUS_ID', 'MODULE_PAYMENT_MERCANTIL_SORT_ORDER');

}

}

?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...