PHP code example of leandroferreirama / pagamento-cnab-240-retorno

1. Go to this page and download the library: Download leandroferreirama/pagamento-cnab-240-retorno library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leandroferreirama / pagamento-cnab-240-retorno example snippets


try{
    $leitorArquivo = new \Leandroferreirama\PagamentoCnab240Retorno\Aplicacao\LeitorRetorno();
    $listaLotes = $leitorArquivo->recepcionarArquivo($_FILES['arquivo']);

    if(! is_null($listaLotes)){
        foreach($listaLotes as $lote){
            ### INCLUIR O TRATAMENTO DE IDENTIFICAÇÃO DA CONTA
            echo "<hr>LOTE: <br>Codigo banco: {$lote['codigo_banco']}<br>agencia: {$lote['agencia']}<br>Conta: {$lote['conta']}<br>DV: {$lote['contaDv']}<br><hr>CONTEUDO:<bR>";
            foreach($lote['detalhes'] as $conteudo){
                ### INCLUIR O TRATAMENTO DOS RETORNOS DOS ITENS
                echo "<hr>Segmento: {$conteudo['segmento']} | Data: {$conteudo['data_pagamento']} | Valor: {$conteudo['valor_pagamento']} | Seu nº: {$conteudo['seu_numero']} | Ocorrencia: {$conteudo['ocorrencia']} | Resultado: {$conteudo['resultado']}<hr>";
            }
        }
    }
} catch(Exception $exception){
    echo $exception->getMessage();
}