1. Go to this page and download the library: Download matfatjoe/api-santander 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/ */
use Matfatjoe\SantanderBoleto\Auth\Authenticator;
use Matfatjoe\SantanderBoleto\Auth\TokenRequest;
use Matfatjoe\SantanderBoleto\HttpClientFactory;
$tokenRequest = new TokenRequest($pfxPath, $passphrase, $clientId, $clientSecret);
$httpClient = HttpClientFactory::createFromTokenRequest($tokenRequest);
$authenticator = new Authenticator($httpClient, $baseUrl);
$token = $authenticator->getToken($tokenRequest);
use Matfatjoe\SantanderBoleto\Workspace\WorkspaceService;
use Matfatjoe\SantanderBoleto\Workspace\CreateWorkspaceRequest;
use Matfatjoe\SantanderBoleto\Models\Covenant;
$workspaceService = new WorkspaceService($httpClient, $token, $clientId, $baseUrl);
$request = new CreateWorkspaceRequest(
'BILLING',
[new Covenant('3567206')],
'Meu Workspace',
true, // Webhook boleto ativo
true, // Webhook PIX ativo
'https://meu-site.com/webhook'
);
$workspace = $workspaceService->create($request);
echo "Workspace criado: " . $workspace->getId();
use Matfatjoe\SantanderBoleto\Boleto\BoletoService;
use Matfatjoe\SantanderBoleto\Boleto\RegisterBoletoRequest;
use Matfatjoe\SantanderBoleto\Models\Boleto;
use Matfatjoe\SantanderBoleto\Models\Payer;
use Matfatjoe\SantanderBoleto\Models\Beneficiary;
$boletoService = new BoletoService($httpClient, $token, $clientId, $baseUrl);
$payer = new Payer(
'João da Silva',
'CPF',
'12345678901',
'Rua das Flores, 123',
'Centro',
'São Paulo',
'SP',
'01234-567'
);
$beneficiary = new Beneficiary(
'Minha Empresa LTDA',
'CNPJ',
'12345678000199'
);
$boleto = new Boleto(
'TESTE',
'1014',
date('Y-m-d'),
'3567206',
'000001',
'CLI-001',
date('Y-m-d', strtotime('+7 days')),
date('Y-m-d'),
'VENDA-001',
'150.00',
$payer,
$beneficiary
);
$registeredBoleto = $boletoService->register($workspaceId, new RegisterBoletoRequest($boleto));
echo "Código de Barras: " . $registeredBoleto->getBarcode();
use Matfatjoe\SantanderBoleto\Query\QueryService;
$queryService = new QueryService($httpClient, $token, $clientId, $baseUrl);
// Por Nosso Número
$boleto = $queryService->queryByBankNumber('3567206', '000001', 'default');
// Por Seu Número
$boleto = $queryService->queryByClientNumber('3567206', 'CLI-001', '2024-01-01', '150.00');
// SONDA (confirma registro - até D+2)
$boleto = $queryService->querySonda($workspaceId, '1014', '2024-01-01', 'TESTE', '3567206', '000001');
bash
docker-compose run --rm php vendor/bin/phpunit --testdox
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.