Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/07/2005, 19:54
rbczgz
 
Fecha de Ingreso: noviembre-2003
Ubicación: Zaragoza, España
Mensajes: 1.257
Antigüedad: 22 años, 10 meses
Puntos: 154
Módulo de oscommerce para el pago por Ibercaja

Hola de nuevo!!

Estoy intentando "arreglar" un módulo para usar en Oscommerce el pago a través de Ibercaja, hasta ahora tengo esto, este es el archivo que va en /includes/modules/payment/:

Código PHP:
<?php 
class ibercaja { 
var 
$code, $title, $description, $enabled; 

// class constructor 
    
function ibercaja() { 
      
$this->code = 'ibercaja'; 
      
$this->title = MODULE_PAYMENT_IBERCAJA_TEXT_TITLE; 
      
$this->description = MODULE_PAYMENT_IBERCAJA_TEXT_DESCRIPTION; 
      
$this->sort_order = MODULE_PAYMENT_IBERCAJA_SORT_ORDER; 
      
$this->enabled = MODULE_PAYMENT_IBERCAJA_STATUS; 

    } 

// class methods 
    
function javascript_validation() { 
      return 
$validation_string; 
    } 

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

return 
$selection_string; 
    } 

function 
pre_confirmation_check() { 
      global 
$HTTP_POST_VARS; 
    } 

function 
confirmation() { 
      global 
$HTTP_POST_VARS, $CardName, $CardNumber; 

$confirmation_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n" . 
             
'<tr>' . "\n" . 
             
'<td class="main">&nbsp;Pago con Tarjeta &nbsp</td>' . "\n" . 
             
'  </tr>' . "\n" . 
             
'</table>' . "\n"; 

return 
$confirmation_string; 
    } 

function 
process_button() { 
      global 
$HTTP_POST_VARS,$order,$total_cost,$total_tax,$shi  pping_cost,$currency; 
      
//$coste_total=$total_cost+$total_tax+$shipping_cost  ; 
      
$coste_total=$order->info['total']; 
      
$process_button_string = tep_draw_hidden_field('moneda',$currency). 
tep_draw_hidden_field('coste_total',$coste_total).   
tep_draw_hidden_field('estado_venta','firma'); 
      return 
$process_button_string; 
    } 

function 
before_process() { 
        global 
$HTTP_POST_VARS,$HTTP_GET_VARS,$order,$total_cost,  $total_tax,$shipping_cost,$shipping_method,$curren  cy,$moneda,$coste_total,$refe_venta,$estado_venta;   

//aquí realizaremos la compra del tvp... a ver que pasa. 

            
if (ENABLE_SSL) { 
$prefijo='https://'; 
            }else{ 
$prefijo='http://'; 
} 


//aqui la direccion del comercio 

$dirlocal=$prefijo.'www.dominio.com'; 

//aqui la direccion web del tpv 

$dirtpv='https://tvp.ibercaja.es:443/servlet/TPVv'; 

//aqui va el codigo de comercio que el banco te asigna. 

$codcomercio='CODIGO_DE_COMERCIO'; 

//este dato tambien lo suministra el banco 

$refcomercio='CLAVE_COMERCIO'; 

//usuario y password, los asigna el banco. 

$usucomercio='USUARIO'; 
$passcomercio='CONTRASEÑA'; 

//fin variables tpv 

if ($estado_venta=='firma'){ 

$refe_venta=dechex(gmmktime()); //es importante enviar una referencia de venta 

//el coste, sin decimales, si lleva centimos los quitamos, por cien 

  
$coste_total=$coste_total*100; 

//codigo de moneda, euro 

  
$OB06='0978'; 

//numero de decimales 

  
$OB07='2'; 
   

//AHORA GENERAMOS LA DIRECCIÓN DE RETORNO CON LOS VALORES QUE PRECISAREMOS: 

$direccion_retorno=$dirlocal.'/checkout_process.php?'. 
   
'prod=' . $HTTP_POST_VARS['prod'] . '&' . 
   
'payment=' . $HTTP_POST_VARS['payment'] . '&' . 
   
'comments=' . $HTTP_POST_VARS['comments'] . '&' . 
   
'shipping_cost=' . $HTTP_POST_VARS['shipping_cost'] . '&' . 
   
'shipping_method=' . $HTTP_POST_VARS['shipping_method'] . '&'. 

//ESTOS SON VALORES PARA QUE LA CONEXIÓN CON TPVV FUNCIONE: 

   
'moneda='.$HTTP_POST_VARS['moneda'].'&'. 
   
'coste_total='.$coste_total.'&'. 
   
'refe_venta='.$refe_venta.'&'. 
   
'estado_venta=venta&'; 

// y ahora el formulario para la solicitud de la firma, que será este: 


$dir_tpv_firma = 'https://tvp.ibercaja.es:443/servlet/Firma2?'; 

echo 
'<form name="checkout_confirmation" method="get" action="'.$dir_tpv_firma.'">'."\n". 
   
'<input type="hidden" name="OB01" value="'.$codcomercio.'">'."\n" . 
   
'<input type="hidden" name="OB02" value="'.$usucomercio.'">'."\n" . 
   
'<input type="hidden" name="OB03" value="'.$passcomercio.'">'."\n" . 
   
'<input type="hidden" name="OB05" value="'.$coste_total.'">'."\n" . 
   
'<input type="hidden" name="OB06" value="'.$OB06.'">'."\n" . 
   
'<input type="hidden" name="OB07" value="'.$OB07.'">'."\n" . 
   
'<input type="hidden" name="OB08" value="'.$direccion_retorno.'">'."\n" . 
   
'<input type="hidden" name="OB09" value="'.$usucomercio.'">'."\n" . 
   
'<input type="hidden" name="OB10" value="'.$passcomercio.'">'."\n" . 
   
'</form>'."\n" . 
   
'<script languaje="JavaScript">document.checkout_confirmation.submit();</script>'; 


//este exit deberia detener la ejecucion de php 
   
exit; 

}else{ 
if (
$estado_venta=='venta'){ 
$firma=$HTTP_GET_VARS['?OB01']; 
$OB07='0978'; 
$OB08='2'; 



//AHORA GENERAMOS LA DIRECCIÓN DE RETORNO CON LOS VALORES QUE PRECISAREMOS: 

$direccion_retorno_ok=$dirlocal.'/checkout_process.php?'. 
   
'prod=' . $HTTP_GET_VARS['prod'] . '&' . 
   
'payment=' . $HTTP_GET_VARS['payment'] . '&' . 
   
'comments=' . $HTTP_GET_VARS['comments'] . '&' . 
   
'shipping_cost=' . $HTTP_GET_VARS['shipping_cost'] . '&' . 
   
'shipping_method=' . $HTTP_GET_VARS['shipping_method'] . '&'. 
   
'estado_venta=ok'; 

// esta es la dirección de retorno no Ok del Tpv 

$direccion_retorno_no_ok=$dirlocal.'/checkout_payment.php?error_message=Se+ha+producido  +un+error+en+el+pago.'; 


// y ahora el formulario para la solicitud de la compra, que será este: 

$dir_tpv_firma = 'https://tvp.ibercaja.es:443/servlet/Firma2?'; 
echo 
'<form name="checkout_confirmation" method="POST" action="'.$dir_tpv_firma.'">'."\n". 
   
'<input type="hidden" name="OB01" value="'.$codcomercio.'">'."\n" . 
   
'<input type="hidden" name="OB02" value="'.$direccion_retorno_ok.'">'."\n" . 
   
'<input type="hidden" name="OB03" value="'.$direccion_retorno_no_ok.'">'."\n" . 
   
'<input type="hidden" name="OB04" value="'.$firma.'">'."\n" . 
   
'<input type="hidden" name="OB05" value="'.$refe_venta.'">'."\n" . 
   
'<input type="hidden" name="OB06" value="'.$coste_total.'">'."\n" . 
   
'<input type="hidden" name="OB07" value="'.$OB07.'">'."\n" . 
   
'<input type="hidden" name="OB08" value="'.$OB08.'">'."\n" . 
   
'<input type="hidden" name="OB12" value="0">'."\n" . 
   
'<input type="hidden" name="OB15" value="'.$refcomercio.'">'."\n" . 
   
'</form>'."\n" . 
   
'<script languaje=JavaScript>document.checkout_confirmation.submit()</script>'; 

   exit; 

}ELSE{if (
$estado_venta=='ok'){ 

//AHORA GENERAMOS LA DIRECCIÓN ultima QUE PRECISAREMOS: 

$direccion_final=$dirlocal.'/checkout_process.php?osCsid='.$osCsid; 

// y ahora el formulario para que se genere el pedido: 

echo '<form name="checkout_confirmation" method="POST" action="'.$direccion_final.'">'."\n". 
   
'<input type="hidden" name="prod" value="' . $HTTP_GET_VARS['prod'] . '">' ."\n" . 
   
'<input type="hidden" name="payment" value="' . $HTTP_GET_VARS['payment'] . '">' ."\n" . 
   
'<input type="hidden" name="comments" value="' . $HTTP_GET_VARS['comments'] . '">' ."\n" . 
   
'<input type="hidden" name="shipping_cost" value="' . $HTTP_GET_VARS['shipping_cost'] . '">' ."\n" . 
   
'<input type="hidden" name="shipping_method" value="' . $HTTP_GET_VARS['shipping_method'] . '">'."\n" . 
   
'<input type="hidden" name="estado_venta" value ="fin">'."\n" . 
   
'</form>'."\n" . 
   
' <script languaje=JavaScript>document.checkout_confirmation.submit()</script>'; 
    
exit; 

}else{if (
$estado_venta="fin"){}; 

}; 
}; 
}; 
} 

function 
after_process() { 
      global 
$insert_id; 
    } 

function 
output_error() { 
      global 
$HTTP_GET_VARS; 

$output_error_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n" . 
             
'<tr>' . "\n" . 
             
'<td class="main">&nbsp;<font color="#FF0000"><b>' . MODULE_PAYMENT_IBERCAJA_TEXT_ERROR . 
'</b></font><br>&nbsp;' . stripslashes(urldecode($HTTP_GET_VARS['ibercaja_val'])) . '&nbsp;</td>' . "\n" . 
             
' </tr>' . "\n" . 
             
'</table>' . "\n"; 

return 
$output_error_string; 
} 

function 
check() { 
      
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 
'MODULE_PAYMENT_IBERCAJA_STATUS'"
); 
      
$check = tep_db_num_rows($check_query); 

return 
$check; 
    } 

function 
install() { 
      
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Pago a traves Ibercaja','MODULE_PAYMENT_IBERCAJA_STATUS', '1', '¿Aceptas el pago a través de el Tpv Ibercaja?', '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 ('Preferencia ordinal al mostrar.', 'MODULE_PAYMENT_IBERCAJA_SORT_ORDER', '0', 'Preferencia ordinal en la lista de formas de pago. Un número menor indica mayor preferencia. ', '6', '0' , now())"); 
} 

function 
remove() { 
      
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_IBERCAJA_STATUS'"); 
      
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_IBERCAJA_SORT_ORDER'"); 
} 

     
function 
keys() { 
      return array(
'MODULE_PAYMENT_IBERCAJA_STATUS', 'MODULE_PAYMENT_IBERCAJA_SORT_ORDER'); 

return 
$keys; 
} 
} 
?>
El problema está en que cuando pasa la firma, devuelve un archivo en lugar de validarla y ahí es cuando ya me he perdido. El archivo lleva el nombre de las variable y valores pasados por GET y el contenido, según parece, es la firma que debería comprobar (creo)

Lo he puesto en otro foro pero no se si es mejor aquí...

Agradecería cualquier ayuda