Aw: Error when they make a paid order
This is the plugin where it gives the "signature" error:
<?php
defined('_JEXEC') or die('Restricted access');
include_once 'redsysapi.php';
class pm_redsys extends PaymentRoot{
function showPaymentForm($params, $pmconfigs){
include(dirname(__FILE__)."/paymentform.php");
}
//function call in admin
function showAdminFormParams($params){
$array_params = array('testmode', 'transaction_end_status', 'transaction_pending_status', 'transaction_failed_status');
foreach ($array_params as $key){
if (!isset($params[$key])) $params[$key] = '';
}
$jv = new JVersion();
$orders = JModelLegacy::getInstance('orders', 'JshoppingModel'); //admin model
include(dirname(__FILE__)."/adminparamsform.php");
}
function checkTransaction($pmconfigs, $order, $act){
$miObj = new RedsysAPI;
$version = $_POST["Ds_SignatureVersion"];
$datos = $_POST["Ds_MerchantParameters"];
$signatureRecibida = $_POST["Ds_Signature"];
$decodec = $miObj->decodeMerchantParameters($datos);
//$key = 'sq7HjrUOBfKmC576ILgskD5srU870gJ7'; //test
$clave = $pmconfigs['clave'];
$key = $clave;
$firma = $miObj->createMerchantSignatureNotif($key, $datos);
\JSHelper::saveToLog("paymentdata.log", print_r($decodec, 1));
if ($firma === $signatureRecibida) {
$autorizada = false;
$Ds_Response = $miObj->getParameter("Ds_Response");
\JSHelper::saveToLog("paymentdata.log", 'ds_response='.$Ds_Response);
if ($Ds_Response >= '0000' && $Ds_Response <= '0099'){
$autorizada = true;
}
elseif($Ds_Response == '0900' || $Ds_Response == '0930') {
$autorizada = true;
}
$pedido = $miObj->getParameter("Ds_Order");//order_number;
if ($autorizada) {
return array(1, '');
} else {
return array(3, "autorizada false. Order ID " . $order->order_id);
}
} else {
\JSHelper::saveToLog("paymentdata.log", 'firma='.$firma);
return array(0, 'Invalid firma. Order ID ' . $order->order_id);
}
}
function showEndForm($pmconfigs, $order){
if ( $pmconfigs['testmode'] ) {
$url_tpvv='https://sis-t.redsys.es:25443/sis/realizarPago'; //test
} else {
$url_tpvv='https://sis.redsys.es/sis/realizarPago'; //real
}
// Valores constantes del comercio
$clave=$pmconfigs['clave'];
$name=$pmconfigs['fiscal'];
$code=$pmconfigs['codigo'];
$terminal=$pmconfigs['terminal'];
$currency=978; //euro
$transactionType='0';
$order = (array) $order;
$amount = $order['order_total'] * 100;
$ordernum = $order['order_number'];// . date('ymdHis');
$notify_url = JURI::root() . "index.php?option=com_jshopping&controller=checkout&task=step7&act=notify&js_paymentclass=pm_redsys&no_lang=1&oid=".$order['order_id'];
$return = JURI::root(). "index.php?option=com_jshopping&controller=checkout&task=step7&act=return&js_paymentclass=pm_redsys&oid=".$order['order_id'];
$cancel_return = JURI::root() . "index.php?option=com_jshopping&controller=checkout&task=step7&act=cancel&js_paymentclass=pm_redsys";
$urlMerchant=$notify_url;//callback
$urlMerchantOK=$return;
$urlMerchantKO=$cancel_return;
$miObj = new RedsysAPI;
// Valores de entrada
$merchantCode = $code;
$terminal = $terminal;
$amount = $amount;
$currency = "978";
$transactionType = "0";
$merchantURL = $notify_url;
$urlOK = $return;
$urlKO = $cancel_return;
$order = $ordernum;
// Se Rellenan los campos
$miObj->setParameter("DS_MERCHANT_AMOUNT",(string)$amount);
$miObj->setParameter("DS_MERCHANT_ORDER",strval($order));
$miObj->setParameter("DS_MERCHANT_MERCHANTCODE",$merchantCode);
$miObj->setParameter("DS_MERCHANT_CURRENCY",$currency);
$miObj->setParameter("DS_MERCHANT_TRANSACTIONTYPE",$transactionType);
$miObj->setParameter("DS_MERCHANT_TERMINAL",$terminal);
$miObj->setParameter("DS_MERCHANT_MERCHANTURL",$merchantURL);
$miObj->setParameter("DS_MERCHANT_URLOK",$urlOK);
$miObj->setParameter("DS_MERCHANT_URLKO",$urlKO);
//Datos de configuraci�n
$version="HMAC_SHA256_V1";
//$key = 'sq7HjrUOBfKmC576ILgskD5srU870gJ7';//Clave secreta del terminal modo test!
$key=$clave;
//$key = 'Hw0IRwc1VzvAIzKGfPejSSnn6Hhit8da';
// Se generan los par�metros de la petici�n
$request = "";
$params = $miObj->createMerchantParameters();
$signature = $miObj->createMerchantSignature($key);
$urlPago = $url_tpvv;
//print_r($miObj);exit;
?>
<html lang="es">
<head>
</head>
<body>
<form name="compra" action=" <?php echo $urlPago ?>" method="POST">
<input type="hidden" name="Ds_SignatureVersion" value="<?php echo $version; ?>"/></br>
<input type="hidden" name="Ds_MerchantParameters" value="<?php echo $params; ?>"/></br>
<input type="hidden" name="Ds_Signature" value="<?php echo $signature; ?>" /></br>
<script>document.compra.submit();</script>
<!-- <input type="submit" />-->
</form>
</body>
</html>
<?php
}
function getUrlParams($pmconfigs) {
$params = array();
$params['order_id'] = \JFactory::getApplication()->input->getInt("oid");
$params['hash'] = '';
$params['checkHash'] = 0;
$params['checkReturnParams'] = 1;
return $params;
}
}