PagSeguro notifications: The notification could not be resent

1

Before asking this question, I have read all the existing questions about "pagseguro notifications".

In SANDBOX, I'm not receiving notifications of the transactions.

I'm testing on a valid domain, hosted on a VM, Linux Ubuntu 14.04, on locaweb.

My notification url has an SSL certificate, Version 3, issued by "COMODO RSA Domain Validation Secure Server CA", with algorithm "Encryption PKCS # 1 SHA-256 with RSA".

I've typed in the APACHE error log: : "NOTIFICATION IS ACTION!", right on the first line of my notifications file, in PHP, which should be called called, every change notification of Transaction Status, as per the code snippet below.

<?php
error_log('NOTIFICACAO ACIONADA!');
$http_origin = $_SERVER['HTTP_ORIGIN'];

$array_origens_permitidas[] = 'https://pagseguro.uol.com.br';
$array_origens_permitidas[] = 'https://ws.pagseguro.uol.com.br';
$array_origens_permitidas[] = 'https://stc.pagseguro.uol.com.br';
$array_origens_permitidas[] = 'https://sandbox.pagseguro.uol.com.br';
$array_origens_permitidas[] = 'https://ws.sandbox.pagseguro.uol.com.br';
$array_origens_permitidas[] = 'https://stc.sandbox.pagseguro.uol.com.br';

if (in_array($http_origin, $array_origens_permitidas)){  
    header("Access-Control-Allow-Origin: $http_origin");
}

I've also tried using:

$request_headers        = apache_request_headers();
$http_origin            = $request_headers['Origin'];

Instead of:

$http_origin = $_SERVER['HTTP_ORIGIN'];

Below are modules installed in apache, listed with print_r(apache_get_modules());

Array (
[0] => core
[1] => mod_so
[2] => mod_watchdog
[3] => http_core
[4] => mod_log_config
[5] => mod_logio
[6] => mod_version
[7] => mod_unixd
[8] => mod_access_compat
[9] => mod_alias
[10] => mod_auth_basic
[11] => mod_authn_core
[12] => mod_authn_file
[13] => mod_authz_core
[14] => mod_authz_host
[15] => mod_authz_user
[16] => mod_autoindex
[17] => mod_cache
[18] => mod_deflate
[19] => mod_dir
[20] => mod_env
[21] => mod_expires
[22] => mod_file_cache
[23] => mod_filter
[24] => mod_headers
[25] => mod_mime
[26] => prefork
[27] => mod_negotiation
[28] => mod_php5
[29] => mod_setenvif
[30] => mod_socache_shmcb
[31] => mod_ssl
[32] => mod_status )

Clicking the "Resend Notification" button displays the error: "The notification could not be resent." and NOTHING is written in the APACHE log.

Clicking "View log" will display the notification URL and the message: "The notification has not been sent, check the notification URL and start a new transaction." and NOTHING is written in the APACHE log.

When copying and pasting the URL of the notification into a browser, the message "NOTIFICATION ACTIONED!" appears in the APACHE log.

The notification url is being defined through the SANDBOX configuration screen, in the "Test Seller" area, field: "Set URL to receive notifications:".

In addition, I also send the notification url in the payment POST via cURL as "notificationURL".

No firewall log (IPTABLES).

Once, nothing is registered in the APACHE log by clicking the "Resend notification" button, but when I type the URL directly in the BROWSER the access is registered in the APACHE LOG.

Strange that: When you click " Resend local notification ", notification is sent and everything works correctly. Being the data hosted on a WEB server, with public IP and valid URL.

It seems that for some reason PAGSEGURO is not sending the notifications to my notification url.

Would anyone have any idea what might be happening? What could I have done wrong? What can I have forgotten to do?

Any help is welcome!

    
asked by anonymous 07.12.2016 / 20:34

3 answers

3

After much research and testing, I discovered that despite the fact that PagSeguro it says that it accepts the TLS v1.1 certificate, in fact it only accepts TLS v1.0.

In order to do this, in the configuration of the SITE in Apache, the SSLProtocol configuration line must be added to the +TLSV1.0 configuration, which enables TLS version 1.0 protocol.

It is important to remember that the TLS protocol in versions 1.0 and 1.1 is already out of date and has security holes, so it should be used with caution.

    
07.02.2017 / 20:50
0

I'm going to put my receipt code for the notification here, I do not know how yours is ... But since mine is working by recording in the bank, maybe this can help. Ai comments here any questions. In this code below, it is the file that is configured in the pagseguro to receive the notifications, in the case the nofiticacao.php. It receives the notification saved in the bank code and transaction status. I hope I can help ...

<?phpinclude_once("sistema/config.php");

     header("access-control-allow-origin: https://sandbox.pagseguro.uol.com.br");
     if (count($_POST)>0) {

               $email = "meu email";
               $token = " meu token";
               $notificationCode = $_POST['notificationCode'];
               $url = "https://ws.sandbox.pagseguro.uol.com.br/v3/transactions/notifications/".$notificationCode."?email=".$email."&token=".$token;

               $curl = curl_init($url);
               curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
               curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
               $response = curl_exec($curl);
               $http = curl_getinfo($curl);

               if($response == 'Unauthorized'){
                        print_r($response);
                        exit;
               }
               curl_close($curl);
               $response= simplexml_load_string($response);

               if(count($response -> error) > 0){
                        print_r($response);
                        exit;
               }

       $conexao=Conecta();
            $preparado=$conexao->prepare("INSERT hf_status_faturas(id_fatura,idStatus) VALUES(?,?)");
$preparado->execute(array($response->code,$response->status));

     }

?>
    
07.12.2016 / 22:36
0

I was having the same problem. Resolved when I removed URL de Notificação at the time of generating the payment URL. So I changed the URL for Transaction Notification inside the Sandbox PagSeguro interface in the INTEGRATION PROFILES menu. This is how I started to notify you when I changed my status:

    
12.06.2017 / 21:41