Instalação via Composer
composer require ledat/nfeio-client
Para usar a biblioteca, use o Composer autoload:
require_once('vendor/autoload.php');
Observação: A versão do PHP deverá ser 5.6 ou superior.
use nfeio\NFeio;
use nfeio\v1\Company;
require_once('vendor/autoload.php');
NFeio::init('YOUR API KEY'); // sua chave de API
$company = new Company([
'name' => 'BANCO DO BRASIL SA',
'tradeName' => 'BANCO DO BRASIL',
'federalTaxNumber' => '00000000000191',
'email' => '[email protected]',
'address' => [
'country' => 'BRA',
'postalCode' => '70040912',
'street' => 'Quadra SAUN',
'number' => 'S/N',
'additionalInformation' => 'Quadra 5 Lote B',
'district' => 'Asa Norte',
'city' => [
'code' => '5300108',
'name' => 'Brasilia',
],
'state' => 'DF',
],
'openningDate' => '1966-08-01',
]);
$company->create();
echo $company->id;
use nfeio\NFeio;
use nfeio\v1\Company;
require_once('vendor/autoload.php');
NFeio::init('YOUR API KEY');
$company = Company::find('COMPANY ID');
$company->upload('/path/to/cert.pfx', 'CERTIFICATE PASSWORD');
use nfeio\NFeio;
use nfeio\v1\Company;
use nfeio\v1\ServiceInvoice;
require_once('vendor/autoload.php');
NFeio::init('YOUR API KEY');
$company = Company::find('COMPANY ID');
$invoice = new ServiceInvoice($company, [
'borrower' => [
'name' => 'BANCO DO BRASIL SA',
'federalTaxNumber' => '00000000000191',
'email' => '[email protected]',
'address' => [
'country' => 'BRA',
'postalCode' => '70040912',
'street' => 'Quadra SAUN',
'number' => 'S/N',
'additionalInformation' => 'Quadra 5 Lote B',
'district' => 'Asa Norte',
'city' => [
'code' => '5300108',
'name' => 'Brasilia',
],
'state' => 'DF',
],
],
'cityServiceCode' => '2690',
'description' => 'TESTE EMISSAO',
'servicesAmount' => 0.01,
]);
$invoice->create();
echo $invoice->id;
use nfeio\NFeio;
use nfeio\v1\Company;
use nfeio\v1\ServiceInvoice;
require_once('vendor/autoload.php');
NFeio::init('YOUR API KEY');
$company = Company::find('COMPANY ID');
$invoice = ServiceInvoice::find($company, 'NFSE ID');
$pdf = $invoice->pdf();
$xml = $invoice->xml();
file_put_contents('./invoice.pdf', $pdf);
file_put_contents('./invoice.xml', $xml);
use nfeio\NFeio;
use nfeio\v1\Company;
use nfeio\v1\ServiceInvoice;
require_once('vendor/autoload.php');
NFeio::init('YOUR API KEY');
$company = Company::find('COMPANY ID');
$invoice = ServiceInvoice::find($company, 'NFSE ID');
if ($invoice->status == 'Issued') {
$invoice->delete();
}