/** * TransactionNotification Envia as credenciais do usuário para a Api e * retorna os dados da transação a partir do notificationCode * @notificationCode string Identificador único da transação */ private static function TransactionNotification($notificationCode) { /* * #### Crendenciais ##### * Se desejar, utilize as credenciais pré-definidas no arquivo de configurações * $credentials = PagSeguroConfig::getAccountCredentials(); */ // Pegando as configurações definidas no admin do módulo $config = self::getConfig(); $credentials = new AccountCredentials($config['email'], $config['token']); try { $transaction = NotificationService::checkTransaction($credentials, $notificationCode); self::validateTransaction($transaction); } catch (PagSeguroServiceException $e) { die($e->getMessage()); } }
$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 NotificationType($type); $strType = $notificationType->getTypeFromValue(); switch($strType) { case 'TRANSACTION': $credentials = new AccountCredentials($account, $token); try { $transaction = NotificationService::checkTransaction($credentials, $code); } catch (PagSeguroServiceException $e) { $error = $e->getMessage(); } break; default: $error = $notificationType->getValue(); break; } }else{ $error = "Invalid notification parameters."; } if($transaction)