Ver Mensaje Individual
  #4 (permalink)  
Antiguo 15/04/2011, 08:02
vaughann
 
Fecha de Ingreso: junio-2008
Mensajes: 42
Antigüedad: 15 años, 10 meses
Puntos: 0
Pregunta Respuesta: Virtuemart TPV Banesto

Hola de nuevo pues conseguí hacerlo funcionar en parte, he llegado al punto para introducir datos de la tarjeta en la web del tpv de banesto, pago correctamente, me aparece en ingreso pero a devolverme a mi web con el resultado ok me aparece este error:
Fatal error: Class 'database' not found in /home/ciempoch/public_html/administrator/components/com_virtuemart/recibir_respuesta.php on line 81 (para que os sea más sencillo la linea 81 dice: $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix );) esta url es la que proporcioné a banesto para la respuesta y por supuesto el archivo recibir_respuesta.php esta en su sitio...

El archivo recibir respuesta al que redirijo es este:
Código:
<?php 
/**
* BANESTO POR Luis Fernandez
*basado en notify.php del core de virtuemart y algunas pasarelas ya desarrolladas y
* compartidas en el foro joomlaspanish
*/
	
    $respuesta = (!empty($_POST) ? $_POST : $_GET);
    define('_VALID_MOS', '1');
    header("HTTP/1.0 200 OK");
    header('Content-type: text/html; charset=utf-8');
    define('_VALID_MOS', '1');
    global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_lang, $database,
    $mosConfig_mailfrom, $mosConfig_fromname;
    
    /*** access Joomla's configuration file ***/
        $my_path = dirname(__FILE__);
        
        if( file_exists($my_path."/../../../configuration.php")) {
            require_once($my_path."/../../../configuration.php");
        }
        elseif( file_exists($my_path."/../../configuration.php")){
            require_once($my_path."/../../configuration.php");
        }
        elseif( file_exists($my_path."/configuration.php")){
            require_once( $my_path."/configuration.php" );
        }
        else
            die( "Joomla Configuration File not found!" );
/***  ***/
        if( file_exists($my_path."/../../../configuration.php")) {
            $absolute_path = dirname( $my_path."/../../../configuration.php" );
            require_once($my_path."/../../../configuration.php");
        } elseif( file_exists($my_path."/../../configuration.php")){
            $absolute_path = dirname( $my_path."/../../configuration.php" );
            require_once($my_path."/../../configuration.php");
        } elseif( file_exists($my_path."/configuration.php")){
            $absolute_path = dirname( $my_path."/configuration.php" );
            require_once( $my_path."/configuration.php" );
        } else {
            die( "Joomla Configuration File not found!" );
        }
        $absolute_path = realpath( $absolute_path );
/***  ***/
        // Set up the appropriate CMS framework
        if (class_exists('JConfig')) {
        	
        	// Joomla 1.5
			define( '_JEXEC', 1 );
			define( 'JPATH_BASE', $absolute_path );
			define( 'DS', DIRECTORY_SEPARATOR );
			// Load the framework
			require_once ( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
			require_once ( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
			// create the mainframe object
			$mainframe = & JFactory::getApplication( 'site' );
			// Initialize the framework
			$mainframe->initialise();
			// load system plugin group
			jimport('joomla.plugin.helper');
			JPluginHelper::importPlugin( 'system' );
			// Set language
			$lang =& JFactory::getLanguage();
			$mosConfig_lang = $GLOBALS['mosConfig_lang'] = strtolower( $lang->getBackwardLang() );
			// Adjust the live site path
			$mosConfig_live_site = str_replace('/administrator/components/com_virtuemart', '', JURI::base());
			$mosConfig_absolute_path = JPATH_BASE;
			// Adjust other values
			$config =& JFactory::getConfig();
			$mosConfig_mailfrom = $config->mailfrom;
			$mosConfig_fromname = $config->fromname;
			
        } else {
        	
        	// Joomla 1.0
	        require_once($mosConfig_absolute_path. '/includes/joomla.php');
	        require_once($mosConfig_absolute_path. '/includes/database.php');
	        
        }
/***  ***/
        $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix );
        
        // load Joomla Language File
        if (file_exists( $mosConfig_absolute_path. '/language/'.$mosConfig_lang.'.php' )) {
            require_once( $mosConfig_absolute_path. '/language/'.$mosConfig_lang.'.php' );
        } elseif (file_exists( $mosConfig_absolute_path. '/language/english.php' )) {
            require_once( $mosConfig_absolute_path. '/language/english.php' );
        }


    /*** END of Joomla config ***/
   
    
    /*** VirtueMart part ***/ 
        require_once($mosConfig_absolute_path.'/administrator/components/com_virtuemart/virtuemart.cfg.php');
        include_once( ADMINPATH.'/compat.joomla1.5.php' );
        require_once( ADMINPATH. 'global.php' );
        require_once( CLASSPATH. 'ps_main.php' );
        $vmLogIdentifier = "retornotpv.php";
        require_once(CLASSPATH."Log/LogInit.php");
        
		require_once( CLASSPATH. "language.class.php" );
		require_once(CLASSPATH."Log/Log.php");
		$vmLoggerConf = array(
			'buffering' => true
			);
		/**
		 * This Log Object will help us log messages and errors
		 * See http://pear.php.net/package/Log
		 * @global Log vmLogger
		 */
		$vmLogger = &vmLog::singleton('display', '', '', $vmLoggerConf, PEAR_LOG_TIP);
		$GLOBALS['vmLogger'] =& $vmLogger;
		
        require_once( $mosConfig_absolute_path.'/includes/phpmailer/class.phpmailer.php');
        $mail = new PHPMailer();
        $mail->PluginDir = $mosConfig_absolute_path.'/includes/phpmailer/';
        $mail->SetLanguage("en", $mosConfig_absolute_path.'/includes/phpmailer/language/');

	// Load language file.
	require_once( CLASSPATH. 'language.class.php' );
	if (file_exists( ADMINPATH. 'languages/'.$mosConfig_lang.'.php' ))
		require_once( ADMINPATH. 'languages/'.$mosConfig_lang.'.php' );
	else if (file_exists( ADMINPATH. 'languages/english.php' ))
		require_once( ADMINPATH. 'languages/english.php' );
              
        
    /* Load the VirtueMart database class */
        require_once( CLASSPATH. 'ps_database.php' );
        
		$debug_email_address = $mosConfig_mailfrom;
                        
    /*** END VirtueMart part ***/
    
    //1. Finished Initialization of the retornotpv.php script" 

    /**
    * Read post from BANESTO system and update order status
    **/
    $i = 1;

    $respuesta = (!empty($_POST) ? $_POST : $_GET);
    $comercio = trim(stripslashes($respuesta['comercio'])); 
    $resultado = trim(stripslashes($respuesta['RESULTADO']));
    $referencia = trim(stripslashes($respuesta['referencia']));
    $pedido = substr($referencia,0,stripos($referencia,'-'));
    $importe = trim(stripslashes($respuesta['IMPORTE']));
    $fecha = trim(stripslashes($respuesta['fecha']));
    
      // Get the Order Details from the database      
      $qv = "SELECT `order_id`, `order_number`, `user_id`, `order_subtotal`,
                    `order_total`, `order_currency`, `order_tax`, 
                    `order_shipping_tax`, `coupon_discount`, `order_discount`
                FROM `#__{vm}_orders` 
                WHERE `order_id`='".intval($pedido)."'";
      $db = new ps_DB;
      $db->query($qv);
      $db->next_record();
      $order_id = $db->f("order_id");
     
      $d['order_id'] = $pedido;
      $d['notify_customer'] = "Y";
	  
		if ($resultado == 'OK') {
				 
			// UPDATE THE ORDER STATUS to 'Completed'
				$d['order_status'] = "C";                    
			require_once ( CLASSPATH . 'ps_order.php' );
			$ps_order= new ps_order;
			$ps_order->order_status_update($d);
			$mail->From = $mosConfig_mailfrom;
			$mail->FromName = $mosConfig_fromname;
			$mail->AddAddress($debug_email_address);
			$mail->Subject = "BANESTO, TPV-virtual";
			$mail->Body = "Hola,\n\n";
			$mail->Body .= "Una transacción a través de TPV-virtual BANESTO ha sido realizada!\n";
			$mail->Body .= "------------------------------------------------------------------\n";
			$mail->Body .= "N. Pedido: $pedido\n";
			$mail->Body .= "El estado del pago recibido por BANESTO es: $Ds_Response\n";
			$mail->Body .= "Descripción: ".$d['order_status'];
			$mail->Send();
		}
		else {
				$mail->From = $mosConfig_mailfrom;
				$mail->FromName = $mosConfig_fromname;
				$mail->AddAddress($debug_email_address);
				$mail->Subject = "Transacción BANESTO en su web";
				$mail->Body = "Hola,
				Ocurrió un error mientras se realizaba una transacción en BANESTO.
				------------------------------------------------------------------
					N. Pedido: $pedido\n
					Estado:$resultado";
				$mail->Send();
		};
     
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=http://www.ciempochef.com/index.php?page=account.order_details&order_id=".$pedido."&option=com_virtuemart&Itemid=6\">";
?>

Alguien ve algo raro para que me devuelva ese error?

El codigo de pago inicial es este (aunque eso parece funcionar)
Código:
<?php

// Valores segun el comercio 
$url_tpvv="";// URL del TPV.
$comercio="MI_NEGOCIO";                                            // Codigo de comercio proporcionado.


$order = $db->f("order_id"); 
$postorder = "-".rand(0,99)."-"; //Para evitar el problema con referencias duplicadas
$importe=$db->f("order_total");
$importe_formatado=$importe*100;

// Montar "petición" en XML

 $xml.="nombre_comercio=".$comercio."&";
 $xml.="referencia=".$order."&";
 $xml.="coste=".$importe;

$peticion=$xml;

?>

<!-- Enviar "petición" al TPVV --> 

<form action="<?php echo $url_tpvv ?>" method="post">
<input type="image" src="/images/pagoseguro.gif" name="submit" alt="Pagar con tarjeta" />
<input type="submit" value="Pagar" />
<input type="hidden" name="nombre_comercio" value="<?php echo $comercio ?>"/>
<input type="hidden" name="referencia" value="<?php echo $order.$postorder ?>"/>
<input type="hidden" name="coste" value="<?php echo number_format($importe,2,'.','') ?>"/>
</form>

Última edición por vaughann; 15/04/2011 a las 08:23