Pagseguro notifications: Unable to resend the notification

Asked

Viewed 1,789 times

1

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

At SANDBOX, I’m not receiving transaction notifications.

I’m testing on a valid domain, hosted on a VM, Linux Ubuntu 14.04, on Locaweb.

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

I put to write on APACHE error log: "NOTIFICATION TRIGGERED!" , right in the first line of my notification file, in PHP, which should be called, for each notification of Transaction Status change, as 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'];

In place of:

$http_origin = $_SERVER['HTTP_ORIGIN'];

Below are the 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 )

When clicking the "Resend Notification" button, the error appears: "Unable to resend the notification." and NADA is written in the APACHE log.

When clicking on "View log" appears the notification URL and the message: "The notification was not sent. Check the notification URL and make a new transaction." and NADA is written in the APACHE log.

When copying and pasting the notification URL in a browser, the message appears in the APACHE log: "TRIGGERED NOTIFICATION!".

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

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

No firewall blocking record (IPTABLES).

Since, nothing is recorded in the APACHE log by clicking the "Resend Notification" button, but when I type the URL directly into the BROWSER the access is recorded in the APACHE LOG.

Strange that: By clicking on "Resend local notification", the notification is sent and everything works correctly. With the data being hosted on a WEB server, with public IP and valid URL.

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

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

Any help is welcome!

  • Is testing on localhost?

  • Thanks for your attention... I’m testing on a valid domain, hosted on a VM, Linux Ubuntu 14.04, on Ocaweb.

  • I had this problem when I was in localhost, ai was the browser blocking some scripts, ai appeared an icon in the upper right corner in the case of Chrome. But on the online server I did not have this problem

3 answers

3


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

For this, in the configuration of the SITE in Apache, in the configuration line SSLProtocol the configuration must be added +TLSV1.0, which gives enables the TLS protocol version 1.0.

It is important to remember that the TLS protocol in versions 1.0 and 1.1 is already outdated and with security flaws, therefore it should be used with caution.

  • 1

    Pagseguro also has problems with SNI certificates, such as those used by Cloudflare and Let’s Encrypt. At least until some time ago it had.

0

I’ll put my notification code here, I don’t know how your... But as mine is working recording in the bank, maybe this can help you. Ai comments here any doubt. In this code below, it is the file that is configured in the pagseguro to receive the notifications, in this case the nofiticacao.php. It receives the notification saved in the bank the code and the status of the transaction. I hope to help... inserir a descrição da imagem aqui

  <?php
 include_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));

     }

?>

0

I had the same problem. Solved when I removed the URL de Notificação when generating the payment URL. Then I changed the URL to Transaction Notification within the Sandbox Pagseguro interface in the INTEGRATION PROFILES menu. This way I started to be notified when changing the status: inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.