0
I wonder if there’s something wrong:
if(isset($_POST['notificationType']) && $_POST['notificationType'] == 'transaction'){
//Todo resto do código iremos inserir aqui.
$email = 'douglas@...';
$token = '95112...';
$url = 'https://ws.pagseguro.uol.com.br/v2/transactions/notifications/' . $_POST['notificationCode'] . '?email=' . $email . '&token=' . $token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$transaction= curl_exec($curl);
curl_close($curl);
if($transaction == 'Unauthorized'){
//Insira seu código avisando que o sistema está com problemas, sugiro enviar um e-mail avisando para alguém fazer a manutenção
$resultado = "Não autorizado!";
exit;//Mantenha essa linha
}
$transaction = simplexml_load_string($transaction);
$transactionStatus = $transaction->status;
if($transactionStatus > 0) {
$TransacaoID = $transaction->code;
$Referencia = $transaction->reference;
$mpresult = $transaction->paymentMethod->type;
if($mpresult == 1){
$MetodoPagamento = "Cartão de crédito";
} elseif($mpresult == 2){
$MetodoPagamento = "Boleto";
} elseif($mpresult == 3){
$MetodoPagamento = "Débito online (TEF)";
} else {
$MetodoPagamento = "Outro";
}
$DataTransacao = date('d/m/Y', strtotime($transaction->date));
if($transactionStatus == 1){
$transactionStatus = 'Aguardando pagamento';
} elseif($transactionStatus == 2){
$transactionStatus = 'Em análise';
} elseif($transactionStatus == 3){ // :)
$transactionStatus = 'Paga';
} elseif($transactionStatus == 4){ // :D
$transactionStatus = 'Disponível';
} elseif($transactionStatus == 5){
$transactionStatus = 'Em disputa';
} elseif($transactionStatus == 6){
$transactionStatus = 'Devolvida';
} elseif($transactionStatus == 7){
$transactionStatus = 'Cancelada';
}
$CliNome = $transaction->sender->name;
$sql = mysql_query("INSERT INTO pedidos (TransacaoID,Referencia,MetodoPagamento,StatusTransacao,CliNome) VALUES ('".$TransacaoID."', '".$Referencia."', '".$MetodoPagamento."', '".$transactionStatus."', '".$CliNome."')");
} } else {
echo "Transação concluida com sucesso!"; }
I made the connection to the bank externally.
– Douglas Takiuti
What is the error? Are you sure the script will reach the query execution? Note: avoid using the functions
mysql_*
...– Berriel
problem solved..
– Douglas Takiuti
Share the solution by answering your own question, or feel free to delete the question...
– Berriel