Tools
extends Tools
in package
Table of Contents
Properties
- $ambiente : string
- ambiente
- $config : stdClass
- config class
- $contingency : Contingency
- contingency class
- $lastRequest : string
- last soap request
- $lastResponse : string
- last soap response
- $pathschemes : string
- Path to schemes folder
- $pathwsfiles : string
- Path to storage folder
- $soap : SoapInterface
- soap class
- $tpAmb : int
- Environment
- $verAplic : string
- Application version
- $algorithm : int
- Sign algorithm from OPENSSL
- $availableVersions : array<string|int, mixed>
- $canonical : array<string|int, mixed>
- Canonical conversion options
- $certificate : Certificate
- certificate class
- $modelo : int
- Model of CTe 57 or 67
- $objHeader : SOAPHeader
- $soapnamespaces : array<string|int, mixed>
- $timezone : string
- $urlAction : string
- $urlcUF : string
- urlcUF
- $urlHeader : string
- $urlMethod : string
- $urlNamespace : string
- $urlOperation : string
- $urlPortal : string
- urlPortal Instância do WebService
- $urlService : string
- urlService
- $urlVersion : string
- urlVersion
- $versao : string
- Version of layout
Methods
- __construct() : mixed
- Constructor load configurations, load Digital Certificate, map all paths, set timezone and and instanciate Contingency::class
- canonicalOptions() : array<string|int, mixed>
- Set option for canonical transformation see C14n
- getAcronym() : string
- Recover state acronym from cUF number
- getcUF() : int
- Recover cUF number from state acronym
- getModalXML() : string|bool
- loadSoapClass() : void
- Load Soap Class Soap Class may be \NFePHP\Common\Soap\SoapNative or \NFePHP\Common\Soap\SoapCurl
- model() : int
- Set or get model of document CTe = 57 or CTeOS = 67
- sefazCancela() : string
- Requires cte cancellation
- sefazCancelaCE() : string
- Requires CE cancellation
- sefazCancelaIE() : string
- Requires IE cancellation
- sefazCCe() : string
- Request authorization for Letter of Correction
- sefazCE() : string
- Requires CE
- sefazConsultaChave() : string
- Check the CTe status for the 44-digit key and retrieve the protocol
- sefazCsc() : string
- Maintenance of the Taxpayer Security Code - CSC (Old Token)
- sefazDistDFe() : string
- Service for the distribution of summary information and electronic tax documents of interest to an actor.
- sefazDownload() : string
- Request the NFe download already manifested by its recipient, by the key using new service in CTeDistribuicaoDFe
- sefazECPP() : string
- Request the cancellation of the request for an extension of the term of return of products of an NF-e of consignment for industrialization by order with suspension of ICMS in interstate operations
- sefazEnviaCTe() : string
- Request authorization to issue CTe in batch with one or more documents
- sefazEnviaCTeOS() : string
- Request authorization to issue CTe OS with one document only
- sefazEnviaCTeSimp() : string
- Envia CTe Simplificado
- sefazEPEC() : string
- Request authorization for issuance in contingency EPEC
- sefazEPP() : string
- Request extension of the term of return of products of an NF-e of consignment for industrialization to order with suspension of ICMS in interstate operations
- sefazIE() : string
- Requires IE
- sefazManifesta() : string
- Request the registration of the manifestation of recipient
- sefazStatus() : string
- Check services status SEFAZ/SVC If $uf is empty use normal check with contingency If $uf is NOT empty ignore contingency mode
- sefazValidate() : bool
- Checks the validity of an CTe, normally used for received CTe
- setEnvironment() : void
- Alter environment from "homologacao" to "producao" and vice-versa
- setEnvironmentTimeZone() : void
- Sets environment time zone
- setSignAlgorithm() : void
- Set OPENSSL Algorithm using OPENSSL constants
- setVerAplic() : mixed
- Set application version
- signCTe() : string
- Sign CTe
- validKeyByUF() : string
- Validate cUF from the key content and returns the state acronym
- version() : string
- Set or get parameter layout version
- addQRCode() : string
- Add QRCode Tag to signed XML from a NFCe
- checkContingencyForWebServices() : mixed
- Verifies the existence of the service
- checkSoap() : mixed
- Verify if SOAP class is loaded, if not, force load SoapCurl
- correctCTeForContingencyMode() : string
- getXmlUrlPath() : string
- Recover path to xml data base with list of soap services
- isValid() : bool
- Performs xml validation with its respective XSD structure definition document NOTE: if dont exists the XSD file will return true
- sendRequest() : string
- Send request message to webservice
- servico() : void
- Assembles all the necessary parameters for soap communication
- sefazEvento() : string
- Send event to SEFAZ
- serializerCCe() : mixed
- tpEv() : stdClass
Properties
$ambiente
ambiente
public
string
$ambiente
= 'homologacao'
$config
config class
public
stdClass
$config
$contingency
contingency class
public
Contingency
$contingency
$lastRequest
last soap request
public
string
$lastRequest
= ''
$lastResponse
last soap response
public
string
$lastResponse
= ''
$pathschemes
Path to schemes folder
public
string
$pathschemes
= ''
$pathwsfiles
Path to storage folder
public
string
$pathwsfiles
= ''
$soap
soap class
public
SoapInterface
$soap
$tpAmb
Environment
public
int
$tpAmb
= 2
$verAplic
Application version
public
string
$verAplic
= ''
$algorithm
Sign algorithm from OPENSSL
protected
int
$algorithm
= OPENSSL_ALGO_SHA1
$availableVersions
protected
array<string|int, mixed>
$availableVersions
= ['4.00' => 'PL_CTe_400']
$canonical
Canonical conversion options
protected
array<string|int, mixed>
$canonical
= [true, false, null, null]
$certificate
certificate class
protected
Certificate
$certificate
$modelo
Model of CTe 57 or 67
protected
int
$modelo
= 57
$objHeader
protected
SOAPHeader
$objHeader
$soapnamespaces
protected
array<string|int, mixed>
$soapnamespaces
= ['xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema", 'xmlns:soap' => "http://www.w3.org/2003/05/soap-envelope"]
$timezone
protected
string
$timezone
$urlAction
protected
string
$urlAction
= ''
$urlcUF
urlcUF
protected
string
$urlcUF
= ''
$urlHeader
protected
string
$urlHeader
= ''
$urlMethod
protected
string
$urlMethod
= ''
$urlNamespace
protected
string
$urlNamespace
= ''
$urlOperation
protected
string
$urlOperation
= ''
$urlPortal
urlPortal Instância do WebService
protected
string
$urlPortal
= 'http://www.portalfiscal.inf.br/cte'
$urlService
urlService
protected
string
$urlService
= ''
$urlVersion
urlVersion
protected
string
$urlVersion
= ''
$versao
Version of layout
protected
string
$versao
= '4.00'
Methods
__construct()
Constructor load configurations, load Digital Certificate, map all paths, set timezone and and instanciate Contingency::class
public
__construct(string $configJson, Certificate $certificate) : mixed
Parameters
- $configJson : string
-
content of config in json format
- $certificate : Certificate
canonicalOptions()
Set option for canonical transformation see C14n
public
canonicalOptions([array<string|int, mixed> $opt = [true, false, null, null] ]) : array<string|int, mixed>
Parameters
- $opt : array<string|int, mixed> = [true, false, null, null]
Return values
array<string|int, mixed>getAcronym()
Recover state acronym from cUF number
public
getAcronym(int $cUF) : string
Parameters
- $cUF : int
Return values
string —acronym sigla
getcUF()
Recover cUF number from state acronym
public
getcUF(string $acronym) : int
Parameters
- $acronym : string
-
Sigla do estado
Return values
int —number cUF
getModalXML()
public
getModalXML(mixed $dom, mixed $modal) : string|bool
Parameters
- $dom : mixed
- $modal : mixed
Tags
Return values
string|boolloadSoapClass()
Load Soap Class Soap Class may be \NFePHP\Common\Soap\SoapNative or \NFePHP\Common\Soap\SoapCurl
public
loadSoapClass(SoapInterface $soap) : void
Parameters
- $soap : SoapInterface
model()
Set or get model of document CTe = 57 or CTeOS = 67
public
model([int $model = null ]) : int
Parameters
- $model : int = null
Return values
int —modelo class parameter
sefazCancela()
Requires cte cancellation
public
sefazCancela(string $chave, string $xJust, string $nProt) : string
Parameters
- $chave : string
-
key of CTe
- $xJust : string
-
justificative 255 characters max
- $nProt : string
-
protocol number
Return values
stringsefazCancelaCE()
Requires CE cancellation
public
sefazCancelaCE(string $chave, string $nProt, string $nProtCE, int $nSeqEvento) : string
Parameters
- $chave : string
-
key of CTe
- $nProt : string
-
protocolo do CTe
- $nProtCE : string
-
protocolo do CE
- $nSeqEvento : int
-
No. sequencial do evento
Return values
stringsefazCancelaIE()
Requires IE cancellation
public
sefazCancelaIE(string $chave, string $nProt, string $nProtIE, int $nSeqEvento) : string
Parameters
- $chave : string
-
key of CTe
- $nProt : string
-
protocolo do CTe
- $nProtIE : string
-
protocolo do IE
- $nSeqEvento : int
-
No. sequencial do evento
Return values
stringsefazCCe()
Request authorization for Letter of Correction
public
sefazCCe(string $chave[, array<string|int, mixed> $infCorrecao = [] ][, int $nSeqEvento = 1 ]) : string
Parameters
- $chave : string
- $infCorrecao : array<string|int, mixed> = []
- $nSeqEvento : int = 1
Return values
stringsefazCE()
Requires CE
public
sefazCE(string $chave, string $nProt, string $xNome, string $nDoc, string $hash, string|null $latitude, string|null $longitude, int $nSeqEvento, string $dhEventoEntrega[, array<string|int, mixed> $aNFes = [] ]) : string
Parameters
- $chave : string
-
key of CTe
- $nProt : string
-
Protocolo do CTe
- $xNome : string
-
Nome de quem recebeu a entrega
- $nDoc : string
-
Documento de quem recebeu a entrega
- $hash : string
-
Hash da Chave de acesso do CT-e + Imagem da assinatura no formato Base64
- $latitude : string|null
-
Latitude do ponto da entrega
- $longitude : string|null
-
Longitude do ponto da entrega
- $nSeqEvento : int
-
No. sequencial do evento
- $dhEventoEntrega : string
-
Data e hora da geração do hash da entrega
- $aNFes : array<string|int, mixed> = []
-
Chave das NFes entregues
Return values
stringsefazConsultaChave()
Check the CTe status for the 44-digit key and retrieve the protocol
public
sefazConsultaChave(string $chave[, int $tpAmb = null ]) : string
Parameters
- $chave : string
- $tpAmb : int = null
Return values
stringsefazCsc()
Maintenance of the Taxpayer Security Code - CSC (Old Token)
public
sefazCsc(int $indOp) : string
Parameters
- $indOp : int
-
Identificador do tipo de operação: 1 - Consulta CSC Ativos; 2 - Solicita novo CSC; 3 - Revoga CSC Ativo
Return values
stringsefazDistDFe()
Service for the distribution of summary information and electronic tax documents of interest to an actor.
public
sefazDistDFe([int $ultNSU = 0 ][, int $numNSU = 0 ][, string $fonte = 'AN' ]) : string
Parameters
- $ultNSU : int = 0
-
last NSU number recived
- $numNSU : int = 0
-
NSU number you wish to consult
- $fonte : string = 'AN'
-
data source 'AN' and for some cases it may be 'RS'
Return values
stringsefazDownload()
Request the NFe download already manifested by its recipient, by the key using new service in CTeDistribuicaoDFe
public
sefazDownload(string $chave) : string
Parameters
- $chave : string
Return values
stringsefazECPP()
Request the cancellation of the request for an extension of the term of return of products of an NF-e of consignment for industrialization by order with suspension of ICMS in interstate operations
public
sefazECPP(string $chNFe, string $nProt[, int $nSeqEvento = 1 ]) : string
Parameters
- $chNFe : string
- $nProt : string
- $nSeqEvento : int = 1
Return values
stringsefazEnviaCTe()
Request authorization to issue CTe in batch with one or more documents
public
sefazEnviaCTe(string $xml) : string
Parameters
- $xml : string
-
string do xml
Return values
string —soap response xml
sefazEnviaCTeOS()
Request authorization to issue CTe OS with one document only
public
sefazEnviaCTeOS(string $xml) : string
Parameters
- $xml : string
Return values
stringsefazEnviaCTeSimp()
Envia CTe Simplificado
public
sefazEnviaCTeSimp(string $xml) : string
Parameters
- $xml : string
-
string do xml
Return values
string —soap response xml
sefazEPEC()
Request authorization for issuance in contingency EPEC
public
sefazEPEC(string &$xml) : string
Parameters
- $xml : string
Return values
stringsefazEPP()
Request extension of the term of return of products of an NF-e of consignment for industrialization to order with suspension of ICMS in interstate operations
public
sefazEPP(string $chNFe, string $nProt[, array<string|int, mixed> $itens = array() ][, int $tipo = 1 ][, int $nSeqEvento = 1 ]) : string
Parameters
- $chNFe : string
- $nProt : string
- $itens : array<string|int, mixed> = array()
- $tipo : int = 1
-
1-primerio prazo, 2-segundo prazo
- $nSeqEvento : int = 1
Return values
stringsefazIE()
Requires IE
public
sefazIE(string $chave, string $nProt, string $nTentativa, string $tpMotivo, string|null $xJustMotivo, string $hash, string|null $latitude, string|null $longitude, int $nSeqEvento, string $dhTentativaEntrega[, array<string|int, mixed> $aNFes = [] ]) : string
Parameters
- $chave : string
-
key of CTe
- $nProt : string
-
Protocolo do CTe
- $nTentativa : string
-
Número da tentativa de entrega que não teve sucesso
- $tpMotivo : string
-
Motivo do Insucesso
- $xJustMotivo : string|null
-
Justificativa do Motivo de insucesso
- $hash : string
-
Hash da Chave de acesso do CT-e + Imagem da assinatura no formato Base64
- $latitude : string|null
-
Latitude do ponto da entrega
- $longitude : string|null
-
Longitude do ponto da entrega
- $nSeqEvento : int
-
No. sequencial do evento
- $dhTentativaEntrega : string
-
Data e hora da geração do hash da tentativa de entrega
- $aNFes : array<string|int, mixed> = []
-
Chave das NFes entregues
Return values
stringsefazManifesta()
Request the registration of the manifestation of recipient
public
sefazManifesta(string $chNFe, int $tpEvento[, string $xJust = '' ][, int $nSeqEvento = 1 ][, mixed $ufEvento = 'RS' ]) : string
Parameters
- $chNFe : string
- $tpEvento : int
- $xJust : string = ''
-
Justification for not carrying out the operation
- $nSeqEvento : int = 1
- $ufEvento : mixed = 'RS'
Return values
stringsefazStatus()
Check services status SEFAZ/SVC If $uf is empty use normal check with contingency If $uf is NOT empty ignore contingency mode
public
sefazStatus([string $uf = '' ][, int $tpAmb = null ]) : string
Parameters
- $uf : string = ''
-
initials of federation unit
- $tpAmb : int = null
Return values
string —xml soap response
sefazValidate()
Checks the validity of an CTe, normally used for received CTe
public
sefazValidate(string $cte) : bool
Parameters
- $cte : string
Return values
boolsetEnvironment()
Alter environment from "homologacao" to "producao" and vice-versa
public
setEnvironment([int $tpAmb = 2 ]) : void
Parameters
- $tpAmb : int = 2
setEnvironmentTimeZone()
Sets environment time zone
public
setEnvironmentTimeZone(string $acronym) : void
Parameters
- $acronym : string
-
(ou seja a sigla do estado)
setSignAlgorithm()
Set OPENSSL Algorithm using OPENSSL constants
public
setSignAlgorithm([int $algorithm = OPENSSL_ALGO_SHA1 ]) : void
Parameters
- $algorithm : int = OPENSSL_ALGO_SHA1
setVerAplic()
Set application version
public
setVerAplic(string $ver) : mixed
Parameters
- $ver : string
signCTe()
Sign CTe
public
signCTe(string $xml) : string
Parameters
- $xml : string
-
CTe xml content
Tags
Return values
string —singed CTe xml
validKeyByUF()
Validate cUF from the key content and returns the state acronym
public
validKeyByUF(string $chave) : string
Parameters
- $chave : string
Tags
Return values
stringversion()
Set or get parameter layout version
public
version([string $version = '' ]) : string
Parameters
- $version : string = ''
Tags
Return values
stringaddQRCode()
Add QRCode Tag to signed XML from a NFCe
protected
addQRCode(DOMDocument $dom) : string
Parameters
- $dom : DOMDocument
Return values
stringcheckContingencyForWebServices()
Verifies the existence of the service
protected
checkContingencyForWebServices(string $service) : mixed
Parameters
- $service : string
Tags
checkSoap()
Verify if SOAP class is loaded, if not, force load SoapCurl
protected
checkSoap() : mixed
correctCTeForContingencyMode()
protected
correctCTeForContingencyMode(string $xml) : string
Parameters
- $xml : string
-
CTe xml content
Tags
Return values
stringgetXmlUrlPath()
Recover path to xml data base with list of soap services
protected
getXmlUrlPath() : string
Return values
stringisValid()
Performs xml validation with its respective XSD structure definition document NOTE: if dont exists the XSD file will return true
protected
isValid(string $version, string $body, string $method) : bool
Parameters
- $version : string
-
layout version
- $body : string
- $method : string
Return values
boolsendRequest()
Send request message to webservice
protected
sendRequest(string $request[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
- $request : string
- $parameters : array<string|int, mixed> = []
Return values
stringservico()
Assembles all the necessary parameters for soap communication
protected
servico(string $service, string $uf, string $tpAmb[, bool $ignoreContingency = false ]) : void
Parameters
- $service : string
- $uf : string
- $tpAmb : string
- $ignoreContingency : bool = false
sefazEvento()
Send event to SEFAZ
private
sefazEvento(string $uf, string $chave, int $tpEvento[, int $nSeqEvento = 1 ][, string $tagAdic = '' ]) : string
Parameters
- $uf : string
- $chave : string
- $tpEvento : int
- $nSeqEvento : int = 1
- $tagAdic : string = ''
Return values
stringserializerCCe()
private
static serializerCCe(array<string|int, mixed> $infCorrecoes) : mixed
Parameters
- $infCorrecoes : array<string|int, mixed>
tpEv()
private
tpEv(int $tpEvento) : stdClass
Parameters
- $tpEvento : int