Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » Joomla »

Virtuemart TPV Banesto

Estas en el tema de Virtuemart TPV Banesto en el foro de Joomla en Foros del Web. Hola Estoy intentando integrar el pago por TPV de Banesto pero me da errores. He añadido un nuevo metodo de pago, en general he puesto ...
  #1 (permalink)  
Antiguo 27/03/2011, 12:52
 
Fecha de Ingreso: junio-2008
Mensajes: 42
Antigüedad: 15 años, 10 meses
Puntos: 0
Virtuemart TPV Banesto

Hola

Estoy intentando integrar el pago por TPV de Banesto pero me da errores.
He añadido un nuevo metodo de pago, en general he puesto HTML y en configuracion el archivo que me manda Banesto.
Banesto me da este codigo como ejemplo:
Código:
<HTML>
<HEAD>
  <TITLE>PhP Form Example</TITLE>
</HEAD>
<BODY>

<?PHP
// If form is submitted with all required data then show the form
// else show error page
empty($Formulario) ?							
	  ShowForm($coste,$moneda,$prod) :
	  ShowError();
exit;
?>

<?PHP


function ShowError () {
	echo "<html><head><title>Results</title></head><body><table width=100% height=50%><tr><td><p><h2><center>Compruebe que todos los datos del formulario son correctos!!</center></h2></p></td></tr></table></body></html>\n";
} # End of function ShowError

function ShowForm ($coste,$moneda,$producto) {
// Posted data
global $HTTP_POST_VARS;

// Valores constantes del comercio
$url_tpvv='http://pruebas.pagoseguro.com.es/cgi-bin/totalizacion';
$nombre_comercio='CIEMPOCHEF_PRUEBAS';
$referencia=date('ymdHis');
$coste='1.00';
$moneda='EUR';

// Now, print the HTML script
echo "<html><head><title>Comercio Simulador</title></head>
<script language=JavaScript>
function calc() { 
vent=window.open('','tpv','width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no');
document.forms[0].submit();}
</script>
<body bgcolor=white>
<form name=compra action=$url_tpvv method=post target=tpv>
<pre>
<table>
<tr><td>
<h2>Página de prueba.</h2>
</td></tr><tr><td>
Comercio: <font color=blue>$nombre_comercio</font>
</td></tr><tr><td>
Referencia: <font color=blue>$referencia</font>
</td></tr><tr><td>
Importe: <font color=blue>$coste</font>
</td></tr><tr><td>";



echo "</td>
</tr><tr><td>
<input type=hidden name=coste value='$coste'>
</td></tr><tr><td>
<input type=hidden name=moneda value='$moneda'>
</td></tr><tr><td>
<input type=hidden name=referencia  value='$referencia'>
</td></tr><tr><td>
<input type=hidden name=nombre_comercio value='$nombre_comercio'>
</td></tr><tr><td>
</td></tr>
</table>
<center><a href='javascript:calc()'><img src='/tpvirtual.jpg' border=0 ALT='TPV Virtual'></a></center>
</pre>
</form>										  
</body></html>";
} # End of function ShowForm
?>
Por un lado hay que modificar $coste ya que pone que se cobrara 1.00 euros en lugar del precio del procuto, por lo que ahi lo modifico por $db->f("order_total");
Al hacre esto, entonces me aparece el siguiente error:
Fatal error: Call to a member function f() on a non-object in /home/ciempoch/public_html/components/com_virtuemart/themes/default/templates/pages/checkout.thankyou.tpl.php(61) : eval()'d code on line 31

¿Que puede ser? me estoy volviendo locooooo

Última edición por vaughann; 27/03/2011 a las 12:53 Razón: completar informacion
  #2 (permalink)  
Antiguo 28/03/2011, 01:20
Avatar de LikanDevelopment  
Fecha de Ingreso: marzo-2011
Mensajes: 2
Antigüedad: 13 años
Puntos: 0
Respuesta: Virtuemart TPV Banesto

Disculpá, entendí mal la pregunta la primera vez.

Yo en ese archivo en mi plantilla veo que se trata de no alterar lo que tenga $db-f()

:

if ($db->f("order_status") == "P" ) {
// Copy the db object to prevent it gets altered
$db_temp = ps_DB::_clone( $db );
/** Start printing out HTML Form code (Payment Extra Info) **/ ?>

codigo
codigo
codigo

<?php
$db = $db_temp;
}

Última edición por LikanDevelopment; 28/03/2011 a las 01:30 Razón: Respuesta equivocada.
  #3 (permalink)  
Antiguo 31/03/2011, 13:36
 
Fecha de Ingreso: junio-2008
Mensajes: 42
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Virtuemart TPV Banesto

Cita:
Iniciado por LikanDevelopment Ver Mensaje
Disculpá, entendí mal la pregunta la primera vez.

Yo en ese archivo en mi plantilla veo que se trata de no alterar lo que tenga $db-f()

:

if ($db->f("order_status") == "P" ) {
// Copy the db object to prevent it gets altered
$db_temp = ps_DB::_clone( $db );
/** Start printing out HTML Form code (Payment Extra Info) **/ ?>

codigo
codigo
codigo

<?php
$db = $db_temp;
}
Perdona por tardar en contestar pero no he podido conectarme antes.
Lo primero muchas gracias por contestar.
Segun veo en el codigo que me pones, la funcion recoge los datos order_status (pedidos pendientes), y lo que necesito es que recoja el valor del importe a pagar ($coste en mi codigo) esa variable es la que tengo mal y no se que poner...
  #4 (permalink)  
Antiguo 15/04/2011, 08:02
 
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
  #5 (permalink)  
Antiguo 17/04/2011, 11:23
 
Fecha de Ingreso: junio-2008
Mensajes: 42
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Virtuemart TPV Banesto

he hecho una prueba real y el pago lo procesa por lo que el archivo de pago está correcto y solo falla al llamar la clase database en el fichero recibir_respuesta.php para darme el ok de la compra ¿que opciones hay?

Gracias un saludo
  #6 (permalink)  
Antiguo 13/06/2011, 09:59
 
Fecha de Ingreso: junio-2008
Mensajes: 42
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Virtuemart TPV Banesto

hola

Me sigue saliendo el 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 );

Alguien sabe como solucionarlo?
  #7 (permalink)  
Antiguo 18/07/2011, 05:00
 
Fecha de Ingreso: julio-2011
Mensajes: 4
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: Virtuemart TPV Banesto

Hola
Yo tengo el mismo problema con el recibir_respuesta.php, en la linea 81
Alguien ha encontrado la solución?
Saludos
  #8 (permalink)  
Antiguo 19/07/2011, 04:28
 
Fecha de Ingreso: junio-2008
Mensajes: 42
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Virtuemart TPV Banesto

Yo sigo sin encontrar la solución, he redirigido a la pagina principal pero eso no es una solución válida...
  #9 (permalink)  
Antiguo 21/07/2011, 05:25
 
Fecha de Ingreso: julio-2011
Mensajes: 4
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: Virtuemart TPV Banesto

Hola vaughann
Podrías compartirme tus archivos, en los que rediriges a la página principal?
Quizás puedo darme una idea yo también.
Gracias
  #10 (permalink)  
Antiguo 25/07/2011, 13:57
 
Fecha de Ingreso: junio-2008
Mensajes: 42
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Virtuemart TPV Banesto

claro que si pero esto es una autentica chapuza... ya que no te da el ok o el ko de la transacción, ni cambia el estado de BBDD del pedido... lo redirigí simplemente para ir haciendo pruebas y no tener que andar dependiendo de banesto.

Es una redireccion simple en PHP... me cree un fichero recibir_respuesta.php y renombre el que debería usar.
aqui esta el codigo
Código:
<?php
Header("Location: http://ciempochef.com/index.php?page=account.index&option=com_virtuemart&Itemid=6&vmcchk=1&Itemid=6"); 
?>

A ver si algun alma caritativa nos puede ayudar y podemos dejarlo bien al 100%...

Etiquetas: banesto, tpv, virtuemart
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:50.