PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV 25
→
Procedures sobre NFC-e
Procedures sobre NFC-e
Started by Boller, Jul., 23 2023 4:20 PM - 1 reply
Connect yourself…
Boller
#1
Registered member
3,660 messages
Popularité : +175 (223 votes)
Posted on July, 23 2023 - 4:20 PM
Bom dia
Voce cadastra na nuvem fiscal, pega o IDCLIENT e o SECRET, coloca nesse codigo
Procedure Token
(
)
URLSite est un restRequest
Resposta est un restResponse
vReponseVariant est un Variant
URLSite.URL
=
"https://auth.nuvemfiscal.com.br/oauth/token"
URLSite
.
.
Method
=
httpPost
URLSite.Content
=
"grant_type=client_credentials&client_id=SEUID&client_secret=SEUSECRET&scope=cnpj%20nfce"
URLSite
.
.
IgnoreError
=
httpIgnoreExpiredCertificate
+
httpIgnoreInvalidCertificate
+
httpIgnoreInvalidCertificateName
Resposta
=
RESTSend
(
URLSite
)
IF ErrorOccurred THEN
Error
(
ErrorInfo
(
errComplet
)
)
ELSE
IF Resposta.StatusCode
=
200
AND Resposta.Content
<
>
"404"
vReponseVariant = JSONToVariant(Resposta.Content)
IF Resposta.Content
<
>
"[]" THEN
EDT_TOKEN = vReponseVariant.access_token
duSegundosRestante is Duration
duSegundosRestante..Second = vReponseVariant.expires_in
EDT_Resultado = DurationToString(duSegundosRestante,"D-HH:MM:SS")
vReponseVariant.Erro = 0
ELSE
vReponseVariant.Erro = 1
END
ELSE
vReponseVariant.Erro = 1
END
END
NFC Envia, vai usar o Token
PROCEDURE NFC_Enviar
(
ArquivoJSON
,
Token
)
URLSite est un restRequest
Resposta est un restResponse
vReponseVariant est un Variant
URLSite.URL
=
"https://api.nuvemfiscal.com.br/nfce"
URLSite
.
.
Method
=
httpPost
URLSite
.
.
Header
[
"Authorization"
]
=
"Bearer "
+
Token
URLSite
.
.
Header
[
"Content-Type"
]
=
"application/json"
URLSite
.
.
Header
[
"Accept"
]
=
"application/json"
URLSite
.
.
Timeout
=
180
s
URLSite
.
.
IgnoreError
=
httpIgnoreExpiredCertificate
+
httpIgnoreInvalidCertificate
+
httpIgnoreInvalidCertificateName
URLSite
.
.
Content
=
ArquivoJSON
Resposta
=
RESTSend
(
URLSite
)
IF ErrorOccurred THEN
Error
(
ErrorInfo
(
errComplet
)
)
ELSE
IF Resposta.StatusCode
=
200
AND Resposta.Content
<
>
"404"
vReponseVariant = JSONToVariant(Resposta.Content)
IF Resposta.Content
<
>
"[]" THEN
vReponseVariant.Erro = 0
vReponseVariant.ErroMSG = ""
ELSE
vReponseVariant.Erro = 1
vReponseVariant.ErroMSG = Resposta.Content
END
ELSE
vReponseVariant.Erro = 1
vReponseVariant.ErroMSG = Resposta.Content
END
END
RESULT = vReponseVariant
NFC Json
esse aqui é API que envia a NFc-e
PROCEDURE NFC_JSON
(
pIdFiscal
)
sRET is string
=
""
gnFalha
=
0
FetchManual
(
fiscal
,
"id_fiscal"
,
pIdFiscal
)
FetchManual
(
sat
,
"id_caixa"
,
gnId_Caixa
)
IF gnFalha
=
1
THEN
RESULT
"Falha"
ELSE
/
/
Grupo A
.
Dados da Nota Fiscal eletrônica
gInfNFE.infNFe.versao
=
"4.00"
gInfNFE.infNFe.Id
=
NoSpace
(
fiscal.nfe_chave
)
/
/
Grupo B
.
Identificação da Nota Fiscal eletrônica
gInfNFE.infNFe.ide.cUF
=
Val
(
NoSpace
(
fiscal.nfe_b02_cuf
)
)
gInfNFE.infNFe.ide.cNF
=
NoSpace
(
NumToString
(
fiscal.nfe_b03_cnf
,
"8d"
)
)
gInfNFE.infNFe.ide.natOp
=
NoSpace
(
Middle
(
fiscal.nfe_b04_natop
,
1
,
60
)
)
gInfNFE.infNFe.ide.mod
=
65
/
/
Val
(
NoSpace
(
Middle
(
fiscal.nfe_b06_mod
,
1
,
2
)
)
)
gInfNFE.infNFe.ide.serie
=
Val
(
NoSpace
(
fiscal.nfe_b07_serie
)
)
gInfNFE.infNFe.ide.nNF
=
Val
(
NoSpace
(
NumToString
(
fiscal.nfe_num
,
"9d"
)
)
)
gInfNFE.infNFe.ide.dhEmi
=
NoSpace
(
DateToString
(
fiscal.nfe_b09_dhemi
,
"AAAA-MM-DDTHH:MM:SS"
)
)
+
gsHoraVerao
gInfNFE.infNFe.ide.dhSaiEnt
=
""
/
/
"2019-08-24T14:15:22Z"
gInfNFE.infNFe.ide.tpNF
=
Val
(
NoSpace
(
NumToString
(
fiscal.nfe_b11_tpnf
,
"1d"
)
)
)
gInfNFE.infNFe.ide.idDest
=
Val
(
NoSpace
(
fiscal.nfe_b11a_iddest
)
)
gInfNFE.infNFe.ide.cMunFG
=
NoSpace
(
fiscal.nfe_b12_cmunfg
)
gInfNFE.infNFe.ide.tpImp
=
Val
(
NoSpace
(
fiscal.nfe_b21_tpimp
)
)
gInfNFE.infNFe.ide.tpEmis
=
Val
(
NoSpace
(
fiscal.nfe_b22_tpemis
)
)
gInfNFE.infNFe.ide.cDV
=
Val
(
NoSpace
(
fiscal.nfe_b23_cdv
)
)
gInfNFE.infNFe.ide.tpAmb
=
Val
(
NoSpace
(
fiscal.nfe_b24_tpamb
)
)
gInfNFE.infNFe.ide.finNFe
=
Val
(
NoSpace
(
fiscal.nfe_b25_finnfe
)
)
gInfNFE.infNFe.ide.indFinal
=
Val
(
NoSpace
(
fiscal.nfe_b25a_indfinal
)
)
gInfNFE.infNFe.ide.indPres
=
Val
(
NoSpace
(
fiscal.nfe_b25b_indpres
)
)
gInfNFE.infNFe.ide.indIntermed
=
0
gInfNFE.infNFe.ide.procEmi
=
Val
(
NoSpace
(
fiscal.nfe_b26_procemi
)
)
gInfNFE.infNFe.ide.verProc
=
NoSpace
(
fiscal.nfe_b27_verproc
)
gInfNFE.infNFe.ide.dhCont
=
""
/
/
"2019-08-24T14:15:22Z"
/
/
gInfNFE.infNFe.ide.xJust
=
""
/
/
Grupo BA
.
Documento Fiscal Referenciado
IF fiscal_cfop.finnfe
=
4
THEN
gInfNFE.infNFe.ide.NFref.refNFe
=
NoSpace
(
fiscal.nfe_ba02_refnfe
)
gInfNFE.infNFe.ide.NFref.refNFeSig
=
""
END
Esse modelo de como to gerando o arquivo JSON
--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Report
0
0
Kelley WILLIAM
#2
Registered member
2 messages
Posted on August, 09 2023 - 1:57 PM
Olá! Parece que você compartilhou um trecho de código relacionado a integrações com uma API da nuvem fiscal para emissão de Notas Fiscais eletrônicas. O código descreve a obtenção de um token de autenticação e o envio de informações de NF-e para a API.
Se você está buscando assistência ou esclarecimentos sobre esse código, posso ajudá-lo. Por favor, indique qual é a sua pergunta específica ou o que você gostaria de entender melhor sobre esse código.
Report
1
0
→ Go back to WINDEV 25
WINDEV 25
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text