PHPackages                             matfatjoe/bradesco-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. matfatjoe/bradesco-api

ActiveLibrary[Payment Processing](/categories/payments)

matfatjoe/bradesco-api
======================

Library for Bradesco Boleto Emission

1.0.1(3mo ago)00MITPHPPHP ^7.4|^8.0

Since Jan 30Pushed 1mo agoCompare

[ Source](https://github.com/matfatjoe/bradesco-api)[ Packagist](https://packagist.org/packages/matfatjoe/bradesco-api)[ RSS](/packages/matfatjoe-bradesco-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Bradesco Boleto API - PHP Library
=================================

[](#bradesco-boleto-api---php-library)

[![PHP Version](https://camo.githubusercontent.com/204b1791e3a57f86a93de1422b2a6e584f5045431629c5b9abd4e28dbc8b5357/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e342d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Biblioteca PHP para integração com a API de Cobrança do Bradesco, permitindo o gerenciamento completo de boletos bancários e workspaces.

📋 Índice
--------

[](#-índice)

- [Características](#-caracter%C3%ADsticas)
- [Requisitos](#-requisitos)
- [Instalação](#-instala%C3%A7%C3%A3o)
- [Configuração](#-configura%C3%A7%C3%A3o)
- [Uso Básico](#-uso-b%C3%A1sico)
- [Módulos](#-m%C3%B3dulos)
- [Exemplos](#-exemplos)
- [Testes](#-testes)
- [Documentação da API](#-documenta%C3%A7%C3%A3o-da-api)
- [Contribuindo](#-contribuindo)
- [Licença](#-licen%C3%A7a)

✨ Características
-----------------

[](#-características)

- ✅ **Autenticação mTLS** - Suporte completo a certificados digitais
- ✅ **Registro de Boletos** - Emissão de boletos híbridos com QR Code
- ✅ **Alteração de Boletos** - Modificação de dados de boletos já registrados
- ✅ **Baixa de Boletos** - Solicitação de baixa de títulos
- ✅ **Consultas** - Consulta de boletos por nosso número
- ✅ **Listagem** - Lista de boletos liquidados com filtros
- ✅ **Reserva de Location** - Reserva de ID Location para QR Code
- ✅ **Webhooks** - Cadastro e gerenciamento de webhooks
- ✅ **PSR-4 Autoloading** - Estrutura moderna e organizada
- ✅ **Type Hints** - Código fortemente tipado para PHP 7.4+

📦 Requisitos
------------

[](#-requisitos)

- PHP &gt;= 7.4
- Composer
- Extensões PHP:
    - `ext-json`
    - `ext-openssl`
    - `ext-curl`
- Certificado digital PFX do Bradesco
- Credenciais da API (Client ID e Client Secret)

🚀 Instalação
------------

[](#-instalação)

```
composer require matfatjoe/bradesco-api
```

Ou clone o repositório:

```
git clone https://github.com/matfatjoe/bradesco-api.git
cd bradesco-api
composer install
```

⚙️ Configuração
---------------

[](#️-configuração)

### 1. Certificado Digital

[](#1-certificado-digital)

Coloque seu certificado `.pfx` no diretório do projeto e configure as credenciais:

```
$certPath = __DIR__ . '/certificate.pem';
$keyPath = __DIR__ . '/private.key';
$clientId = 'seu_client_id';
$clientSecret = 'seu_client_secret';
```

### 2. Ambiente

[](#2-ambiente)

```
// Sandbox (Testes)
$baseUrl = 'https://openapisandbox.prebanco.com.br';

// Produção
$baseUrl = 'https://openapi.bradesco.com.br';
```

💡 Uso Básico
------------

[](#-uso-básico)

### Autenticação

[](#autenticação)

```
use Matfatjoe\BradescoBoleto\Auth\Authenticator;
use Matfatjoe\BradescoBoleto\Auth\TokenRequest;
use Matfatjoe\BradescoBoleto\HttpClientFactory;

$tokenRequest = new TokenRequest($certPath, $keyPath, $clientId, $clientSecret);
$httpClient = HttpClientFactory::create();
$authenticator = new Authenticator($httpClient, $baseUrl);
$token = $authenticator->getToken($tokenRequest);
```

### Registrar Boleto

[](#registrar-boleto)

```
use Matfatjoe\BradescoBoleto\Boleto\BoletoService;
use Matfatjoe\BradescoBoleto\Boleto\RegisterBoletoBradescoRequest;
use Matfatjoe\BradescoBoleto\Models\BoletoBradesco;

$boletoService = new BoletoService($httpClient, $token, $certPath, $keyPath, $baseUrl);

$dadosBoleto = [
    'ctitloCobrCdent' => 0,
    'registrarTitulo' => 1,
    'nroCpfCnpjBenef' => 68542653,
    'codUsuario' => 'APISERVIC',
    'filCpfCnpjBenef' => '1018',
    'tipoAcesso' => 2,
    'digCpfCnpjBenef' => 38,
    'cidtfdProdCobr' => 9,
    'cnegocCobr' => 111111111111111111,
    'tipoRegistro' => 1,
    'codigoBanco' => 237,
    'demisTitloCobr' => '17.12.2024',
    'ctitloCliCdent' => 'TESTEBIA',
    'dvctoTitloCobr' => '20.02.2025',
    'vnmnalTitloCobr' => 6000,
    'cindcdEconmMoeda' => 9,
    'cespceTitloCobr' => 2,
    'cindcdAceitSacdo' => 'N',
    'cindcdPgtoParcial' => 'N',
    'cformaEmisPplta' => '02',
    'fase' => '1',
    'cindcdCobrMisto' => 'S',
    'isacdoTitloCobr' => 'TESTE EMPRESA PGIT',
    'enroLogdrSacdo' => 'TESTE',
    'elogdrSacdoTitlo' => 'TESTE',
    'ecomplLogdrSacdo' => 'TESTE',
    'ccepSacdoTitlo' => 6332,
    'ebairoLogdrSacdo' => 'TESTE',
    'ccomplCepSacdo' => 130,
    'imunSacdoTitlo' => 'TESTE',
    'indCpfCnpjSacdo' => 1,
    'csglUfSacdo' => 'SP',
    'nroCpfCnpjSacdo' => 38453450803
];

$boleto = new BoletoBradesco($dadosBoleto);
$resultado = $boletoService->register(new RegisterBoletoBradescoRequest($boleto));
```

### Consultar Boleto

[](#consultar-boleto)

```
use Matfatjoe\BradescoBoleto\Query\QueryService;

$queryService = new QueryService($httpClient, $token, $certPath, $keyPath, $baseUrl);

$dadosConsulta = [
    'contaProduto' => 38610041000,
    'controleCpfCnpjUsuario' => 38,
    'cpfCnpjUsuario' => 68542653,
    'filialCnpjUsuario' => 1018,
    'idProduto' => 9,
    'nomePersonalizado' => '',
    'nossoNumero' => 970039324,
    'seqTitulo' => 0,
    'status' => 0
];

$boleto = $queryService->consultar($dadosConsulta);
```

### Alterar Boleto

[](#alterar-boleto)

```
$dadosAlteracao = [
    'codUsuario' => 'NETEMPR',
    'vnmnalTitloCobr' => 655,
    'chave' => [
        'cnpjCpf' => 38052160,
        'filial' => 57,
        'controle' => '01',
        'idprod' => 9,
        'ctaprod' => 39950075557,
        'nossoNumero' => '2570068544'
    ],
    'dadosTitulo' => [
        'seuNumero' => 'JFM ALT 1010',
        'dataVencimento' => 22122024,
        // ... outros campos
    ]
];

$resultado = $boletoService->alterar($dadosAlteracao, '20241122237093995007555702570068544');
```

### Baixar Boleto

[](#baixar-boleto)

```
$dadosBaixa = [
    'cpfCnpj' => [
        'cpfCnpj' => '1234567',
        'filial' => '1',
        'controle' => '99'
    ],
    'produto' => 9,
    'negociacao' => 28560222654,
    'nossoNumero' => '50150001462',
    'sequencia' => 0,
    'codigoBaixa' => 57
];

$resultado = $boletoService->baixar($dadosBaixa);

### Listar Boletos Liquidados

```php
use Matfatjoe\BradescoBoleto\Boleto\ListSettledBoletosBradescoRequest;

$request = new ListSettledBoletosBradescoRequest([
    'cpfCnpj' => [
        'cpfCnpj' => 114383908,
        'filial' => 0,
        'controle' => 7
    ],
    'produto' => 9,
    'negociacao' => 28560230114,
    'dataPagamentoDe' => 14092017,
    'dataPagamentoAte' => 15092025
]);

$boletos = $boletoService->listarLiquidados($request);
```

```

### Listar Boletos Liquidados

```php
$filtros = [
    'cpfCnpj' => [
        'cpfCnpj' => 114383908,
        'filial' => 0,
        'controle' => 7
    ],
    'produto' => 9,
    'negociacao' => 28560230114,
    'dataPagamentoDe' => 14092017,
    'dataPagamentoAte' => 15092025
];

$boletos = $queryService->listar($filtros);

```

### Reservar ID Location

[](#reservar-id-location)

```
use Matfatjoe\BradescoBoleto\Location\LocationService;

$locationService = new LocationService($httpClient, $token, $certPath, $keyPath, $baseUrl);

$dadosReserva = [
    'codUsuario' => 'APISERVIC',
    'cnpjCpfBnf' => 68542653,
    'cflialCnpjCpfBnf' => 1018,
    'cctrlCnpjCpfBnf' => 38,
    'cidtfdProdCobr' => 9,
    'agenciaCobr' => 3861,
    'contaCobr' => 41000
];

$location = $locationService->reservar($dadosReserva);
```

### Cadastrar Webhook

[](#cadastrar-webhook)

```
use Matfatjoe\BradescoBoleto\Webhook\WebhookService;

$webhookService = new WebhookService($httpClient, $token, $certPath, $keyPath, $baseUrl);

$dadosWebhook = [
    'documento' => [
        'cpfCnpj' => '1234567',
        'filial' => '1',
        'controle' => '99'
    ],
    'versaoLayout' => '1',
    'tipoCadastro' => 'C',
    'utilizaWebhook' => 'S',
    'urlEnvio' => 'http://empresa.com.br',
    'tipoAviso' => '1'
];

$resultado = $webhookService->cadastrar($dadosWebhook);
```

📚 Módulos
---------

[](#-módulos)

### 🔐 Auth Module

[](#-auth-module)

- `Authenticator` - Autenticação mTLS
- `TokenRequest` - Requisição de token
- `HttpClientFactory` - Cliente HTTP configurado

### 📄 Boleto Module

[](#-boleto-module)

- `BoletoService` - Registro, alteração, baixa e listagem de liquidados
- `RegisterBoletoBradescoRequest` - Request para registro
- `ListSettledBoletosBradescoRequest` - Request para listagem de liquidados
- `BoletoBradesco` - Model de boleto do Bradesco

### 🔍 Query Module

[](#-query-module)

- `QueryService` - Consultas e listagem de boletos
- Métodos: consultar por nosso número, listar liquidados

### 📍 Location Module

[](#-location-module)

- `LocationService` - Reserva de ID Location para QR Code

### 🔔 Webhook Module

[](#-webhook-module)

- `WebhookService` - Cadastro e gerenciamento de webhooks

📖 Exemplos
----------

[](#-exemplos)

Veja a pasta `examples/` para exemplos completos (a ser criada):

- `example-auth.php` - Autenticação
- `example-workspace.php` - Gerenciamento de workspaces
- `example-boleto.php` - Registro de boletos
- `list_settled_boletos.php` - Listagem de liquidados
- `example-query.php` - Consultas

🧪 Testes
--------

[](#-testes)

Execute os testes unitários:

```
composer test
```

Ou com Docker:

```
docker-compose run --rm php vendor/bin/phpunit --testdox
```

📘 Documentação da API
---------------------

[](#-documentação-da-api)

- [Portal do Desenvolvedor Bradesco](https://developers.bradesco.com.br/)

🤝 Contribuindo
--------------

[](#-contribuindo)

Contribuições são bem-vindas! Por favor:

1. Fork o projeto
2. Crie uma branch para sua feature (`git checkout -b feature/MinhaFeature`)
3. Commit suas mudanças (`git commit -m 'Add: Minha nova feature'`)
4. Push para a branch (`git push origin feature/MinhaFeature`)
5. Abra um Pull Request

📝 Licença
---------

[](#-licença)

Este projeto está sob a licença MIT. Veja o arquivo [LICENSE](LICENSE) para mais detalhes.

🆘 Suporte
---------

[](#-suporte)

- 🐛 Issues: [GitHub Issues](https://github.com/matfatjoe/bradesco-api/issues)

---

**Desenvolvido por [Matheus Furquim de Camargo](https://github.com/matfatjoe)**

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance92

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

2

Last Release

92d ago

PHP version history (2 changes)1.0.0PHP ^7.4

1.0.1PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/35349edc0be58383ba4e73e66262342586bcfbecdf38bc40fe8ae8cf860e3e03?d=identicon)[matfatjoe](/maintainers/matfatjoe)

---

Top Contributors

[![matfatjoe](https://avatars.githubusercontent.com/u/38146311?v=4)](https://github.com/matfatjoe "matfatjoe (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/matfatjoe-bradesco-api/health.svg)

```
[![Health](https://phpackages.com/badges/matfatjoe-bradesco-api/health.svg)](https://phpackages.com/packages/matfatjoe-bradesco-api)
```

###  Alternatives

[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M9](/packages/chargebee-chargebee-php)[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k8](/packages/buckaroo-sdk)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
