4
Good morning, I am consulting the Nfe of a certain client, so far so good, is returning the Key notes all right, but when I use the download option, the same returns 'Paralyzed Service without Forecast', in a quick read, I noticed that this Download service 'Nfedownloadnf', has been discontinued, I would like to know how to download Nfe using 'Nfedistribuicaodfe', follows code snippet...
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$ultNSU = 0;
$numNSU = 0;
$tpAmb = '1';
$cnpj = '';
$aResposta = array();
$aRespostaDownload = array();
$xml = $nfe->sefazDistDFe('AN', $tpAmb, $cnpj, $ultNSU, $numNSU, $aResposta);
foreach ($aResposta['aDoc'] as $k => $v) {
$xml = simplexml_load_string($v['doc']);
$xml = get_object_vars($xml);
if (isset($xml['vNF'])) {
$dados = array(
'chnfe' => $xml['chNFe'],
'cnpj' => $xml['CNPJ'],
'xnome' => utf8_decode($xml['xNome']),
'ie' => $xml['IE'],
'data' => date('Y-m-d H:i:s', strtotime($xml['dhEmi'])),
'tpnf' => $xml['tpNF'],
'vnf' => $xml['vNF'],
'nprot' => $xml['nProt'],
'csitnfe' => $xml['cSitNFe'],
'nsu' => $v['NSU']
);
$resp = $nfe->sefazDownload($dados['chnfe'], $tpAmb, $cnpj, $aRespostaDownload);
var_dump($aRespostaDownload);exit();
}
}
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
Good morning Felipe, although the request is being made different I have the same problem... confirms to me if the webservice you are using is this: * https://hom.nfe.fazenda.gov.br/NfeDownloadNF/NfeDownloadNF.asmx*
– Thiago Motta Barboza
I am using 'https://www.nfe.fazenda.gov.br/NfeDownloadNF/NfeDownloadNF.asmx'
– Felipe Aurelio
in some places even talk possible problem with the revenue service, but it doesn’t make sense... because I have another program that is downloading normally... a boy answered me in my question saying that the recipe is changing some validations... follows the link that he made available: http://www.contabeis.com.br/noticias/35193/cfc-alert_overdreations-validations-fiscals-electronicnotations-electronic/
– Thiago Motta Barboza
Yeah, I also read something about using 'Nfedistribuicaodfe' to download the xml, but I don’t know how...
– Felipe Aurelio