PHP code example of quantumtecnology / falcon-fiscalhub-sdk
1. Go to this page and download the library: Download quantumtecnology/falcon-fiscalhub-sdk 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/ */
quantumtecnology / falcon-fiscalhub-sdk example snippets
use QuantumTecnology\FalconFiscalHub\FiscalHubClient;
use QuantumTecnology\FalconFiscalHub\FiscalHubConfig;
$fiscal = new FiscalHubClient(FiscalHubConfig::make(
'https://fiscal.falcon-server.com.br', // URL da API — vem da SUA config
'ffx_abc12345_...', // chave criada no painel
));
// Uma vez: qual natureza usar (guarde o id na sua config).
$perfis = $fiscal->natureOperations()->nfseProfiles();
// Tomador: acha pelo documento ou cadastra. Opcional — sem tomador a nota sai
// com "tomador não identificado", como o leiaute nacional permite.
$tomador = $fiscal->persons()->findOrCreate([
'type' => 'pf',
'cpf' => '12345678901',
'razao_social' => 'Ana Silva',
]);
$nota = $fiscal->nfse()->emit([
'nature_operation_id' => $naturezaId,
'recipient_person_id' => $tomador['id'],
'external_reference' => 'pedido-123', // ⭐ idempotência
'service' => ['valor_servicos' => 49.90],
]);
$nota->data['status']['value']; // authorized
$nota->data['number'];
$pdf = $fiscal->nfse()->pdf($notaId); // bytes do DANFSe
$xml = $fiscal->nfse()->xml($notaId);
$fiscal->nfse()->find($notaId);
$fiscal->nfse()->events($notaId); // linha do tempo (inclui motivos de rejeição)
$fiscal->nfse()->cancel($notaId, 'Serviço não prestado.');
// Listagem paginada: a paginação vem em ->meta
$pagina = $fiscal->nfse()->list(['page' => 2, 'filter' => ['status' => 'authorized']]);
$pagina->meta['total'];
use QuantumTecnology\FalconFiscalHub\Exceptions\FiscalRejectionException;
try {
$fiscal->nfse()->emit($payload);
} catch (FiscalRejectionException $e) {
$e->getMessage(); // motivo do fisco
$e->getInvoiceId(); // a nota rejeitada, para corrigir e retransmitir
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.