<?php $acesso_bd = "ok"; include('fncr-geral/coneccao-bd.php');

  require_once "js/PagSeguroLibrary/PagSeguroLibrary.php";
  $email = "lswebsites@hotmail.com";
  $token = "5418AF7C4B824F7C8DE7C2012DE7EE08";
  $notificationCode = $_POST['notificationCode'];
  $url = "https://ws.pagseguro.uol.com.br/v2/transactions/notifications/".$notificationCode."?email=".$email."&token=".$token;

  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($curl);
  $http = curl_getinfo($curl);

  if($response == 'Unauthorized'){   print_r($response);   exit;  }
  curl_close($curl);
  $response= simplexml_load_string($response);
  if(count($response -> error) > 0){   print_r($response);   exit;  }

/********* CONFIGURAÇÃO LOCAL *********/

// Data e Hora atual
date_default_timezone_set("Brazil/East");
$data_atual = date('Y/m/d');
$hora = date('H:i');

$id_registro        = $response->reference;
$status_pgt         = $response->status;
$cod_transacao      = $response->code;
$valor_transacao    = $response->grossAmount;
$data_notificacao   = $response->lastEventDate;   $data_notificacao = explode('T', $data_notificacao);
$valor_desc_pag     = $response->feeAmount;
$valor_liberado     = $response->netAmount;
$data_liberacao     = $response->escrowEndDate;   $data_liberacao = explode('T', $data_liberacao);
$boleto             = $response->paymentLink;

echo "Id do registro: ".$id_registro."<br>";
echo "Status Pgto: ".$status_pgt."<br>";
echo "Cod. Transa&ccedil;&atilde;o: ".$cod_transacao."<br>";
echo "Valor Transa&ccedil;&atilde;o: ".$valor_transacao."<br>";
echo "Data Notifica&ccedil;&atilde;o: ".$data_notificacao."<br>";
echo "Valor Descontado: ".$valor_desc_pag."<br>";
echo "Valor L&iacute;quido: ".$valor_liberado."<br>";
echo "Data Libera&ccedil;&atilde;o: ".$data_liberacao."<br>";
echo "Link do Boleto (se houver): ".$boleto."<br>";

$bd = null;
?>


