Hi!
I've developed my own callback module. Everything is working fine: it receives the informations from my payment gateway and create the transation. How ever, the invoice still marked as unpaid. Any ideia about this bug?
I've double checked the invoices values and they are allright. Here is my code:
<?php
# Required File Includes
include("../../../dbconnect.php");
include("../../../includes/functions.php");
include("../../../includes/gatewayfunctions.php");
include("../../../includes/invoicefunctions.php");
$gatewaymodule = "pagseguro"; # Enter your gateway module name here replacing template
$GATEWAY = getGatewayVariables($gatewaymodule);
if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback
# Get Returned Variables - Adjust for Post Variable Names from your Gateway's Documentation
$notificationCode = $_POST["notificationCode"];
$notificationType = $_POST["notificationType"];
$emailPagseguro = $GATEWAY["email"];
$apiKey = $GATEWAY["callbacktoken"];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"https://ws.pagseguro.uol.com.br/v3/transactions/notifications/$notificationCode?email=$emailPagseguro&token=$apiKey");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$ret = curl_exec($curl);
$retorno = new SimpleXMLElement($ret);
$err = curl_error($curl);
curl_close($curl);
$idTransacao = $retorno->code;
$idFatura = $retorno->reference;
$statusPagamento = $retorno->status;
$valorBruto = $retorno->grossAmount;
$valorTaxas1 = $retorno->creditorFees->intermediationRateAmount;
$valorTaxas2 = $retorno->creditorFees->intermediationFeeAmount;
$valorLiquido = $retorno->netAmount;
$totalTaxa=(float)$valorTaxas1+(float)$valorTaxas2;
$invoiceid = checkCbInvoiceID($idFatura,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing
checkCbTransID($idTransacao); # Checks transaction number isn't already in the database and ends processing if it does
if ($statusPagamento=="3") {
# Successful
addInvoicePayment($idFatura,$idTransacao,$valorBruto,$totalTaxa,$gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, fees, modulename
logTransaction($GATEWAY["name"],$_POST,"Successful"); # Save to Gateway Log: name, data array, status
} else {
# Unsuccessful
logTransaction($GATEWAY["name"],$_POST,"Unsuccessful"); # Save to Gateway Log: name, data array, status
}
?>