-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1020 from robmachado/master
docs para insucesso na entrega
- Loading branch information
Showing
3 changed files
with
179 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Registro de Insucesso na Entrega da Mercadoria | ||
|
||
**Função:** Evento fiscal da NF-e visa registrar as operações de transporte que ocorreram, mas que por algum motivo (recusa do destinatário ou a sua não localização, por exemplo), não foi possível a conclusão do serviço com a efetivação da entrega da mercadoria ao recebedor. | ||
|
||
**Processo:** síncrono. | ||
|
||
**Método:** nfeRecepcaoEvento | ||
|
||
```php | ||
|
||
use NFePHP\NFe\Tools; | ||
use NFePHP\Common\Certificate; | ||
use NFePHP\NFe\Common\Standardize; | ||
|
||
try { | ||
//$content = conteúdo do certificado PFX | ||
$tools = new Tools($configJson, Certificate::readPfx($content, 'senha')); | ||
|
||
//dados do evento de insucesso na entrega | ||
$std = new \stdClass(); | ||
//$std->verAplic = '1.2.3'; //opcional se declarado anteriormente - versão da aplicação que está gerando o evento | ||
$std->nSeqEvento = 1; | ||
$std->chNFe = '12345678901234567890123456789012345678901234'; //chave de 44 digitos da nota do fornecedor | ||
$std->imagem = 'kakakakakakakakak'; // aqui pode ser colocada uma imagem ou uma string que fará parte do hash | ||
$std->latitude = null; | ||
$std->longitude = null; | ||
$std->data_tentativa = '2021-04-25T10:34:13-03:00'; //data de recebimento | ||
$std->tentativas = 3; | ||
$std->tipo_motivo = 1; | ||
//1 – Recebedor não encontrado | ||
//2 – Recusa do recebedor | ||
//3 – Endereço inexistente | ||
//4 – Outros (exige informar justificativa) | ||
$std->justificativa = null; | ||
$std->cancelar = false; //permite cancelar um registro de insucesso de entrega se for true | ||
|
||
$response = $tools->sefazInsucessoEntrega($std); | ||
|
||
//transforma o xml de retorno em um stdClass | ||
$st = new Standardize(); | ||
$std = $st->toStd($xmlResp); | ||
|
||
//verifique se o evento foi processado | ||
if ($std->cStat != 128) { | ||
//houve alguma falha e o evento não foi processado | ||
//TRATAR | ||
} else { | ||
$cStat = $std->retEvento->infEvento->cStat; | ||
if ($cStat == '135' || $cStat == '136') { | ||
//SUCESSO PROTOCOLAR A SOLICITAÇÂO ANTES DE GUARDAR | ||
$xml = Complements::toAuthorize($tools->lastRequest, $xmlResp); | ||
//grave o XML protocolado | ||
} else { | ||
//houve alguma falha no evento | ||
//TRATAR | ||
} | ||
} | ||
} catch (\Exception $e) { | ||
echo str_replace("\n", "<br/>", $e->getMessage()); | ||
} | ||
``` | ||
|
||
# Cancelamento de evento de Insucesso na Entrega | ||
|
||
**Função:** Cancelar o evento de insucesso na entrega anteriormente autorizado | ||
|
||
**Processo:** síncrono. | ||
|
||
**Método:** nfeRecepcaoEvento | ||
|
||
```php | ||
|
||
use NFePHP\NFe\Tools; | ||
use NFePHP\Common\Certificate; | ||
use NFePHP\NFe\Common\Standardize; | ||
|
||
try { | ||
//$content = conteúdo do certificado PFX | ||
$tools = new Tools($configJson, Certificate::readPfx($content, 'senha')); | ||
|
||
//dados do evento de insucesso na entrega | ||
$std = new \stdClass(); | ||
//$std->verAplic = '1.2.3'; //opcional se declarado anteriormente - versão da aplicação que está gerando o evento | ||
$std->nSeqEvento = 1; | ||
$std->chNFe = '12345678901234567890123456789012345678901234'; //chave de 44 digitos da nota do fornecedor | ||
$std->protocolo = '123456789012345'; //protocolo de autoriação do evento que se deseja cancelar | ||
$std->cancelar = true; //permite cancelar um registro de insucesso de entrega se for true | ||
|
||
$response = $tools->sefazInsucessoEntrega($std); | ||
|
||
//transforma o xml de retorno em um stdClass | ||
$st = new Standardize(); | ||
$std = $st->toStd($xmlResp); | ||
|
||
//verifique se o evento foi processado | ||
if ($std->cStat != 128) { | ||
//houve alguma falha e o evento não foi processado | ||
//TRATAR | ||
} else { | ||
$cStat = $std->retEvento->infEvento->cStat; | ||
if ($cStat == '135' || $cStat == '136') { | ||
//SUCESSO PROTOCOLAR A SOLICITAÇÂO ANTES DE GUARDAR | ||
$xml = Complements::toAuthorize($tools->lastRequest, $xmlResp); | ||
//grave o XML protocolado | ||
} else { | ||
//houve alguma falha no evento | ||
//TRATAR | ||
} | ||
} | ||
} catch (\Exception $e) { | ||
echo str_replace("\n", "<br/>", $e->getMessage()); | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'On'); | ||
require_once '../bootstrap.php'; | ||
|
||
use NFePHP\NFe\Tools; | ||
use NFePHP\Common\Certificate; | ||
use NFePHP\Common\Soap\SoapFake; | ||
use NFePHP\NFe\Common\FakePretty; | ||
|
||
try { | ||
|
||
$arr = [ | ||
"atualizacao" => "2016-11-03 18:01:21", | ||
"tpAmb" => 2, | ||
"razaosocial" => "SUA RAZAO SOCIAL LTDA", | ||
"cnpj" => "99999999999999", | ||
"siglaUF" => "SP", | ||
"schemes" => "PL_009_V4", | ||
"versao" => '4.00', | ||
"tokenIBPT" => "AAAAAAA", | ||
"CSC" => "GPB0JBWLUR6HWFTVEAS6RJ69GPCROFPBBB8G", | ||
"CSCid" => "000001", | ||
"proxyConf" => [ | ||
"proxyIp" => "", | ||
"proxyPort" => "", | ||
"proxyUser" => "", | ||
"proxyPass" => "" | ||
] | ||
]; | ||
$configJson = json_encode($arr); | ||
$soap = new SoapFake(); | ||
$soap->disableCertValidation(true); | ||
|
||
$content = file_get_contents('expired_certificate.pfx'); | ||
$tools = new Tools($configJson, Certificate::readPfx($content, 'associacao')); | ||
$tools->model('55'); | ||
$tools->setVerAplic('5.1.34'); | ||
$tools->loadSoapClass($soap); | ||
|
||
$std = new \stdClass(); | ||
//$std->verAplic = '1.2.3'; //opcional se declarado anteriormente - versão da aplicação que está gerando o evento | ||
$std->nSeqEvento = 1; | ||
$std->chNFe = '12345678901234567890123456789012345678901234'; //chave de 44 digitos da nota do fornecedor | ||
$std->imagem = 'kakakakakakakakak'; // aqui pode ser colocada uma imagem ou uma string que fará parte do hash | ||
$std->latitude = null; | ||
$std->longitude = null; | ||
$std->data_tentativa = '2021-04-25T10:34:13-03:00'; //data de recebimento | ||
$std->tentativas = 3; | ||
$std->tipo_motivo = 1; | ||
//1 – Recebedor não encontrado | ||
//2 – Recusa do recebedor | ||
//3 – Endereço inexistente | ||
//4 – Outros (exige informar justificativa) | ||
$std->justificativa = null; | ||
$std->cancelar = false; //permite cancelar um registro de insucesso de entrega se for true | ||
|
||
$response = $tools->sefazInsucessoEntrega($std); | ||
|
||
echo FakePretty::prettyPrint($response); | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters