Integration Cielo By Page Loja

4

I have a problem that I have tried to solve in several ways, but so far nothing and so I decided to go here.

I am implementing Cielo's payment solution , where the user performs the payment information in my own store, and then generated an XML for Cielo, and the whole process occurs.

I downloaded the Cielo Integration Kit, which comes with a model store, and I activated it in my development environment, and it worked perfectly, I just had to change the following lines:

curl_setopt($sessao_curl, CURLOPT_CAINFO, getcwd() ."/ssl/VeriSignClass3PublicPrimaryCertificationAuthority-G5.CRT");
curl_setopt($sessao_curl, CURLOPT_SSLVERSION, 1);

The first line tells you where the certificate, provided by Cielo, is in my directory and the second line is the certificate version.

Situation

When I run the system on my machine, calling the approval environment of Cielo, the whole process occurs correctly and without any problem.

However, when I put this code in the client approval environment, and I try to process it, the system creates the XML correctly, but at the time of connecting to the Cielo environment, it returns the following error

Operation timed out after 0 milliseconds with 0 out of 0 bytes received

In other words, the system can not connect to Cielo's server to send the XML, the problem is that I do not know if it is when sending or returning XML.

I would like to know if anyone has already experienced this problem, if there is some kind of release needed to do on the server, PHP version, etc.

Below is the code that connects to Cielo's server.

 
require 'errorHandling.php';
require_once 'pedido.php';
require_once 'logger.php';

define('VERSAO', "1.1.0");

session_start();

if(!isset($_SESSION["pedidos"]))
{
    $_SESSION["pedidos"] = new ArrayObject();
}

// CONSTANTES
define("ENDERECO_BASE", "https://qasecommerce.cielo.com.br");
define("ENDERECO", ENDERECO_BASE."/servicos/ecommwsec.do");

define("LOJA", "0000000");
define("LOJA_CHAVE", "xxxxxxxxx");
define("CIELO", "0000000");
define("CIELO_CHAVE", "xxxxxxxxx");


// Envia requisição
function httprequest($paEndereco, $paPost){

    $sessao_curl = curl_init();
    curl_setopt($sessao_curl, CURLOPT_URL, $paEndereco);

    curl_setopt($sessao_curl, CURLOPT_FAILONERROR, true);

    //  CURLOPT_SSL_VERIFYPEER
    //  verifica a validade do certificado
    curl_setopt($sessao_curl, CURLOPT_SSL_VERIFYPEER, true);

    //  CURLOPPT_SSL_VERIFYHOST
    //  verifica se a identidade do servidor bate com aquela informada no certificado
    curl_setopt($sessao_curl, CURLOPT_SSL_VERIFYHOST, 2);

    //  CURLOPT_SSL_CAINFO
    //  informa a localização do certificado para verificação com o peer
    curl_setopt($sessao_curl, CURLOPT_CAINFO, getcwd() ."/ssl/VeriSignClass3PublicPrimaryCertificationAuthority-G5.CRT");
    curl_setopt($sessao_curl, CURLOPT_SSLVERSION, 1);

    //  CURLOPT_CONNECTTIMEOUT
    //  o tempo em segundos de espera para obter uma conexão
    curl_setopt($sessao_curl, CURLOPT_CONNECTTIMEOUT, 10);

    //  CURLOPT_TIMEOUT
    //  o tempo máximo em segundos de espera para a execução da requisição (curl_exec)
    curl_setopt($sessao_curl, CURLOPT_TIMEOUT, 40);

    //  CURLOPT_RETURNTRANSFER
    //  TRUE para curl_exec retornar uma string de resultado em caso de sucesso, ao
    //  invés de imprimir o resultado na tela. Retorna FALSE se há problemas na requisição
    curl_setopt($sessao_curl, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($sessao_curl, CURLOPT_POST, true);
    curl_setopt($sessao_curl, CURLOPT_POSTFIELDS, $paPost );

    $resultado = curl_exec($sessao_curl);

    if (!$resultado) 
        $curl_error = curl_error($sessao_curl); // Capturo o erro ANTES de fechar

    curl_close($sessao_curl);

    if (!$resultado) 
        echo "<br><font size=6>" . $curl_error ;

    if ($resultado)
    {
        return $resultado;
    }
    else
    {
        return curl_error($sessao_curl);
    }
}

// Monta URL de retorno
function ReturnURL()
{
    $pageURL = 'http';

    if ($_SERVER["SERVER_PORT"] == 443) // protocolo https
    {
        $pageURL .= 's';
    }
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80")
    {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"]. substr($_SERVER["REQUEST_URI"], 0);
    }
    // ALTERNATIVA PARA SERVER_NAME -> HOST_HTTP

    $file = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);

    $ReturnURL = str_replace($file, "retorno.php", $pageURL);

    return $ReturnURL;
}
    
asked by anonymous 18.01.2015 / 20:47

4 answers

0

After a long time and many searches I identified that the problem was in this line

CURLOPT_SSLVERSION, 3

In a statement made even by Pay Pal he said that people who were using this line of code in this way should change to the line below

CURLOPT_SSLVERSION, 4

From what I understand code 3 validates your certificate using the last validation rule and it seems to me that the new version that was released occurred some kind of problem, that could not validate the certificate and returned as an invalid certificate. / p>

Because of this they requested to use code 4, which checks but uses the latest stable validation version of the system, ie the previous version of the validation code.

When doing this my system started to work perfectly, without any problem and also passed Cielo's approval without problems.

Go to the tip for who is or has been through this problem.

I hope I have helped

Abs

    
08.02.2015 / 14:01
3

I had already noticed this issue and made this change, but it still did not resolve.

Researching a lot on the internet, I found an integration post with Pay Pal that reported, that this line of code:

curl_setopt($sessao_curl, CURLOPT_SSLVERSION, 3);

Due to a bug in Poodle (I think that's it), it should be changed to

    curl_setopt($sessao_curl, CURLOPT_SSLVERSION, 4);

I made this change and the problem stopped happening.

In research on this change, there is a bug in the new version of SSL validation, so you should use the value 4, because with this value the system does not use the latest evaluation version of the certificate, previous (I think that's it)

I made this change and it is now working

It may be that this information helps those who have the same problem

Thanks for the response

Abs

    
25.01.2015 / 19:31
1

I went through the same problem, in my case I decided to rename the SSL file that comes in the integration kit of Cielo, because in the definition of cURL you are using the format that comes in the example of Cielo, which is:

curl_setopt($sessao_curl, CURLOPT_CAINFO, getcwd() ."/ssl/VeriSignClass3PublicPrimaryCertificationAuthority-G5.CRT");

But in the integration kit this file comes with the name VERISI~1.CRT instead of VeriSignClass3PublicPrimaryCertificationAuthority-G5.CRT

By doing this update the connections happen to be carried out normally in my case. Hope it helps!

    
24.01.2015 / 15:56
0

Hello. Cielo Buy Page has been discontinued. If you are trying to pass the values with a test key it will not work. For this code to work, you will have to use a Key in the Production environment, because Cielo keeps the service active for customers already approved. I recommend downloading the new integration manual, or speak directly with Support.

Heaven Checkout (Old Buy Page) - link

    
24.01.2015 / 14:25