<?php
$ApiKey = "6u39nqhq8ftd0hlvnjfs66eh8c";
$merchant_id = $_REQUEST['merchantId'];
$referenceCode = $_REQUEST['referenceCode'];
$TX_VALUE = $_REQUEST['TX_VALUE'];
$New_value = number_format($TX_VALUE, 1, '.', '');
$currency = $_REQUEST['currency'];
$transactionState = $_REQUEST['transactionState'];
$firma_cadena = "$ApiKey~$merchant_id~$referenceCode~$New_value~$currency~$transactionState";
$firmacreada = md5($firma_cadena);
$firma = $_REQUEST['signature'];
$reference_pol = $_REQUEST['reference_pol'];
$cus = $_REQUEST['cus'];
$extra1 = $_REQUEST['description'];
$pseBank = $_REQUEST['pseBank'];
$lapPaymentMethod = $_REQUEST['lapPaymentMethod'];
$transactionId = $_REQUEST['transactionId'];
if ($_REQUEST['transactionState'] == 4 ) {
$estadoTx = "Transacción aprobada";
}
else if ($_REQUEST['transactionState'] == 6 ) {
$estadoTx = "Transacción rechazada";
}
else if ($_REQUEST['transactionState'] == 104 ) {
$estadoTx = "Error";
}
else if ($_REQUEST['transactionState'] == 7 ) {
$estadoTx = "Transacción pendiente";
}
else {
$estadoTx=$_REQUEST['mensaje'];
}
if (strtoupper($firma) == strtoupper($firmacreada)) {
?>
<h2>Resumen Transacción</h2>
<table>
<tr>
<td>Estado de la transaccion</td>
<td><?php echo $estadoTx; ?></td>
</tr>
<tr>
<tr>
<td>ID de la transaccion</td>
<td><?php echo $transactionId; ?></td>
</tr>
<tr>
<td>Referencia de la venta</td>
<td><?php echo $reference_pol; ?></td>
</tr>
<tr>
<td>Referencia de la transaccion</td>
<td><?php echo $referenceCode; ?></td>
</tr>
<tr>
<?php
if($pseBank != null) {
?>
<tr>
<td>cus </td>
<td><?php echo $cus; ?> </td>
</tr>
<tr>
<td>Banco </td>
<td><?php echo $pseBank; ?> </td>
</tr>
<?php
}
?>
<tr>
<td>Valor total</td>
<td>$<?php echo number_format($TX_VALUE); ?></td>
</tr>
<tr>
<td>Moneda</td>
<td><?php echo $currency; ?></td>
</tr>
<tr>
<td>Descripción</td>
<td><?php echo ($extra1); ?></td>
</tr>
<tr>
<td>Entidad:</td>
<td><?php echo ($lapPaymentMethod); ?></td>
</tr>
</table>
<?php
}
else
{
?>
<h1>Error validando firma digital.</h1>
<?php
}
?>
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$state_pol = $_POST["state_pol"];
$response_code_pol = $_POST["response_code_pol"];
$risk = $_POST["risk"];
$reference_sale = $_POST["reference_sale"];
$payment_method_type = $_POST["payment_method_type"];
$value = $_POST["value"];
$currency = $_POST["currency"];
$test = $_POST["test"];
$ip = $_POST["ip"];
$nickname_buyer = $_POST["nickname_buyer"];
$description = $_POST["description"];
$content = "Informacion de confirmacion".PHP_EOL;
$content .= "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-".PHP_EOL;
$content .= "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-".PHP_EOL;
$content .= "Estado de la transaccion: ".$state_pol.PHP_EOL;
$content .= "Codigo de respuesta de PayU: ".$response_code_pol.PHP_EOL;
$content .= "Riesgo de la transaccion: ".$risk.PHP_EOL;
$content .= "Referencia de la venta: ".$reference_sale.PHP_EOL;
$content .= "Tipo de medio de pago: ".$payment_method_type.PHP_EOL;
$content .= "Valor de la compra: ".$value.PHP_EOL;
$content .= "Moneda de la transaccion: ".$currency.PHP_EOL;
$content .= "IP del comprador: ".$ip.PHP_EOL;
$content .= "Nombre corto del comprador: ".$nickname_buyer.PHP_EOL;
$content .= "Descripcion de la compra: ".$description.PHP_EOL;
$content .= "¿Estamos haciendo pruebas? ".$test.PHP_EOL;
}
?>