Previously I had opened an error question in the pagseguro API, well, I managed to solve it. Now my problem is another ... I can not receive the notifications of the pagseguro. I already configured the URL in the pagseguro panel, but I do not receive anything after the purchases. I tested the direct notification file in the browser and it sent me an email (which is what I want to do), but for the sake it does not return anything. My code is this:
<?php
if(isset($_POST['notificationType']) && $_POST['notificationType'] == 'transaction'){
$email = '[email protected]';
$token = 'MEU-TOKEN-PAGSEGURO';
$url = 'https://ws.pagseguro.uol.com.br/v2/transactions/notifications/' . $_POST['notificationCode'] . '?email=' . $email . '&token=' . $token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$transaction= curl_exec($curl);
curl_close($curl);
if($transaction == 'Unauthorized'){
exit;
}
$transaction = new SimpleXMLElement($transaction);
$Ref = $transaction->{'reference'};
$Status = $transaction->{'status'};
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;charset=utf-8\r\n";
$headers .= "From: ABC <[email protected]>\r\n";
mail('[email protected]', 'Teste', 'Testando', $headers);
}
?>