Esempio n. 1
0
File: gerar.php Progetto: phpnfe/nfe
$nfe->transp->transporta->IE = 'ISENTO';
$nfe->transp->transporta->xEnder = 'RUA TESTE, 278, 278 - BAIRRO TESTE';
$nfe->transp->transporta->xMun = 'GOVERNADOR CELSO RAMOS';
$nfe->transp->transporta->UF = 'SC';
$nfe->transp->vol->qVol = '1';
$nfe->transp->vol->esp = 'UNIDADE';
$nfe->transp->vol->marca = '-';
$nfe->transp->vol->nVol = '000003';
$nfe->transp->vol->pesoL = 1.0;
$nfe->transp->vol->pesoB = 1.0;
// Cobr
$nfe->cobr->fat->nFat = '000003';
$nfe->cobr->fat->vOrig = 133.2;
$nfe->cobr->fat->vLiq = 133.2;
$nfe->cobr->dup->add($item = new \PhpNFe\NFe\Builder\Cobr\DupNfe());
$item->nDup = '000003A';
$item->dVenc = '2016-10-09';
$item->vDup = 133.2;
// infAdic
$nfe->infAdic->infCpl = 'xxxx';
$nfe = $nfe->getXML();
$cert = new \PhpNFe\Tools\Certificado\Certificado();
$cert->carregarPfx(__DIR__ . '/SeuCertificado.pfx', 'suaSenha');
$xml = $cert->assinarXML($nfe, 'infNFe');
$autorizar = new \PhpNFe\NFe\NFe($cert);
$val = $autorizar->validar($xml, '3.10');
$ret = $autorizar->autorizar($xml);
$ehErro = $ret->isError();
$message = $ret->getMessage();
$codigo = $ret->getCode();
echo 'Foi!';
Esempio n. 2
0
<?php

include __DIR__ . '/../vendor/autoload.php';
$path = __DIR__ . '/../tests/utils/xmlTeste.xml';
$cert = new \PhpNFe\Tools\Certificado\Certificado();
$cert->carregarPfx(__DIR__ . 'seu_certificado.pfx', 'suaSenha');
$xml = file_get_contents($path);
$xml = $cert->assinarXML($xml, 'infNFe');
$nfe = new \PhpNFe\NFe\NFe($cert);
$b = $cert->ehValido();
$v = $nfe->validar($xml, '3.10');
$ret = $nfe->autorizar($xml);
$code = $ret->getCode();
$chave = $ret->getChNFe();
$retXml = $ret->getXML();
$message = $ret->getMessage();
echo 'foi';