Jump to content

Notification.php (update data in MySQL and send email to user) after RedSys PAYMENT GATEWAY is not working HELP!


Recommended Posts

Hello.
I have a form for users to make reservations and they have to pay for that.

I activate the Payment Gateway Platform (by Redsys in Spain), and it works fine asking you for card number and it goes through correctly and says PAYMENT OK, but the notification.PHP FILE does not work.

Could my server (SSL) configuration be the problem? or is it the CODE?

Any help about this, please, would be highly appreciated.

Thank you.

Part of the Nofication.php code is:

__________________________________________________________________________________

<?php
  @ini_set("display_errors","1");
  @ini_set("display_startup_errors","1");

  $handle = fopen("_redsys.log", "a");

  require_once("include/dbcommon.php");
  require_once("redsysHMAC256_API_PHP_4.0.2/apiRedsys.php"); 

  $miObj = new RedsysAPI; 

  $version = postvalue("Ds_SignatureVersion"); 
  $params = postvalue("Ds_MerchantParameters"); 
  $signatureRecibida = postvalue("Ds_Signature");

//  $version = "HMAC_SHA256_V1"; 
//  $params = "eyJEc19BbW91bnQiOiIyMDAiLCJEc19DdXJyZW5jeSI6Ijk3OCIsIkRzX09yZGVyIjoiMjAwNjE4MDkyNDMzIiwiRHNfTWVyY2hhbnRDb2RlIjoiOTk5MDA4ODgxIiwiRHNfVGVybWluYWwiOiIxIiwiRHNfUmVzcG9uc2UiOiI5OTk4IiwiRHNfQXV0aG9yaXNhdGlvbkNvZGUiOiIiLCJEc19UcmFuc2FjdGlvblR5cGUiOiIwIiwiRHNfU2VjdXJlUGF5bWVudCI6IjAiLCJEc19MYW5ndWFnZSI6IjEiLCJEc19NZXJjaGFudERhdGEiOiIifQ=="; 
//  $signatureRecibida = "Aa6GG9IfCYlRrj-yF5VxXg_qmhJ3R-fmfXxGvB8w2Sk="; 
  
  $txt = "version=".$version."\nparams=".$params."\nsignatureRecibida=".$signatureRecibida."\n";
  fwrite($handle,"\n\n\n".date("Y-m-d h:i:s")."\n");
  fwrite($handle,$txt);


  $decodec = $miObj->decodeMerchantParameters($params); 
  $codigoRespuesta = $miObj->getParameter("Ds_Response"); 

  $claveModuloAdmin = 'sq7HjrUOBfKmC576ILgskD5srU870gJ7'; 
  $signatureCalculada = $miObj->createMerchantSignatureNotif($claveModuloAdmin, $params); 
  $res = my_json_decode($decodec);
  fwrite($handle,$decodec."\n");
  

  if ($signatureCalculada === $signatureRecibida && $res["Ds_AuthorisationCode"]!="++++++" && !isset($res["Ds_ErrorCode"]) { 
  
    fwrite($handle,"Ds_Order = ".$res["Ds_Order"]."\n");
    DB::Query("update reservas set status=1 where Ds_Order='".$res["Ds_Order"]."'");
    $rs2 = DB::Query("select * from reservas where Ds_Order='".$res["Ds_Order"]."'");
    $values = $rs2->fetchAssoc();
    $email=$values['Email'];
    $msg="";
    $msg.= "El seu codi de reserva és: ". dechex(999999999-$values['Id_Reserva'])."<br>";
    $msg.= "Código sin cifrar: ". 999999999-$values['Id_Reserva']."<br>";
    $msg.= "Reserva descifrada ". (((hexdec(dechex(999999999-$values['Id_Reserva'])))-999999999)*-1)."<br>";
    $msg.= "La data de la seva reserva es : ".$values['Dia']."-".$values['Mes']."-".$values['Año']."<br>";

    $sql = "SELECT Espacio FROM Espacios WHERE Id_Espacio=" . $values["Id_Espacio"];
    $rs = CustomQuery($sql);
    $data = db_fetch_array($rs);
    //$result["txt"] = "Ãrea: " . $data["c"];
    //$msg.= "QR : " .$values['QR']."\r\n";         //json_decode($image, true);
    //<img src="http://www.htmldog.com/badge1.gif">          https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=12345678
    //$image2= '<img src="data:image/jpeg;base64,'.$values['QR'].'>';
    $msg.= '<img src="https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http%3A%2F%2Fwww.sungest.net/reservas_list.php?qs='.dechex(999999999-$values['Id_Reserva']).'&f=all%2F&choe=UTF-8">';
    //echo '<img src="https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http%3A%2F%2Fwww.sungest.net/reservas_list.php?qs='.dechex(999999999-$values['Id_Reserva']).'&f=all%2F&choe=UTF-8">';

    //    echo '<img src="data:image/jpeg;base64,'.$imageData.'">';
    //echo '<img src="data:image/jpeg;base64,'.$imageData.'">';
    //echo '<img src="data:image/jpeg;base64,'.$imageData.'">';
    $msg.= "<font size=4 color='Navy'><b>La seva reserva és per anar a : </b></font>". "<font size=5 color='Olive'><b>" .$data["Espacio"] . "</b></font><br>";
    $msg.= "<font size=4 color='Olive'><b>La seva àrea assignada és: </b></font>".$values['Id_Area']."<br>";


    $subject="La seva reserva per la platja";
    $ret=runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $msg));
        echo "ok";
  } 
  else
      DB::Exec("delete from reservas where Ds_Order='".$res["Ds_Order"]."'");
fclose($handle);
?>

_______________________________________________________________________________________________

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.