Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
abaixo dúvida sobre problema no retorno automatico em servidor de testes. Consigo ver o pedido completo no servidor de testes.
tenho pagseguro.php baixado do site da visie
servidor de testes pagseguro em ambiente windows
eis meu log quando envio uma fatura para o servidor de testes:
-----------------------------------
POST recebido (A): 2009-07-16 15:08:50
Array
(
[TransacaoID] => 7F6490E2-6FC4-4B7F-8D65-5EDB7EFDA8CD
[DataTransacao] => 16/07/2009 15:08:50
[VendedorEmail] => xxxx
[Referencia] => Pedido: 105 - Cliente: 3
[TipoFrete] => FR
[ValorFrete] => 0,00
[Anotacao] =>
[TipoPagamento] => Boleto
[StatusTransacao] => Aguardando Pagto
[CliNome] => xxxx
[CliEmail] => xxxx
[CliEndereco] =>
[CliNumero] =>
[CliComplemento] =>
[CliBairro] =>
[CliCidade] =>
[CliEstado] =>
[CliCEP] => xxxxxx
[CliTelefone] => 0 xxxxx
[NumItens] => 2
[ProdID_1] => 24{7}14
[ProdDescricao_1] => A Terra Sagrada[PC-DISC]
[ProdValor_1] => 90,00
[ProdQuantidade_1] => 1
[ProdFrete_1] => 0,00
[ProdExtras_1] => 0,00
[ProdID_2] => 8{7}14
[ProdDescricao_2] => Vida de Inseto[DVD-ABUG]
[ProdValor_2] => 35,99
[ProdQuantidade_2] => 3
[ProdFrete_2] => 0,00
[ProdExtras_2] => 0,00
)
-----------------------------------
POST recebido: 2009-07-16 15:08:50
Array
(
[TransacaoID] => 7F6490E2-6FC4-4B7F-8D65-5EDB7EFDA8CD
[DataTransacao] => 16/07/2009 15:08:50
[VendedorEmail] => xxxxx
[Referencia] => Pedido: 105 - Cliente: 3
[TipoFrete] => FR
[ValorFrete] => 0,00
[Anotacao] =>
[TipoPagamento] => Boleto
[StatusTransacao] => Aguardando Pagto
[CliNome] => xxxxxx
[CliEmail] => xxxxx
[CliEndereco] =>
[CliNumero] =>
[CliComplemento] =>
[CliBairro] =>
[CliCidade] =>
[CliEstado] =>
[CliCEP] => xxxx
[CliTelefone] => xxxx
[NumItens] => 2
[ProdID_1] => 24{7}14
[ProdDescricao_1] => A Terra Sagrada[PC-DISC]
[ProdValor_1] => 90,00
[ProdQuantidade_1] => 1
[ProdFrete_1] => 0,00
[ProdExtras_1] => 0,00
[ProdID_2] => 8{7}14
[ProdDescricao_2] => Vida de Inseto[DVD-ABUG]
[ProdValor_2] => 35,99
[ProdQuantidade_2] => 3
[ProdFrete_2] => 0,00
[ProdExtras_2] => 0,00
)
-----------------------------------
cURL: 2009-07-16 15:08:51
<html><head><script language="javascript">window.location="http://localhost/loja/ext/modules/payment/pagseguro.php";
-----------------------------------
resposta: 2009-07-16 15:08:51
<html><head><script language="javascript">window.location="http://localhost/loja/ext/modules/payment/pagseguro.php";<br>confirmação:
-----------------------------------
POST recebido (A): 2009-07-16 15:08:51
Array
(
)
-----------------------------------
POST vazio: 2009-07-16 15:08:51
Redirecionando para checkout_process
Eis aqui quando faço a alteração de estado (para aprovado, por exemplo) no servidor de testes
-----------------------------------
POST recebido (A): 2009-07-16 15:09:43
Array
(
[TransacaoID] => 7F6490E2-6FC4-4B7F-8D65-5EDB7EFDA8CD
[DataTransacao] => 16/07/2009 15:08:50
[VendedorEmail] => xxxxxx
[Referencia] => Pedido: 105 - Cliente: 3
[TipoFrete] => FR
[ValorFrete] => 0,00
[Anotacao] =>
[TipoPagamento] => Pagamento
[StatusTransacao] => Aprovado
[CliNome] => xxxxx
[CliEmail] => xxx
[CliEndereco] =>
[CliNumero] =>
[CliComplemento] =>
[CliBairro] =>
[CliCidade] =>
[CliEstado] =>
[CliCEP] => xxxx
[CliTelefone] => xxxx
[NumItens] => 2
[ProdID_1] => 24{7}14
[ProdDescricao_1] => A Terra Sagrada[PC-DISC]
[ProdValor_1] => 90,00
[ProdQuantidade_1] => 1
[ProdFrete_1] => 0,00
[ProdExtras_1] => 0,00
[ProdID_2] => 8{7}14
[ProdDescricao_2] => Vida de Inseto[DVD-ABUG]
[ProdValor_2] => 35,99
[ProdQuantidade_2] => 3
[ProdFrete_2] => 0,00
[ProdExtras_2] => 0,00
)
-----------------------------------
POST recebido: 2009-07-16 15:09:43
Array
(
[TransacaoID] => 7F6490E2-6FC4-4B7F-8D65-5EDB7EFDA8CD
[DataTransacao] => 16/07/2009 15:08:50
[VendedorEmail] => xxxxx
[Referencia] => Pedido: 105 - Cliente: 3
[TipoFrete] => FR
[ValorFrete] => 0,00
[Anotacao] =>
[TipoPagamento] => Pagamento
[StatusTransacao] => Aprovado
[CliNome] => xxxxx
[CliEmail] => xxxxx
[CliEndereco] =>
[CliNumero] =>
[CliComplemento] =>
[CliBairro] =>
[CliCidade] =>
[CliEstado] =>
[CliCEP] => xxxxxx
[CliTelefone] => xxxxxx
[NumItens] => 2
[ProdID_1] => 24{7}14
[ProdDescricao_1] => A Terra Sagrada[PC-DISC]
[ProdValor_1] => 90,00
[ProdQuantidade_1] => 1
[ProdFrete_1] => 0,00
[ProdExtras_1] => 0,00
[ProdID_2] => 8{7}14
[ProdDescricao_2] => Vida de Inseto[DVD-ABUG]
[ProdValor_2] => 35,99
[ProdQuantidade_2] => 3
[ProdFrete_2] => 0,00
[ProdExtras_2] => 0,00
)
-----------------------------------
cURL: 2009-07-16 15:09:43
<html><head><script language="javascript">window.location="http://localhost/loja/ext/modules/payment/pagseguro.php";
-----------------------------------
resposta: 2009-07-16 15:09:43
<html><head><script language="javascript">window.location="http://localhost/loja/ext/modules/payment/pagseguro.php";<br>confirmação:
pagseguro.php
ele entra em $curl, gera o log acima, mas não entra em if ($confirma), onde $confirma = (strcmp (substr($resp,0,10), "VERIFICADO") == 0);
indo para o else de $confirma, ele não entra no if de == FALSE e morre ali.
se eu setar confirm como true, o resto (operações de liberação de download, ...) ele faz correto.
acredito que o problema seja entre essa resposta e recimento ali, será que não?
se alguém tiver uma contribuição, à vontade!
grato
<?php
/*
$Id: pagseguro.php,v 1.1.2.8 2004/12/07 15:46:08 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2004 osCommerce
Released under the GNU General Public License
*/
chdir('../../../');
require('includes/application_top.php');
if (!function_exists('debug_var')) {
function debug_var($var, $name='', $to_file=false){
if ($to_file==true) {
$txt = fopen('ext/debug.log','a');
fwrite($txt, "-----------------------------------\n");
fwrite($txt, $name."\n");
fwrite($txt, print_r($var, true)."\n");
fclose($txt);//
} else {
print('<pre><br><b>'.$name.'</b><br>');
echo '<pre>';
print_r($var);
echo '</pre>';
}
}
}
// re-set the level of error reporting due to problems with IIS and the loop fgets
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
debug_var ($_POST, "POST recebido (A): ".date("Y-m-d G:i:s"), true);
// RECEBE O POST ENVIADO PELA PAGSEGURO E ADICIONA OS VALORES PARA VALIDAÇÃO DOS DADOS
if (!tep_not_null($_POST)) { // variáveis POST vazias, significa que é a segunda chamada do script
debug_var ('Redirecionando para checkout_process', "POST vazio: ".date("Y-m-d G:i:s"), true);
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PROCESS, "StatusTransacao=$StatusTransacao&Referencia=$Referencia", 'SSL'));
}
debug_var ($_POST, "POST recebido: ".date("Y-m-d G:i:s"), true);
// ENVIA DE VOLTA PARA A PAGSEGURO OS DADOS PARA VALIDAÇÃO
$PagSeguro = 'Comando=validar';
$PagSeguro .= "&Token=".trim(MODULE_PAYMENT_PAGSEGURO_TOKEN);
foreach ($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$PagSeguro .= "&$key=$value";
}
$server = 'localhost:9090';
$fsocket = false;
$curl = false;
$result = false;
if (function_exists('curl_exec')) {
$curl = true;
} elseif ( (PHP_VERSION >= 4.3) && ($fp = @fsockopen ('ssl://'.$server, 443, $errno, $errstr, 30)) ) {
$fsocket = true;
} elseif ($fp = @fsockopen($server, 80, $errno, $errstr, 30)) {
$fsocket = true;
}
if ($curl == true) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://' . $server . '/Security/NPI/Default.aspx/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $PagSeguro);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($ch);
if (!tep_not_null($resp)) {
curl_setopt($ch, CURLOPT_URL, 'http://' . $server . '/Security/NPI/Default.aspx/');
$resp = curl_exec($ch);
}
debug_var ($resp, "cURL: ".date("Y-m-d G:i:s"),true);
curl_close($ch);
$confirma = (strcmp (substr($resp,0,10), "VERIFICADO") == 0);
} elseif ($fsocket == true) {
$Cabecalho = "POST /Security/NPI/Default.aspx HTTP/1.0\r\n";
$Cabecalho .= "Content-Type: application/x-www-form-urlencoded\r\n";
$Cabecalho .= "Content-Length: " . strlen($PagSeguro) . "\r\n\r\n";
if ($fp || $errno>0){
fputs ($fp, $Cabecalho . $PagSeguro);
$confirma = false;
$resp = '';
while (!feof($fp)){
$res = @fgets ($fp, 1024);
$resp .= $res;
// Verifica se o status da transação está VERIFICADO
if (strcmp (substr($res,0,10), "VERIFICADO") == 0)
{
$confirma=true;
debug_var ($resp, "fsockopen: ".date("Y-m-d G:i:s"),true);
tep_db_query("INSERT INTO teste (data) VALUES (now())");
break;
}
}
fclose ($fp);
} else{
echo "$errstr ($errno)<br />\n";
debug_var ($errstr.'('.$errno.')', "erro em fsockopen:: ".date("Y-m-d G:i:s"),true);
// ERRO HTTP
}
}
debug_var ($resp.'<br>confirmação: '.print_r($confirma,true), "resposta: ".date("Y-m-d G:i:s"),true);
if ($confirma) {
//aqui depois tudo certo!
} else {
if (strcmp ($res, "FALSO") == 0){
// LOG para investigação manual
if (tep_not_null(MODULE_PAYMENT_PAGSEGURO_DEBUG_EMAIL)) {
$email_body = '$_POST:' . "\n\n";
foreach ($_POST as $key => $value) {
$email_body .= $key . '=' . $value . "\n";
}
$email_body .= "\n" . '$_GET:' . "\n\n";
foreach ($_GET as $key => $value) {
$email_body .= $key . '=' . $value . "\n";
}
tep_mail('', MODULE_PAYMENT_PAGSEGURO_DEBUG_EMAIL, 'Post Inválido: ', $email_body, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}
if ($txt = @fopen ('ext/fake.log', 'a')) {
fwrite ($txt, "\n======================================\nDados possivelmente falsificados: ".date("Y-m-d G:i:s"). "\n");
fwrite ($txt, print_r($_POST,true). "\n");
fclose($txt);
};
}
}
require('includes/application_bottom.php');
?>Carregando comentários...