Amigos, sei que existem tópicos sobre o assunto, porém vi que já são um poco antinguinhos e preciso muito de uma ajudinha.
Eu criei o retorno automático, porém nos testes que realizei o status da transação não está sendo editada no meu sistema.
public function actionRetornoPagseguro()
{
$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':
$credentials = new PagSeguroAccountCredentials($email, $token);
try {
$transaction = PagSeguroNotificationService::checkTransaction($credentials, $code);
$transactionStatus = $transaction->getStatus(); //Status da transação
$id_pedido = $transaction->getReference(); //Código de referência da transação
$model = Fatura::model()->findByPk($id_pedido);
switch ($transactionStatus->getTypeFromValue()) {
case 'WAITING_PAYMENT':
$model->status = "Em Aberto";
break;
case 'IN_ANALYSIS':
$model->status = "Em Análise";
break;
case 'PAID':
$model->status = "Paga";
break;
case 'AVAILABLE':
$model->status = "Completa";
break;
case 'IN_DISPUTE':
$model->status = "Em Disputa";
break;
case 'REFUNDED':
$model->status = "Devolvida";
break;
case 'CANCELLED':
$model->status = "Cancelada";
break;
}
if ($model->validate()) {
$model->save()
}
} catch (PagSeguroServiceException $e) {
die($e->getMessage());
}
break;
default:
LogPagSeguro::error("Unknown notification type [".$notificationType->getValue()."]");
}
self::printLog($strType);
} else {
LogPagSeguro::error("Invalid notification parameters.");
self::printLog();
}
}
Se alguém puder me ajudar dizendo por que não está salvando o status eu agradeço =)
Abraços