Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Gente,
Tenho o seguinte código (baixado no kit de integração)...
<?php
require_once "../PagSeguroLibrary/PagSeguroLibrary.php";
class NotificationListener {
public static function main() {
$code = (isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? trim($_POST['notificationCode']) : null);
$type = (isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? trim($_POST['notificationType']) : null);
if ( $code && $type ) {
$notificationType = new PagSeguroNotificationType($type);
$strType = $notificationType->getTypeFromValue();
switch($strType) {
case 'TRANSACTION':
self::TransactionNotification($code);
break;
default:
LogPagSeguro::error("Unknown notification type [".$notificationType->getValue()."]");
}
self::printLog($strType);
} else {
LogPagSeguro::error("Invalid notification parameters.");
self::printLog();
}
}
private static function TransactionNotification($notificationCode) {
$credentials = new PagSeguroAccountCredentials("fromeroprado@hotmail.com", "62F6194814564DDA91A591A40451B8DC");
try {
$transaction = PagSeguroNotificationService::checkTransaction($credentials, $notificationCode);
} catch (PagSeguroServiceException $e) {
die($e->getMessage());
}
}
private static function printLog($strType = null) {
$count = 1;
echo "<h2>Receive notifications</h2>";
if($strType) {
echo "<h4>notifcationType: $strType</h4>";
}
echo "<p>Last <strong>$count</strong> items in <strong>log file:</strong></p><hr>";
echo LogPagSeguro::getHtml($count);
}
}
NotificationListener::main();
?>
... e eu gostaria de saber como e onde receber os dados retornados..
Carregando comentários...