public static function retornoPagseguro($dados) { $widget = Widgets::findFisrt('id = 3'); $opcoes = unserialize($widget->opcoes); $url = 'https://ws.pagseguro.uol.com.br/v2/transactions/notifications/' . $dados['notificationCode'] . '?email=' . $opcoes['email'] . '&token=' . $opcoes['token']; $curl = curl_init($url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $retorno = curl_exec($curl); curl_close($curl); if ($retorno == 'Unauthorized') { return false; //Mantenha essa linha } $retorno = simplexml_load_string($retorno); $pedido = Pedidos::findFirst('id = ' . $retorno->reference); $pedido->status_id = self::deParaStatus($retorno->status, 3); $pedido->save(); if ($pedido->status_id == 3) { self::subtraiEstoque($pedido->id); } return $pedido->pedido_id; }