Advertisement
Guest User

Obter Dados da transacao pelo codigo da notificação

a guest
Jan 5th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1.     public function getNotificacao() {
  2.         try {
  3.  
  4.             if (\PagSeguro\Helpers\Xhr::hasPost()) {
  5.  
  6.                 $this->credentials->getCredentials();
  7.  
  8.                 $response = \PagSeguro\Services\Transactions\Notification::check(
  9.                                 \PagSeguro\Configuration\Configure::getAccountCredentials()
  10.                 );
  11.             } else {
  12.                 $this->LOGERROR->error('status', $_POST);
  13.                 throw new \InvalidArgumentException($_POST);
  14.             }
  15.  
  16.             if ($_POST['notificationType'] === "transaction") {
  17.  
  18.                 $this->LOGINFO->info("codigo da notificação ->> " . $_POST['notificationCode']);
  19.  
  20.                 $notificationCode = $_POST['notificationCode'];
  21.                
  22.                 // repassando o codigo da notificação para o metodo pegar os dados da transacao
  23.                 $this->getDataTransaction($notificationCode);
  24.             }
  25.         } catch (Exception $e) {
  26.             $this->LOGERROR->error($e->getMessage());
  27.         }
  28.     }
  29.  
  30.     public function getDataTransaction($notificationCode) {
  31.         try {
  32.             $this->credentials->getCredentials();
  33.             $response = \PagSeguro\Services\PreApproval\Search\Notification::search(
  34.                             \PagSeguro\Configuration\Configure::getAccountCredentials(), $notificationCode
  35.             );
  36.            
  37.             //print_r($response);
  38.  
  39.             $this->LOGINFO->info("DADOS DA TRANSACAO" . $response);
  40.         } catch (Exception $e) {
  41.             $this->LOGERROR->error($e->getMessage());
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement