Laravel Boleto’s Docs

Installation

Requirements

At the command line:

composer require "eduardokum/laravel-boleto"

Or, Put in your composer.json file:

{
    "eduardokum/laravel-boleto": "~0.8"
}

Usage

To create an instance of a Boleto, you first need to create 2 Pessoa, the Beneficiário and the Pagador.
Each of the banks has a particularity, so each one has its own documentation seen below.

Beneficiário

To create a Beneficiário you need to create an instance of the Pessoa object.

Note

Beneficiário is the person issuing the charge.

$beneficiario = new \Eduardokum\LaravelBoleto\Pessoa;
$beneficiario->setDocumento('00.000.000/0000-00')
    ->setNome('Company co.')
    ->setCep('00000-000')
    ->setEndereco('Street name, 123')
    ->setBairro('district')
    ->setUf('UF')
    ->setCidade('City');

Or, Simply:

$beneficiario = new \Eduardokum\LaravelBoleto\Pessoa([
    'documento' => '00.000.000/0000-00',
    'nome'      => 'Company co.',
    'cep'       => '00000-000',
    'endereco'  => 'Street name, 123',
    'bairro' => 'district',
    'uf'        => 'UF',
    'cidade'    => 'City',
]);

Attention

The Boleto requires an instance of Beneficiário.

Pagador

To create a Pagador you need to create an instance of the Pessoa object.

Note

Pagador is the person receiving the charge.

$pagador = new \Eduardokum\LaravelBoleto\Pessoa;
$pagador->setDocumento('00.000.000/0000-00')
    ->setNome('Company co.')
    ->setCep('00000-000')
    ->setEndereco('Street name, 123')
    ->setBairro('district')
    ->setUf('UF')
    ->setCidade('City');

Or, Simply:

$pagador = new \Eduardokum\LaravelBoleto\Pessoa([
    'documento' => '00.000.000/0000-00',
    'nome'      => 'Company co.',
    'cep'       => '00000-000',
    'endereco'  => 'Street name, 123',
    'bairro' => 'district',
    'uf'        => 'UF',
    'cidade'    => 'City',
]);

Attention

The Boleto requires an instance of Pagador.

Boleto

All banks have information that is shared such as:

logo:Path with logo image. [default: Without logo]
carteira:Bank contracts.
dataVencimento:Date the bill expires.
dataDesconto:Maximum date for granting the discount. [default: dataVencimento]
dataDocumento:Bill date. [default: today]
dataProcessamento:
 Creation date bill. [default: today]
desconto:Bill discount amount.
valor:Bill amount.
multa:Percentage of fee to be charged (per month). [default: false]
juros:Percentage of interest to be charged (per month). [default: false]
jurosApos:How many days after expired will be charged the interest. [default: 0]
diasProtesto:How many days after expired will be protested. [default: 0]
numero:Bill number. (Will be used to generate the Nosso Número)
numeroDocumento:
 Your internal bill number.
numeroControle:Any control that you may have, the same one sent will be returned in Retorno
descricaoDemonstrativo:
 Texts that will be shown in the bill Demonostrativo field.
instrucoes:Texts that will be shown in the bill Instruções ao caixa field.
instrucoesImpressao:
 Texts that will be shown at the top of the bill with instructions for printing or anything else you want to communicate.
aceite:If the bill is accepted by the customer. [default: N]
especieDoc:Kind of bill. (Usually DM - Duplicata Mercantil) [default: DM]
pagador:The Pagador.
beneficiario:The Beneficiário

Bancoob

This bank has the following mandatory fields:

numero:Bill number. (size: 7)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 5)
convenio:Number of agreement with the bank. (size: 6)

Available bank contracts:

1 Simples Com Registro
3 Garantida Caucionada
$bancoob = new Eduardokum\LaravelBoleto\Boleto\Banco\Bancoob;
$bancoob->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira(1)
    ->setAgencia(1111)
    ->setConvenio(1231237)
    ->setConta(22222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$bancoob->addDescricaoDemonstrativo('demonstrativo 4');
$bancoob->addInstrucoes('instrucao 2');

Or, Simply:

$bancoob = new Eduardokum\LaravelBoleto\Boleto\Banco\Bancoob([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 1,
    'agencia' => 1111,
    'convenio' => 123123,
    'conta' => 22222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Banrisul

This bank has the following mandatory fields:

numero:Bill number. (size: 8)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 5)

Available bank contracts:

1 Cobrança Simples
3 Cobrança Caucionada
4 Cobrança em IGPM
5 Cobrança Caucionada CGB Especial
6 Cobrança Simples Seguradora
7 Cobrança em UFIR
8 Cobrança em IDTR
C Cobrança Vinculada
D Cobrança CSB
E Cobrança Caucionada Câmbio
F Cobrança Vendor
H Cobrança Caucionada Dólar
I Cobrança Caucionada Compror
K Cobrança Simples INCC-M
M Cobrança Partilhada
N Capital de Giro CGB ICM
R Desconto de Duplicata
S Vendor Eletrônico – Valor Final (Corrigido)
X Vendor BDL – Valor Inicial (Valor da NF)
$banrisul = new Eduardokum\LaravelBoleto\Boleto\Banco\Banrisul;
$banrisul->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira(1)
    ->setAgencia(1111)
    ->setConta(22222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$banrisul->addDescricaoDemonstrativo('demonstrativo 4');
$banrisul->addInstrucoes('instrucao 2');

Or, Simply:

$banrisul = new Eduardokum\LaravelBoleto\Boleto\Banco\Banrisul([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 1,
    'agencia' => 1111,
    'conta' => 22222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Banco do Brasil

This bank has the following mandatory fields:

numero:

Bill number.

  • convenio 4 (size: 7)
  • convenio 6 (size: 5)
  • convenio 7 (size: 10)
agencia:

Account keeping agency. (size: 4)

conta:

Account number. (size: 8)

convenio:

Number of agreement with the bank. (size: 4, 6 and 7)

variacaoCarteira:
 

Bank contracts variation (size: 3)

Available bank contracts:

11 Cobrança com registro Simples
12 Cobrança com registro Indexada
15 Cobrança com registro Prêmios de Seguro
17 Cobrança com registro Direta Especial
18 Cobrança com registro Simples
31 Cobrança com registro Caucionada
51 Cobrança com registro Descontada
$bb = new Eduardokum\LaravelBoleto\Boleto\Banco\Bb;
$bb->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira(11)
    ->setAgencia(1111)
    ->setConvenio(1231237)
    ->setConta(22222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$bb->addDescricaoDemonstrativo('demonstrativo 4');
$bb->addInstrucoes('instrucao 2');

Or, Simply:

$bb = new Eduardokum\LaravelBoleto\Boleto\Banco\Bb([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 11,
    'agencia' => 1111,
    'convenio' => 1231237,
    'conta' => 22222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Banco do Nordeste

This bank has the following mandatory fields:

numero:Bill number. (size: 7)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 7)

Available bank contracts:

21 Cobrança Simples - Boleto Emitido Pelo Cliente
31 Cobrança Caucionada - Boleto Emitido Pelo Cliente
41 Cobrança Vinculada - Boleto Emitido Pelo Cliente
$bnb = new Eduardokum\LaravelBoleto\Boleto\Banco\Bnb;
$bnb->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira(21)
    ->setAgencia(1111)
    ->setConta(22222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$bnb->addDescricaoDemonstrativo('demonstrativo 4');
$bnb->addInstrucoes('instrucao 2');

Or, Simply:

$bnb = new Eduardokum\LaravelBoleto\Boleto\Banco\Bnb([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 21,
    'agencia' => 1111,
    'conta' => 22222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Bradesco

This bank has the following mandatory fields:

numero:Bill number. (size: 11)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 7)
cip:Code used to identify specific messages to the recipient. [default: 000] (size: 3)

Available bank contracts:

09 Com Registro
21 Com Registro - Pagável somente no Bradesco
26 Com Registro – Emissão na Internet
$bradesco = new Eduardokum\LaravelBoleto\Boleto\Banco\Bradesco;
$bradesco->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira('09')
    ->setAgencia(1111)
    ->setConta(2222222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$bradesco->addDescricaoDemonstrativo('demonstrativo 4');
$bradesco->addInstrucoes('instrucao 2');

Or, Simply:

$bradesco = new Eduardokum\LaravelBoleto\Boleto\Banco\Bradesco([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => '09',
    'agencia' => 1111,
    'conta' => 2222222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Caixa Econônica Federal

This bank has the following mandatory fields:

numero:Bill number. (size: 15)
agencia:Account keeping agency. (size: 4)
codigoCliente:Recipient number. (size: 6)

Available bank contracts:

RG Com Registro
$caixa = new Eduardokum\LaravelBoleto\Boleto\Banco\Caixa;
$caixa->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira('RG')
    ->setAgencia(1111)
    ->setCodigoCliente(222222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$caixa->addDescricaoDemonstrativo('demonstrativo 4');
$caixa->addInstrucoes('instrucao 2');

Or, Simply:

$caixa = new Eduardokum\LaravelBoleto\Boleto\Banco\Caixa([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 'RG',
    'agencia' => 1111,
    'codigoCliente' => 222222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

HSBC

This bank has the following mandatory fields:

numero:Bill number. (size: 5)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 6)
range:Range to start bill number. (size: 5)
contaDv:Account number verification code. (size: 1)

Available bank contracts:

CSB Carteira CSB
$hsbc = new Eduardokum\LaravelBoleto\Boleto\Banco\Hsbc;
$hsbc->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira('CSB')
    ->setAgencia(1111)
    ->setConta(222222)
    ->setContaDv(2)
    ->setRange(99999)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$hsbc->addDescricaoDemonstrativo('demonstrativo 4');
$hsbc->addInstrucoes('instrucao 2');

Or, Simply:

$hsbc = new Eduardokum\LaravelBoleto\Boleto\Banco\Hsbc([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 'CSB',
    'agencia' => 1111,
    'conta' => 222222,
    'contaDv' => 2,
    'range' => 99999,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Itaú

This bank has the following mandatory fields:

numero:Bill number. (size: 8)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 5)

Available bank contracts:

109 Direta Eletrônica Sem Emissão - Simples
110 Direta Eletrônica Sem Emissão - Simples
111 Direta Eletrônica Sem Emissão - Simples
112 Escritural Eletrônica - simples / contratual
115 Carteira 115
121 Direta Eletrônica Emissão Parcial - Simples/Contra
188 Carteira 188
180 Direta Eletrônica Emissão Integral
$itau = new Eduardokum\LaravelBoleto\Boleto\Banco\Itau;
$itau->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira(109)
    ->setAgencia(1111)
    ->setConta(22222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$itau->addDescricaoDemonstrativo('demonstrativo 4');
$itau->addInstrucoes('instrucao 2');

Or, Simply:

$itau = new Eduardokum\LaravelBoleto\Boleto\Banco\Itau([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 109,
    'agencia' => 1111,
    'conta' => 22222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Santander

This bank has the following mandatory fields:

numero:Bill number. (size: 12)
codigoCliente:Account number. (size: 7)

Available bank contracts:

101 Cobrança Simples
201 Penhor Rápida
$santander = new Eduardokum\LaravelBoleto\Boleto\Banco\Santander;
$santander->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira(101)
    ->setCodigoCliente(2222222)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$santander->addDescricaoDemonstrativo('demonstrativo 4');
$santander->addInstrucoes('instrucao 2');

Or, Simply:

$santander = new Eduardokum\LaravelBoleto\Boleto\Banco\Santander([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 101,
    'codigoCliente' => 2222222,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Sicredi

This bank has the following mandatory fields:

numero:Bill number. (size: 5)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 5)
codigoCliente:Customer/Beneficiary code with the banking institution. Generally, the customer code is the same as the account number without the check digit, but in cases such as changing an account between branches, that number changes. (size: 5)
byte:Byte of our Number Generation. (size: 1)
posto:Posto provided by the bank. (size: 2)

Available bank contracts:

1 Simples
2 Caucionada
3 Descontada
$sicredi = new Eduardokum\LaravelBoleto\Boleto\Banco\Sicredi;
$sicredi->setLogo('/path/to/logo.png')
    ->setDataVencimento('1997-10-07')
    ->setValor('100')
    ->setNumero(1)
    ->setNumeroDocumento(1)
    ->setPagador($pagador)
    ->setBeneficiario($beneficiario)
    ->setCarteira(1)
    ->setPosto(11)
    ->setByte(2)
    ->setAgencia(1111)
    ->setConta(22222)
    ->setCodigoCliente(12345)
    ->setDescricaoDemonstrativo(['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'])
    ->setInstrucoes(['instrucao 1', 'instrucao 2', 'instrucao 3']);

// You can add more ``Demonstrativos`` or ``Instrucoes`` on this way:

$sicredi->addDescricaoDemonstrativo('demonstrativo 4');
$sicredi->addInstrucoes('instrucao 2');

Or, Simply:

$sicredi = new Eduardokum\LaravelBoleto\Boleto\Banco\Sicredi([
    'logo' => '/path/to/logo.png',
    'dataVencimento' => '1997-10-07',
    'valor' => 100,
    'numero' => 1,
    'numeroDocumento' => 1,
    'pagador' => $pagador,
    'beneficiario' => $beneficiario,
    'carteira' => 1,
    'posto' => 11,
    'byte' => 2,
    'agencia' => 1111,
    'conta' => 22222,
    'codigoCliente' => 12345,
    'multa' => 1, // 1% do valor do boleto após o vencimento
    'juros' => 1, // 1% ao mês do valor do boleto
    'jurosApos' => 0 // quant. de dias para começar a cobrança de juros,
    'descricaoDemonstrativo' => ['demonstrativo 1', 'demonstrativo 2', 'demonstrativo 3'],
    'instrucoes' => ['instrucao 1', 'instrucao 2', 'instrucao 3'],
]);

Attention

To render this object see the Render session.

Render

There are 2 ways to render the bill

  1. In the Boleto object itself there are the renderPDF() and renderHTML() methods that render it individual.
  2. Instantiating a rendering class by adding the desired amount of tickets and calling the render() method;

See below the explanation of each one of them:

PDF

To render in PDF you first need a Boleto instance.

Render individually
$boleto->renderPDF($print = false, $instrucoes = true);

// This will generate a PDF string
$boleto->renderPDF();

// If you want to show a print window after rendering pass true on the first argument
$boleto->renderPDF(true);

// If you want to hide the print instructions pass false in the second argument
$boleto->renderPDF(false, false);
Render multiple
$pdf = new Eduardokum\LaravelBoleto\Boleto\Render\Pdf();

// Add as many bills as you want.
$pdf->addBoleto($boleto);

// Or, Simply
$pdf->addBoletos([
    $boleto1,
    $boleto2,
    $boleto3,
]);

// If you want to show a print window after rendering.
$pdf->showPrint();

// If you want to hide the print instructions.
$pdf->hideInstrucoes();

// To Render
$pdf->gerarBoleto($dest = self::OUTPUT_STANDARD, $save_path = null);

Options available for PDF destinations:

Pdf::OUTPUT_STANDARD Return a PDF with headers.
Pdf::OUTPUT_DOWNLOAD Force download.
Pdf::OUTPUT_SAVE Save PDF on disk, require a second parameter with a save_path.
Pdf::OUTPUT_STRING Return a PDF string.
HTML

To render in HTML you first need a Boleto instance.

Render individually
$boleto->renderHTML($print = false, $instrucoes = true);

// This will generate a HTML string.
$boleto->renderHTML();

// If you want to show a print window after rendering pass true on the first argument.
$boleto->renderHTML(true);

// If you want to hide the print instructions pass false in the second argument.
$boleto->renderHTML(false, false);
Render multiple
$html = new Eduardokum\LaravelBoleto\Boleto\Render\Html();

// Add as many bills as you want
$html->addBoleto($boleto);

// Or, Simply
$html->addBoletos([
    $boleto1,
    $boleto2,
    $boleto3,
]);

// If you want to show a print window after rendering.
$html->showPrint();

// If you want to hide the print instructions.
$html->hideInstrucoes();

// To Render, this will return a html string.
$html->gerarBoleto();

// Html also provides a ``carnê`` as a form of rendering.
$html->gerarCarne();

See also

API bill docs
Documentation for return objects.
Examples
Examples of use

Remessa

There are 2 types of Remessas: 240 positions and 400 positions.

Options available by bank:

Banco 240 400
Bancoob yes yes
Banrisul yes* yes
Banco do Brasil yes* yes
Banco do Nordeste no yes*
Bradesco yes* yes
Caixa Econônica Federal yes* yes
HSBC no yes
Itaú yes* yes
Santander yes* yes
Sicredi yes* yes

Note

* requires homologation

All banks have information that is shared such as:

carteira:Bank contracts.
beneficiario:The Beneficiário

All banks have the same methods for file generation. What changes are the fields required by each bank:

// Add a single bill to a send object. Here need a instance of Boleto.
$send->addBoleto(BoletoContract $detalhe);

// Add multiples bill to a send object. Here need a array of instances of Boleto.
$send->addBoletos(BoletoContract[] $boletos);

// Return a string of file.
// It depends on the instance, 240 or 400 positions.
$send->gerar();

// Saves the string to a file on the disk whose path was passed in $path argument.
$send->save($path);

// Force file download.
// If you pass the $filename argument it overwrites the name in the download.
$send->download($filename = null);

Bancoob

This bank has the following mandatory fields:

agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 8)
convenio:Number of agreement with the bank. (size: 7)
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bancoob;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bancoob;

$send->setBeneficiario($beneficiario)
    ->setCarteira(1)
    ->setAgencia(1111)
    ->setConvenio(123123)
    ->setConta(22222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'carteira' => 1,
    'agencia' => 1111,
    'convenio' => 123123,
    'conta' => 22222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bancoob($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bancoob($sendArray);

Attention

To generate the file see the Remessa session.

Banrisul

This bank has the following mandatory fields:

agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 5)
codigoCliente:Recipient number. (size: 13)
codigoClienteOfficeBanking:
 Recipient number. (size: 10) [required when Bank contract is ‘R’, ‘S’, ‘X’]
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Banrisul;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Banrisul;

$send->setBeneficiario($beneficiario)
    ->setCarteira(1)
    ->setAgencia(1111)
    ->setCodigoCliente(1234567)
    // ->setCodigoClienteOfficeBanking(1234567890)
    ->setConta(22222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'carteira' => 1,
    'agencia' => 1111,
    'codigoCliente' => 1234567,
    // 'codigoClienteOfficeBanking' => '1234567890',
    'conta' => 22222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Banrisul($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Banrisul($sendArray);

Attention

To generate the file see the Remessa session.

Banco do Brasil

This bank has the following mandatory fields:

agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 8)
convenio:Number of agreement with the bank. (size: 4, 6 and 7)
variacaoCarteira:
 Bank contracts variation (size: 3) [optional]
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bb;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bb;

$send->setBeneficiario($beneficiario)
    ->setCarteira(11)
    ->setAgencia(1111)
    ->setConvenio(1231237)
    // ->setVariacaoCarteira(017)
    ->setConta(22222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'carteira' => 11,
    'agencia' => 1111,
    'convenio' => 1231237,
    // 'variacaoCarteira' => '017',
    'conta' => 22222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bb($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bb($sendArray);

Attention

To generate the file see the Remessa session.

Banco do Nordeste

This bank has the following mandatory fields:

agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 7)
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bnb;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bnb;

$send->setBeneficiario($beneficiario)
    ->setCarteira(21)
    ->setAgencia(1111)
    ->setConta(22222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'carteira' => 21,
    'agencia' => 1111,
    'conta' => 22222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bnb($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bnb($sendArray);

Attention

To generate the file see the Remessa session.

Bradesco

This bank has the following mandatory fields:

idremessa:Sequence number of send. (size: 7)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 7)
codigoCliente:Recipient number. (size: 20). [optional, if not pass, The class will automatically generate]
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bradesco;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bradesco;

$send->setBeneficiario($beneficiario)
    ->setIdremessa(1)
    ->setCarteira('09')
    ->setAgencia(1111)
    ->setCodigoCliente('12345678901234567890')
    ->setConta(2222222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'idremessa' => 1,
    'carteira' => '09',
    'agencia' => 1111,
    'codigoCliente' => 12345678901234567890,
    'conta' => 2222222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Bradesco($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Bradesco($sendArray);

Attention

To generate the file see the Remessa session.

Caixa Econônica Federal

This bank has the following mandatory fields:

idremessa:Sequence number of send. (size: 5)
agencia:Account keeping agency. (size: 4)
codigoCliente:Recipient number. (size: 6)
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Caixa;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Caixa;

$send->setBeneficiario($beneficiario)
    ->setIdremessa(1)
    ->setCarteira('RG')
    ->setAgencia(1111)
    ->setCodigoCliente(222222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'idremessa' => 1,
    'carteira' => 'RG',
    'agencia' => 1111,
    'codigoCliente' => 222222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Caixa($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Caixa($sendArray);

Attention

To generate the file see the Remessa session.

HSBC

This bank has the following mandatory fields:

agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 6)
contaDv:Account number verification code. (size: 1)
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Hsbc;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Hsbc;

$send->setBeneficiario($beneficiario)
    ->setCarteira('CSB')
    ->setAgencia(1111)
    ->setConta(222222)
    ->setContaDv(2);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'carteira' => 'CSB',
    'agencia' => 1111,
    'conta' => 222222,
    'contaDv' => 2,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Hsbc($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Hsbc($sendArray);

Attention

To generate the file see the Remessa session.

Itaú

This bank has the following mandatory fields:

agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 5)
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Itau;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Itau;

$send->setBeneficiario($beneficiario)
    ->setCarteira(109)
    ->setAgencia(1111)
    ->setConta(22222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'carteira' => 109,
    'agencia' => 1111,
    'conta' => 22222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Itau($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Itau($sendArray);

Attention

To generate the file see the Remessa session.

Santander

This bank has the following mandatory fields:

agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 8)
codigoCliente:Account number. (size: 7)
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Santander;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Santander;

$send->setBeneficiario($beneficiario)
    ->setCarteira(101)
    ->setAgencia(1111)
    ->setCodigoCliente(2222222)
    ->setConta(22222222);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'carteira' => 101,
    'agencia' => 1111,
    'codigoCliente' => 2222222,
    'conta' => 22222222,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Santander($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Santander($sendArray);

Attention

To generate the file see the Remessa session.

Sicredi

This bank has the following mandatory fields:

idremessa:Sequence number of send. (size: 7)
agencia:Account keeping agency. (size: 4)
conta:Account number. (size: 5)
codigoCliente:Customer/Beneficiary code with the banking institution. Generally, the customer code is the same as the account number without the check digit, but in cases such as changing an account between branches, that number changes. (size: 5)
// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Sicredi;

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Sicredi;

$send->setBeneficiario($beneficiario)
    ->setIdremessa(1)
    ->setCarteira(1)
    ->setAgencia(1111)
    ->setConta(22222)
    ->setCodigoCliente(12345);

Or, Simply:

$sendArray = [
    'beneficiario' => $beneficiario,
    'idremessa' => 1,
    'carteira' => 1,
    'agencia' => 1111,
    'conta' => 22222,
    'codigoCliente' => 12345,
];

// for 400 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab400\Banco\Sicredi($sendArray);

// Or, for 240 positions
$send = new Eduardokum\LaravelBoleto\Cnab\Remessa\Cnab240\Banco\Sicredi($sendArray);

Attention

To generate the file see the Remessa session.

See also

API send docs
Documentation for return objects.
Examples
Examples of use

Retorno

There are 2 types of Retornos: 240 positions and 400 positions.

Options available by bank:

Banco 240 400
Bancoob yes yes
Banrisul yes* yes*
Banco do Brasil yes yes*
Banco do Nordeste no no
Bradesco yes yes*
Caixa Econônica Federal yes yes*
HSBC no yes
Itaú yes yes*
Santander yes yes
Sicredi yes* yes*

Note

* requires homologation

All banks have the same reading process. The constructor accepts as argument:

// File path
$argument = '/path/to/retorno.ret';

// Or, String content
$argument = '0RETORNOCONTENTHERE...\n1RETORNOCONTENTHERE...';

// Or, Array content
$argument = [
    '0RETORNOCONTENTHERE...',
    '1RETORNOCONTENTHERE...'
];

Factory

// The Factory will guess what the return if it is 240 or 400 and which bank and already return the instantiated object
$return = \Eduardokum\LaravelBoleto\Cnab\Retorno\Factory::make($argument);

// To process the file
$return->processar();

// You can know the type of bank after instantiate, using the methods respectively:
$return->getTipo();
$return->getCodigoBanco();

Bancoob

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Bancoob($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Bancoob($argument)

// To process the file
$return->processar();

Banrisul

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Banrisul($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Banrisul($argument)

 // To process the file
$return->processar();

Banco do Brasil

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Bb($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Bb($argument)

 // To process the file
$return->processar();

Banco do Nordeste

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Bnb($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Bnb($argument)

 // To process the file
$return->processar();

Bradesco

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Bradesco($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Bradesco($argument)

 // To process the file
$return->processar();

Caixa Econônica Federal

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Caixa($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Caixa($argument)

 // To process the file
$return->processar();

HSBC

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Hsbc($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Hsbc($argument)

 // To process the file
$return->processar();

Itaú

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Itau($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Itau($argument)

 // To process the file
$return->processar();

Santander

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Santander($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Santander($argument)

 // To process the file
$return->processar();

Sicredi

// 400 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab400\Banco\Sicredi($argument)

// 240 positions
$return = new \Eduardokum\LaravelBoleto\Cnab\Retorno\Cnab240\Banco\Sicredi($argument)

 // To process the file
$return->processar();

Dealing with the return

In return of 400 positions the object of the bank has the following methods:

// This will return a iterable object, with all returns
$return->getDetalhes();
// This will return a object with information
$return->getHeader();
// This will return a object with totals information
$return->getTrailer();

 // To iterate do:
foreach($return->getDetalhes() as $object) {
    var_dump($object->toArray());
}

In return of 240 positions the object of the bank has the following methods:

// This will return a iterable object, with all returns
$return->getDetalhes();
// This will return a object with information
$return->getHeader();
// This will return a object with information by lote
$return->getHeaderLote();
// This will return a object with totals information
$return->getTrailer();
// This will return a object with totals information by lote
$return->getTrailerLote();

// To iterate do:
foreach($return->getDetalhes() as $object) {
    var_dump($object->toArray());
}

The return object implements SeekableIterator, so you can do a foreach on the object that will iterate for each return:

foreach($return as $object) {
    var_dump($object->toArray());
}

See also

API return docs
Documentation for return objects.
Examples
Examples of use

Utilities

isCnab240

Test if a content is a cnab 240 positions valid.

Util::isCnab240($content)

isCnab400

Test if a content is a cnab 400 positions valid.

Util::isCnab400($content)

IPTE2CodigoBarras

Converts a digitable line from the bill to the string that generates the bar code

Util::IPTE2CodigoBarras($ipte)

IPTE2Variveis

It parses the bill’s digitable line, extracting the contained variables

Util::IPTE2Variveis($ipte)

array2Controle

Converts an array to a control string that can be passed in the bill.

Util::array2Controle(array $array)
// Example
$array = [
    'A' => 47885,
    'B' => 212,
    'C' => 9598,
];
Util::array2Controle($array);
// will return
A47885B212C9598

controle2array

It parses the bill’s digitable line, extracting the contained variables

Util::controle2array($control)
// Example
Util::controle2array('A47885B212C9598')
// will return
[
    'A' => 47885,
    'B' => 212,
    'C' => 9598,
]

fatorVencimento

Converts a date to the expiration factor

Util::fatorVencimento($date, $format = 'Y-m-d')
// Example
Util::fatorVencimento('2018-01-01')
// will return
7391

fatorVencimentoBack

Converts an expiration factor to the corresponding date.

Util::fatorVencimentoBack($factor, $format = 'Y-m-d')
// Example
Util::fatorVencimentoBack('7391')
// will return
'2018-01-01'

// or
Util::fatorVencimentoBack('7391', false)
// will return a instance of Carbon.
Carbon\Carbon Object
(
    [date] => 2018-01-01 00:00:00.000000
    [timezone_type] => 3
    [timezone] => America/Sao_Paulo
)

License

Laravel Boleto is free software distributed under the terms of the MIT license.

Contributing

Support follows PSR-1 and PSR-4 PHP coding standards. Additionally the source code follows the PSR-2 code style and the builds check it.

Please report any issue you find in the issues page.

Pull requests are always welcome.

Warning

All PR’s must be made to the branch develop, and later to be incorporated into the branch master.

Support

The easiest way to get help with the project is to join the @laravelBoleto channel on Telegram. We hang out there and you can get real-time help with your projects. The other good way is to open an issue on Github.

Support for latest stable version of php only.

The mailing list at GoogleGroups. is also available for support.