keercus/bling-notafiscal

连接到 Bling ERP 的客户端

v1.0.4 2018-10-02 18:11 UTC

This package is not auto-updated.

Last update: 2024-09-15 23:37:52 UTC


README

该库旨在与 Bling ERP 通信,以发送产品和生成发票。

Bling 文档

要访问,请点击 这里

示例

搜索发票数据

require __DIR__ . '/vendor/autoload.php';

$bling = new \Bling\NotaFiscal\Bling('sua-api-key');
$nota = $bling->buscaNotaFiscal('numero-nota', 'serie'); // Retorna NotaFiscal()

echo $nota->getChaveAcesso();

发送发票数据

require_once __DIR__ . '/vendor/autoload.php';

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',
        'teste@teste.com',
        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);

发票对象

在发送新的发票或搜索任何发票时,将返回一个包含以下信息的 NotaFiscal 实体

  • 访问密钥
  • XML 链接
  • 丹尼尔链接
  • 发票号
  • 系列号
  • 状态