public function verificaValidade($pathXmlFile = '', &$aRetorno = array())
{
$aRetorno = array();
if (!file_exists($pathXmlFile)) {
$msg = "Arquivo não localizado!!";
throw new Exception\InvalidArgumentException($msg);
}
//carrega a NFe
$xml = Files\FilesFolders::readFile($pathXmlFile);
$this->oCertificate->verifySignature($xml, 'infNFe');
//obtem o chave da NFe
$docnfe = new Dom();
$docnfe->loadXMLFile($pathXmlFile);
$tpAmb = $docnfe->getNodeValue('tpAmb');
$chNFe = $docnfe->getChave('infNFe');
$this->sefazConsultaChave($chNFe, $tpAmb, $aRetorno);
if ($aRetorno['cStat'] != '100' && $aRetorno['cStat'] != '150') {
return false;
}
return true;
}
<?php error_reporting(E_ALL); ini_set('display_errors', 'On'); include_once '../../bootstrap.php'; use NFePHP\NFe\ToolsNFe; $nfe = new ToolsNFe('../../config/config.json'); $nfe->setModelo('55'); $aResposta = array(); $pathXmlFile = '/var/www/nfephpdev/exemplos/xml/35150258716523000119550000000344861511504837-nfe.xml'; if (!$nfe->verificaValidade($pathXmlFile, $aResposta)) { echo "<h1>NFe INVÁLIDA!!</h1>"; } else { echo "<h1>NFe valida.</h1>"; } echo '<br><br><PRE>'; echo htmlspecialchars($nfe->soapDebug); echo '</PRE><BR>'; print_r($aResposta); echo "<br>";