1. Go to this page and download the library: Download dindigital/nfe-focus 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/ */
dindigital / nfe-focus example snippets
$issuer = new Issuer;
$issuer->setCompanyDocument('11112332000110'); // CNPJ
$issuer->setCompanyName('DIN DIGITAL WEB LTDA ME'); // Razão Social
$issuer->setTradingName('DIN DIGITAL'); // Nome Fantasia
$issuer->setStateRegistration('1234567890'); // Inscrição Estadual
$issuerAddress = new Address;
$issuerAddress->setStreet('Rua Bernardino de Campos');
$issuerAddress->setNumber('31, Sala 501');
$issuerAddress->setNeighborhood('Centro');
$issuerAddress->setCity('Santo André');
$issuerAddress->setState('SP');
$issuerAddress->setZipCode('09015-010');
// Adiciono endereço do vendedor ao vendedor
$issuer->setAddress($issuerAddress);
$receiver = new Receiver;
$receiver->setDocument('446.441.646-23'); // CPF ou CNPJ
$receiver->setName('Mário Mello'); // Nome
$receiver->setEmail('[email protected]'); // E-mail
$receiverAddress = new Address;
$receiverAddress->setStreet('Rua Havana');
$receiverAddress->setNumber('217');
$receiverAddress->setNeighborhood('Parque das Américas');
$receiverAddress->setCity('Mauá');
$receiverAddress->setState('SP');
$receiverAddress->setZipCode('09351-020');
// Adiciono endereço do vendedor ao vendedor
$receiver->setAddress($receiverAddress);
$product1 = new Item;
$product1->setDescription('Produto 1');
$product1->setQuantity('1');
$product1->setCost('300');
$product1->setNcmCode('33030020');
// Defino o container de produtos
$items = new ItemContainer($receiver);
$items->addItem($product1);
$nfse = new Nfse(
new DateTime("2015-03-23 12:00:00"), // data da venda
$issuer, // vendedor
$receiver, // cliente
$items // container de produtos
);
$transaction = new InsertTransaction(Enviroment::DEVELOPMENT, 'token');
if ($transaction->insert($nfse, 'referencia')) { // OK
//$transaction->getResponseBody();
} else { // erro
//$transaction->getResponseBody();
}
$transaction = new FindTransaction(Enviroment::DEVELOPMENT, 'token');
if ($transaction->find('referencia')) { // OK
//$transaction->getResponseBody();
} else { // erro
//$transaction->getResponseBody();
}
$transaction = new CancelTransaction(Enviroment::DEVELOPMENT, 'token');
$transaction->setJustification('Modtivo do cancelamento');
if ($transaction->cancel('referencia')) { // OK
//$transaction->getResponseBody();
} else { // erro
//$transaction->getResponseBody();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.