Access NFC-e via the Website

Asked

Viewed 145 times

1

Hello, I need to access the coupons (NFC-e) of my clients from the state of São Paulo. Today I would have access to the coupons and the public key of the same, but through the manual access on the site of Sefaz. I would like to access them via the webservice of Sefaz itself and if possible read in an XML extension, would it be possible? initially need a certificate from my company to access these coupons via webservice? Thank you!

  • Eduardo, it is not yet possible to download the xml of the model 65 of nfces. There is no web services for this. Model 55 and 57 only attached to model 55. For other features work with Nfephp

  • If you need to model 55 I can give you examples and help you

  • Thank you @Leandroalfredo, could you give me examples of this model 55? I ended up editing the question a little, I would not necessarily need to download, but via webservice get the return of this NFC-e in xml or any other extension that the If returns me.

  • Okay, I’ll assemble the answer here for you

1 answer

0

Eduardo, you can use the Nfephp library link from github here

Do I initially need a certificate from my company to access these coupons via webservice? Yes, you need the digital certificate to perform any action involving the SEFAZ’s.

Below is an example to download Nfe with access key :

use NFePHP\NFe\Tools;
use NFePHP\Common\Certificate;

try {

    $tools = new Tools($configJson, Certificate::readPfx($pfxcontent, $password));
    //só funciona para o modelo 55
    $tools->model('55');
    //este serviço somente opera em ambiente de produção
    $this->tools->setEnvironment(1);
    $chave = '35180174283375000142550010000234761182919182';
    $response = $tools->sefazDownload($chave);
    header('Content-type: text/xml; charset=UTF-8');
    echo $response;

} catch (\Exception $e) {
    echo str_replace("\n", "<br/>", $e->getMessage());
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.