0
Previously I had opened an error question in the pagseguro API, well, I managed to solve it. Now my problem is another... I can’t get paid notifications. I already set up the URL in the pay-as-you-go panel only I don’t get anything after shopping. I tested the direct notification file in the browser and it sent me an email (which is what I want to do), but by pagseguro it does not return anything. This is my code:
<?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);
}
?>
You accessed the pagseguro in the transaction to see if notification was sent ? If you have a sending code other than 200 there is something wrong, probably the url, passed from notification to pagseguro
– Dexxtz