R: [Php-it] oscommerce e bancasella

Luca Falvo lfalvo at logos.net
Tue Jun 12 17:28:30 CEST 2007


At 17:15 12/06/2007, you wrote:
>quindi usi il sistema base con le OTP (le sto 
>studiando da documentazione adesso).
>Molto probabilmente utilizzerò anche io quel 
>sistema (se l'azienda non vuole spendere 4€ in + al mese)

:D

>Ma anche se vecchio cmq il modulo dovrebbe 
>funzionare. o no? (domani posso fare i test e lo saprò)

le offerte commerciali cambiano nel tempo e anche 
le scelte tecniche si adeguano. non so cosa 
abbiano toccato ma se implementi il modulo così com'è non funziona.


>Forse chiedo troppo, ma cosa hai modificato? i 
>file puoi eventualmente spedirli?

io ho dovuto metter mano ai file 
checkout_process.php e gestpay_otp_response.php che ti allego.

in più ho dovuto creare una tabella d'appoggio per la gestione delle sessioni:
CREATE TABLE `ots_sessions` (
   `ots` varchar(32) NOT NULL default '',
   `sesskey` varchar(32) NOT NULL default '',
   `value` text NOT NULL,
   PRIMARY KEY  (`ots`)
) TYPE=MyISAM;  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: checkout_process.php
Type: application/octet-stream
Size: 16566 bytes
Desc: not available
Url : http://lists.ziobudda.net/pipermail/php-it/attachments/20070612/58dbc3af/checkout_process-0001.obj
-------------- next part --------------
<?php
/*
  $Id: checkout_process.php,v 1.118 2003/01/14 00:10:34 hpdl Exp $

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/


  include('includes/application_top.php');
  include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

  if(isset($_GET['b'])){
  	$sql="select value from ots_sessions where ots='$_GET[b]'";
	$res=tep_db_query($sql);
	if(tep_db_num_rows($res)==1){
		$row=tep_db_fetch_array($res);
		$clone=unserialize($row['value']);
		$_SESSION=$clone;
		//print_r($_SESSION);
		unset($clone);
		//die(print_r($clone).'<br /><br />'.print_r($_SESSION));
	}
  }
 
// avoid hack attempts during the checkout procedure by checking the internal cartID
  if (isset($cart->cartID) && tep_session_is_registered('cartID')) 
	{
    if ($cart->cartID != $cartID) 
		{
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
  }

  
	//----------------------------------------------------------------------------------------------
	// Banca Sella response decode
	//
	$a=$HTTP_GET_VARS['a'];
	$b=$HTTP_GET_VARS['b'];
	$c=$HTTP_GET_VARS['c'];
	/*$b_exploded=explode("*P1*",$b);
	$b_params=array();
	foreach($b_exploded as $row)
	{
		$row_exploded=explode("=",$row);
		$key=$row_exploded[0];
		$val=$row_exploded[1];
   	$b_params[$key]=$val;
	}*/
	$b_params['PAY1_OTP']=$c;
	$b_params['PAY1_SHOPTRANSACTIONID']=$b;
	strcasecmp($a, 'KO')==0?$b_params['PAY1_TRANSACTIONRESULT']=$a:$b_params['PAY1_TRANSACTIONRESULT']='ok';
	//
	// load payment module
	//
  require(DIR_WS_MODULES . '/payment/gestpay_otp.php');
  $pm_gestpay = new gestpay_otp;
	//
	reset($b_params);
	if (strtolower($b_params['PAY1_TRANSACTIONRESULT']) == 'ok')
	{
		//
		// verificare congruenza otp ris
		// confronta ris nel db e se la trova la cancella, valida storico trxs e continua:
		//
		if ($pm_gestpay->validate_transaction($b_params['PAY1_OTP'],$b_params['PAY1_SHOPTRANSACTIONID']))
		{
		  tep_session_register('gp_otp_tn');
			$gp_otp_tn=$b_params['PAY1_SHOPTRANSACTIONID']; // it will be read by payment function after_process() soon...
			tep_redirect(tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'));
		}
		else
		{
			$pm_gestpay->check_otp("ris",$b_params['PAY1_OTP']);
			// if it enter here there is really something wrong...
			echo '
<SCRIPT language="javaScript">
alert("Procedura di pagamento annullata per problemi di comunicazione tra il server Banca Sella e il negozio.\nVerificare la connessione internet e riprovare.");
location.href="'.FILENAME_CHECKOUT_PAYMENT.'";
</SCRIPT>
			';
die();			
//			tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
		}
	}
	else
	{
		$pm_gestpay->check_otp("ris",$b_params['PAY1_OTP']);
		tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
	}
		
	//----------------------------------------------------------------------------------------------
	//
	//
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
<?php	
//--------------------------------------
function arrayDump($arr)
{
	reset($arr);
	while (list ($key, $val) = each ($arr)) 
	{
    echo "[$key] $val<br />\n";
	}
}
?>
-------------- next part --------------



More information about the Php-it mailing list