Jump to content

addInvoicePayment() create the transation, but invoice still marked as unpaid

Recommended Posts



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:



# Required File Includes

$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); 

$idTransacao = $retorno->code; 
$idFatura = $retorno->reference; 
$statusPagamento = $retorno->status; 
$valorBruto = $retorno->grossAmount; 
$valorTaxas1 = $retorno->creditorFees->intermediationRateAmount; 
$valorTaxas2 = $retorno->creditorFees->intermediationFeeAmount;
$valorLiquido = $retorno->netAmount; 

$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


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.


Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated