PHP code example of keercus / bling-notafiscal
1. Go to this page and download the library: Download keercus/bling-notafiscal 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/ */
keercus / bling-notafiscal example snippets
$bling = new \Bling\NotaFiscal\Bling('sua-api-key');
$nota = $bling->buscaNotaFiscal('numero-nota', 'serie'); // Retorna NotaFiscal()
echo $nota->getChaveAcesso();
use Bling\NotaFiscal\Entity\Cliente;
use Bling\NotaFiscal\Entity\Endereco;
use Bling\NotaFiscal\Entity\Item;
use Bling\NotaFiscal\Entity\Pedido;
function generateCliente(): Cliente
{
return new Cliente(
'Teste',
Cliente::TIPO_FISICA,
'12345678911',
'12345678',
'[email protected] ',
generateEndereco()
);
}
function generateEndereco(): Endereco
{
return new Endereco('Teste', '123', 'Teste Complemento', 'Teste Bairro', '12345789', 'Teste Cidade', 'TS');
}
function generateItem(): Item
{
return new Item('123', 'Nome do produto', 10.00, 1.123, 1.123, '4820.1000', 1, '0', 'un', Item::TIPO_PRODUTO);
}
function generatePedido(): Pedido
{
return new Pedido('002', generateCliente(), [generateItem()], 0, [], 0, 0, 0, '');
}
$apiKey = 'sua-api-key';
$bling = new Bling\NotaFiscal\Bling($apiKey);
$response = $bling->enviaNotaFiscal(generatePedido());
var_dump($response);