Hola a todos, necesito vuestra ayuda, tengo un problema con la implementación de la tpv de La Caixa, me sale error de datos no enviado y no sé porqué? He comprobado los valores que le paso y es como si no reconociera el código java, os pongo el código que tengo que no me tira, a ver si me podéis echar un cable...... Muchas gracias de antemano!!!
<%@ page import="java.security.*"%>
<%
final int SHA1_DIGEST_LENGTH = 20;
java.text.SimpleDateFormat formador = new java.text.SimpleDateFormat("yyMMddHHmmss");
String Merchant_Name = "Simulador de Comercio";
String Merchant_Code = "999008881";
int Merchant_Terminal = 4;
String Merchant_Order = formador.format(new java.util.Date());
String Merchant_Password = "qwertyasdf0123456789";
String Merchant_Amount = "100";
String Merchant_Currency = "978";
String Merchant_TransactionType = "0";
String Merchant_MerchantURL = "url";
byte bAmount[] = new byte[Merchant_Amount.length()];
byte bOrder[] = new byte[Merchant_Order.length()];
byte bCode[] = new byte[Merchant_Code.length()];
byte bCurrency[] = new byte[Merchant_Currency.length()];
byte bTransactionType[] = new byte[Merchant_TransactionType.length()];
byte bMerchantURL[] = new byte[Merchant_MerchantURL.length()];
byte bPassword[] = new byte[Merchant_Password.length()];
bAmount = Merchant_Amount.getBytes();
bOrder = Merchant_Order.getBytes();
bCode = Merchant_Code.getBytes();
bCurrency = Merchant_Currency.getBytes();
bTransactionType = Merchant_TransactionType.getBytes();
bMerchantURL = Merchant_MerchantURL.getBytes();
bPassword = Merchant_Password.getBytes();
MessageDigest sha = MessageDigest.getInstance("SHA-1");
sha.update(bAmount);
sha.update(bOrder);
sha.update(bCode);
sha.update(bCurrency);
sha.update(bTransactionType);
sha.update(bMerchantURL);
byte[] hash = sha.digest(bPassword);
String Merchant_Signature = new String();
int h = 0;
String s = new String();
for(int i = 0; i < SHA1_DIGEST_LENGTH; i++)
{
h = (int) hash
; // Convertir de byte a int
if(h < 0) h += 256; // Si son valores negativos, pueden haber problemas de conversi¢n.
s = Integer.toHexString(h); // Devuelve el valor hexadecimal como un String
if (s.length() < 2) Merchant_Signature = Merchant_Signature.concat("0"); // A¤ade un 0 si es necesario
Merchant_Signature = Merchant_Signature.concat(s); // A¤ade la conversi¢n a la cadena ya existente
}
Merchant_Signature = Merchant_Signature.toUpperCase(); // Convierte la cadena generada a Mayusculas.
%>
<HTML>
<HEAD>
<TITLE>Simulador Comercio</TITLE>
</HEAD>
<script LANGUAGE="JavaScript" >
function calc()
{
vent=window.open("","tpv","width=480,height=475,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no");
document.forms[0].submit();
}
</SCRIPT>
<BODY BGCOLOR="WHITE">
<H1> Gestor de Compras</H1>
<form name=compra action='https://sis-t.sermepa.es:25443/sis/realizarPago' method="POST" target="tpv">
<table>
<tr>
<td>
Comercio: <INPUT TYPE=HIDDEN name=Ds_Merchant_MerchantName value="<%=Merchant_Name%>"><font color="blue"><%=Merchant_Name%></font>
</td>
</tr>
<tr>
<td>
FUC: <INPUT TYPE=HIDDEN name=Ds_Merchant_MerchantCode value="<%=Merchant_Code%>"><font color="blue"><%=Merchant_Code%></font>
</td>
</tr>
<tr>
<td>
Terminal: <INPUT TYPE=HIDDEN name=Ds_Merchant_Terminal value="<%=Merchant_Terminal%>"><font color="blue"><%=Merchant_Terminal %></font>
</td>
</tr>
<tr>
<td>
N§ Pedido: <INPUT TYPE=HIDDEN name=Ds_Merchant_Order value="<%=Merchant_Order%>"><font color="blue"><%=Merchant_Order %></font>
</td>
</tr>
<td>
Producto: <font color="blue">Producto</font>
</td>
</tr>
<tr>
<td>
Importe: <INPUT TYPE=HIDDEN name=Ds_Merchant_Amount value="1000"><font color="blue">1000</font>
</td>
</tr>
<tr>
<td>
Moneda: <INPUT TYPE=HIDDEN name=Ds_Merchant_Currency value="<%=Merchant_Currency%>"><font color="blue"><%=Merchant_Currency%></font>
</td>
</tr>
<tr>
<td>
Tipo de operacion: <INPUT TYPE=HIDDEN name=Ds_Merchant_TransactionType value="<%=Merchant_TransactionType%>"><font color="blue"><%=Merchant_TransactionType%></font>
</td>
</tr>
<tr>
<td>
URL del comercio: <INPUT TYPE=HIDDEN name=Ds_Merchant_MerchantURL value="<%=Merchant_MerchantURL%>"><font color="blue"><%=Merchant_MerchantURL%></font>
</td>
</tr>
<tr>
<td>
<%-- Comentarios - Firma: <INPUT TYPE=HIDDEN name=Ds_Merchant_MerchantSignature value="<%=Merchant_Signature%>"><font color="blue"><%=Merchant_Signature%></font> --%>
<INPUT TYPE=HIDDEN name=Ds_Merchant_MerchantSignature value="<%=Merchant_Signature%>">
</td>
</tr>
</td>
<tr>
<td>
</td>
</tr>
</table>
<center><a href="javascript:calc()"><img src='tpvirtual.jpg' border=0 ALT="TPV Virtual"></a></center>
</form>
</BODY></HTML>