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;
}