<?php
session_start(); 
$xml=simplexml_load_file("config/config.xml");
include('config/config.php');
include('config/controller.php');
require_once "../../plugins/PagSeguroLibrary/PagSeguroLibrary.php";



function TokenPagamento($transaction_id){

    $credentials = new PagSeguroAccountCredentials(PAGSEGURO, TOKEN);
	  
	/*  
	    Realizando uma consulta de transação a partir do código identificador  
	    para obtero o objeto PagSeguroTransaction 
	*/   
	$transaction = PagSeguroTransactionSearchService::searchByCode(  
	    $credentials,  
	    $transaction_id  
	);

	return $transaction;	
	
}

$transaction = TokenPagamento($_REQUEST['transaction_id']);

$paymentMethod = $transaction->getPaymentMethod();  

$cad = new Control();
$cad->Comprar($transaction->getDate(), $paymentMethod->getType()->getTypeFromValue(), $transaction->getGrossAmount(), $transaction->getStatus()->getTypeFromValue(), $_SESSION['idAluno'], $_REQUEST['transaction_id'], $transaction->getItems());

?>