mangati / sicoob-sdk
v1.0.0
2023-12-13 15:45 UTC
Requires
- php: >=8.1
- phpdocumentor/reflection-docblock: ^5.3
- symfony/http-client: ^5.3|^6.0
- symfony/property-access: ^6.1
- symfony/serializer: ^6.1
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- slevomat/coding-standard: ^8.14
- squizlabs/php_codesniffer: ^3.8
README
Configuração
use Mangati\Sicoob\SicoobClient; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\HttpOptions;; $localCert = "path/to/cert.pem"; $localPk = "path/to/cert.key"; $options = new HttpOptions(); $options ->setLocalCert($localCert) ->setLocalPk($localPk); $client = HttpClient::create( defaultOptions: $options->toArray(), ); // pix $sicoob = new SicoobPixClient($client); // boleto $sicoob = new SicoobCobrancaBancariaClient($client); // conta corrente $sicoob = new SicoobContaCorrenteClient($client);
Autenticação
Production:
use Mangati\Sicoob\Dto\TokenRequest; use Mangati\Sicoob\Types\TokenScope; $response = $sicoob->token(new TokenRequest( clientId: $clientId, scopes: [ TokenScope::COBRANCA_BOLETOS_INCLUIR ], )); print_r($response); // output: // // Mangati\Sicoob\Dto\TokenResponse Object // ( // [token] => Mangati\Sicoob\Dto\AuthenticationToken Object // ( // [clientId] => <client_id> // [tokenType] => Bearer // [accessToken] => <generated_token> // [expiresIn] => 300 // [refreshExpiresIn] => 0 // [scopes] => Array // ( // [0] => Mangati\Sicoob\Types\TokenScope Enum:string // ( // [name] => COBRANCA_BOLETOS_INCLUIR // [value] => cobranca_boletos_incluir // ) // ) // ) // )
Sandbox:
use Mangati\Sicoob\SicoobCobrancaBancariaClient; use Mangati\Sicoob\Dto\AuthenticationToken; /** @var AuthenticationToken */ $token = SicoobCobrancaBancariaClient::sandboxToken(); // then $sicoob = new SicoobCobrancaBancariaClient($client, isSandbox: true);
Cobrança Bancária - Boleto
use Mangati\Sicoob\Dto\CobrancaBancaria\IncluirBoletosRequest; use Mangati\Sicoob\Model\CobrancaBancaria\Boleto; $boleto = new Boleto(); $response = $sicoob->incluirBoletos($authToken, new IncluirBoletosRequest( boletos: [ $boleto ], )); $resultado = $response->resultado[0]; if ($resultado->status->codigo !== 200) { throw new \Exception($resultado->status->mensagem); } $base64Data = $resultado->boleto->pdfBoleto; $nossoNumero = $resultado->boleto->nossoNumero;