Skip to content

Commit bdd2f03

Browse files
authored
Merge pull request #26 from renatoguarilha/main
Criação do Provedor Tiplan para a Cidade de Angra dos Reis
2 parents 6e75706 + 333f2db commit bdd2f03

5 files changed

Lines changed: 237 additions & 63 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[![Nuget count](http://img.shields.io/nuget/v/OpenAC.Net.NFSe.Nacional.svg)](https://www.nuget.org/packages/OpenAC.Net.NFSe.Nacional/)
22
[![Junte-se ao chat](https://img.shields.io/badge/Chat%20on-Discord-purple.svg)](https://discord.com/invite/brdmJ7Yv6w)
33

4-
# Ajude-nos
4+
# Ajude o projeto OpenAC diretamente no repositório deles
55

66
Se *OpenNFSeNacional* for um componente vital em sua aplicação comercial ou de código aberto e / ou você quiser contribuir para seu sucesso contínuo, por favor considere fazer uma pequena contribuição monetária.
77

88
# OpenAC.Net.NFSe.Nacional
99

10-
Biblioteca para emissão e transmissão de NFSe (Nota Fiscal de Serviço Eletrônica) Padrão Nacional.
10+
Biblioteca para emissão e transmissão de NFSe (Nota Fiscal de Serviço Eletrônica) Padrão Nacional.
11+
12+
# Essa biblioteca pode conter ajustes que ainda não foram levados ao projeto original.

src/OpenAC.Net.NFSe.Nacional/OpenAC.Net.NFSe.Nacional.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net462;net48;netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
5-
<LangVersion>latest</LangVersion>
5+
<LangVersion>preview</LangVersion>
66
<AssemblyName>OpenAC.Net.NFSe.Nacional</AssemblyName>
77
<RootNamespace>OpenAC.Net.NFSe.Nacional</RootNamespace>
88
<SignAssembly>true</SignAssembly>
Lines changed: 89 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,92 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<NFSeServices xmlns="https://www.openac.net.br/">
3-
<Services>
4-
<serviceInfo Id="-1">
5-
<Tipo>Nacional</Tipo>
6-
<Nome>NFSe Nacional</Nome>
7-
<UF>EX</UF>
8-
<Ambientes>
9-
<Ambiente Tipo="2">
10-
<Enderecos>
11-
<Endereco Tipo="Enviar">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
12-
<Endereco Tipo="EnviarEvento">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
13-
<Endereco Tipo="ConsultarNsu">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
14-
<Endereco Tipo="ConsultarChave">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
15-
<Endereco Tipo="DownloadDanfse">https://adn.producaorestrita.nfse.gov.br</Endereco>
16-
<Endereco Tipo="ConsultarChaveDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
17-
<Endereco Tipo="ConsultaExisteDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
18-
</Enderecos>
19-
</Ambiente>
20-
<Ambiente Tipo="1">
21-
<Enderecos>
22-
<Endereco Tipo="Enviar">https://sefin.nfse.gov.br/sefinnacional</Endereco>
23-
<Endereco Tipo="EnviarEvento">https://sefin.nfse.gov.br/sefinnacional</Endereco>
24-
<Endereco Tipo="ConsultarNsu">https://adn.nfse.gov.br/contribuintes</Endereco>
25-
<Endereco Tipo="ConsultarChave">https://adn.nfse.gov.br/contribuintes</Endereco>
26-
<Endereco Tipo="DownloadDanfse">https://adn.nfse.gov.br</Endereco>
27-
<Endereco Tipo="ConsultarChaveDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
28-
<Endereco Tipo="ConsultaExisteDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
29-
</Enderecos>
30-
</Ambiente>
31-
</Ambientes>
32-
</serviceInfo>
33-
<serviceInfo Id="3514106">
34-
<Tipo>SimplISS</Tipo>
35-
<Nome>DOIS CÓRREGOS</Nome>
36-
<UF>SP</UF>
37-
<Ambientes>
38-
<Ambiente Tipo="2">
39-
<Enderecos>
40-
<Endereco Tipo="Enviar">https://producaorestrita.simplissweb.com.br</Endereco>
41-
<Endereco Tipo="EnviarEvento">https://producaorestrita.simplissweb.com.br</Endereco>
42-
<Endereco Tipo="ConsultarNsu">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
43-
<Endereco Tipo="ConsultarChave">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
44-
<Endereco Tipo="DownloadDanfse">https://adn.producaorestrita.nfse.gov.br</Endereco>
45-
<Endereco Tipo="ConsultarChaveDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
46-
<Endereco Tipo="ConsultaExisteDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
47-
</Enderecos>
48-
</Ambiente>
49-
<Ambiente Tipo="1">
50-
<Enderecos>
51-
<Endereco Tipo="Enviar">https://nfsedoiscorregos.simplissweb.com.br</Endereco>
52-
<Endereco Tipo="EnviarEvento">https://nfsedoiscorregos.simplissweb.com.br</Endereco>
53-
<Endereco Tipo="ConsultarNsu">https://adn.nfse.gov.br/contribuintes</Endereco>
54-
<Endereco Tipo="ConsultarChave">https://adn.nfse.gov.br/contribuintes</Endereco>
55-
<Endereco Tipo="DownloadDanfse">https://adn.nfse.gov.br</Endereco>
56-
<Endereco Tipo="ConsultarChaveDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
57-
<Endereco Tipo="ConsultaExisteDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
58-
</Enderecos>
59-
</Ambiente>
60-
</Ambientes>
61-
</serviceInfo>
62-
</Services>
3+
<Services>
4+
<serviceInfo Id="-1">
5+
<Tipo>Nacional</Tipo>
6+
<Nome>NFSe Nacional</Nome>
7+
<UF>EX</UF>
8+
<Ambientes>
9+
<Ambiente Tipo="2">
10+
<Enderecos>
11+
<Endereco Tipo="Enviar">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
12+
<Endereco Tipo="EnviarEvento">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
13+
<Endereco Tipo="ConsultarNsu">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
14+
<Endereco Tipo="ConsultarChave">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
15+
<Endereco Tipo="DownloadDanfse">https://adn.producaorestrita.nfse.gov.br</Endereco>
16+
<Endereco Tipo="ConsultarChaveDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
17+
<Endereco Tipo="ConsultaExisteDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
18+
</Enderecos>
19+
</Ambiente>
20+
<Ambiente Tipo="1">
21+
<Enderecos>
22+
<Endereco Tipo="Enviar">https://sefin.nfse.gov.br/sefinnacional</Endereco>
23+
<Endereco Tipo="EnviarEvento">https://sefin.nfse.gov.br/sefinnacional</Endereco>
24+
<Endereco Tipo="ConsultarNsu">https://adn.nfse.gov.br/contribuintes</Endereco>
25+
<Endereco Tipo="ConsultarChave">https://adn.nfse.gov.br/contribuintes</Endereco>
26+
<Endereco Tipo="DownloadDanfse">https://adn.nfse.gov.br</Endereco>
27+
<Endereco Tipo="ConsultarChaveDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
28+
<Endereco Tipo="ConsultaExisteDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
29+
</Enderecos>
30+
</Ambiente>
31+
</Ambientes>
32+
</serviceInfo>
33+
<serviceInfo Id="3514106">
34+
<Tipo>SimplISS</Tipo>
35+
<Nome>DOIS CÓRREGOS</Nome>
36+
<UF>SP</UF>
37+
<Ambientes>
38+
<Ambiente Tipo="2">
39+
<Enderecos>
40+
<Endereco Tipo="Enviar">https://producaorestrita.simplissweb.com.br</Endereco>
41+
<Endereco Tipo="EnviarEvento">https://producaorestrita.simplissweb.com.br</Endereco>
42+
<Endereco Tipo="ConsultarNsu">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
43+
<Endereco Tipo="ConsultarChave">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
44+
<Endereco Tipo="DownloadDanfse">https://adn.producaorestrita.nfse.gov.br</Endereco>
45+
<Endereco Tipo="ConsultarChaveDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
46+
<Endereco Tipo="ConsultaExisteDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
47+
</Enderecos>
48+
</Ambiente>
49+
<Ambiente Tipo="1">
50+
<Enderecos>
51+
<Endereco Tipo="Enviar">https://nfsedoiscorregos.simplissweb.com.br</Endereco>
52+
<Endereco Tipo="EnviarEvento">https://nfsedoiscorregos.simplissweb.com.br</Endereco>
53+
<Endereco Tipo="ConsultarNsu">https://adn.nfse.gov.br/contribuintes</Endereco>
54+
<Endereco Tipo="ConsultarChave">https://adn.nfse.gov.br/contribuintes</Endereco>
55+
<Endereco Tipo="DownloadDanfse">https://adn.nfse.gov.br</Endereco>
56+
<Endereco Tipo="ConsultarChaveDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
57+
<Endereco Tipo="ConsultaExisteDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
58+
</Enderecos>
59+
</Ambiente>
60+
</Ambientes>
61+
</serviceInfo>
62+
<serviceInfo Id="3300100">
63+
<Tipo>Tiplan</Tipo>
64+
<Nome>ANGRA DOS REIS</Nome>
65+
<UF>RJ</UF>
66+
<Ambientes>
67+
<Ambiente Tipo="2">
68+
<Enderecos>
69+
<Endereco Tipo="Enviar">https://angrahomologacao.nfe.com.br/api</Endereco>
70+
<Endereco Tipo="EnviarEvento">https://angrahomologacao.nfe.com.br/api</Endereco>
71+
<Endereco Tipo="ConsultarNsu">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
72+
<Endereco Tipo="ConsultarChave">https://adn.producaorestrita.nfse.gov.br/contribuintes</Endereco>
73+
<Endereco Tipo="DownloadDanfse">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
74+
<Endereco Tipo="ConsultarChaveDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
75+
<Endereco Tipo="ConsultaExisteDps">https://sefin.producaorestrita.nfse.gov.br/SefinNacional</Endereco>
76+
</Enderecos>
77+
</Ambiente>
78+
<Ambiente Tipo="1">
79+
<Enderecos>
80+
<Endereco Tipo="Enviar">https://www.spe.angra.rj.gov.br/api</Endereco>
81+
<Endereco Tipo="EnviarEvento">https://www.spe.angra.rj.gov.br/api</Endereco>
82+
<Endereco Tipo="ConsultarNsu">https://adn.nfse.gov.br/contribuintes</Endereco>
83+
<Endereco Tipo="ConsultarChave">https://adn.nfse.gov.br/contribuintes</Endereco>
84+
<Endereco Tipo="DownloadDanfse">https://sefin.nfse.gov.br/sefinnacional</Endereco>
85+
<Endereco Tipo="ConsultarChaveDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
86+
<Endereco Tipo="ConsultaExisteDps">https://sefin.nfse.gov.br/sefinnacional</Endereco>
87+
</Enderecos>
88+
</Ambiente>
89+
</Ambientes>
90+
</serviceInfo>
91+
</Services>
6392
</NFSeServices>

src/OpenAC.Net.NFSe.Nacional/Webservice/NFSeServiceManager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ private NFSeServiceManager()
4949
{ VersaoNFSe.Ve100, typeof(SimplISS.SimplISSWebservice) },
5050
{ VersaoNFSe.Ve101, typeof(SimplISS.SimplISSWebservice) }
5151
}
52+
},
53+
{
54+
NFSeProvider.Tiplan, new Dictionary<VersaoNFSe, Type>
55+
{
56+
{ VersaoNFSe.Ve100, typeof(Tiplan.TiplanWebService) },
57+
{ VersaoNFSe.Ve101, typeof(Tiplan.TiplanWebService) }
58+
}
5259
}
5360
};
5461

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// ***********************************************************************
2+
// Assembly : OpenAC.Net.NFSe.Nacional
3+
// Author : RGG
4+
// Created : 14-01-2026
5+
//
6+
// Last Modified By : RGG
7+
// Last Modified On : 14-01-2026
8+
// ***********************************************************************
9+
// <copyright file="TiplanWebService.cs" company="OpenAC .Net">
10+
// The MIT License (MIT)
11+
// Copyright (c) 2014-2026 Grupo OpenAC.Net
12+
//
13+
// Permission is hereby granted, free of charge, to any person obtaining
14+
// a copy of this software and associated documentation files (the "Software"),
15+
// to deal in the Software without restriction, including without limitation
16+
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17+
// and/or sell copies of the Software, and to permit persons to whom the
18+
// Software is furnished to do so, subject to the following conditions:
19+
// The above copyright notice and this permission notice shall be
20+
// included in all copies or substantial portions of the Software.
21+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27+
// DEALINGS IN THE SOFTWARE.
28+
// </copyright>
29+
// <summary></summary>
30+
// ***********************************************************************
31+
32+
using OpenAC.Net.Core.Logging;
33+
using OpenAC.Net.NFSe.Nacional.Common;
34+
using OpenAC.Net.NFSe.Nacional.Common.Model;
35+
using OpenAC.Net.NFSe.Nacional.Common.Types;
36+
using OpenAC.Net.NFSe.Nacional.Webservice.Nacional;
37+
using System;
38+
using System.Net.Http;
39+
using System.Net.Http.Json;
40+
using System.Text.Json;
41+
using System.Threading.Tasks;
42+
43+
namespace OpenAC.Net.NFSe.Nacional.Webservice.Tiplan;
44+
/// <summary>
45+
/// Classe de serviço web para integração com a Tiplan.
46+
/// </summary>
47+
public class TiplanWebService : NacionalWebservice
48+
{
49+
private static readonly JsonSerializerOptions JsonOptions = new()
50+
{
51+
PropertyNameCaseInsensitive = true,
52+
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
53+
};
54+
55+
/// <summary>
56+
/// Construtor da classe TiplanWebService.
57+
/// </summary>
58+
/// <param name="configuracaoNFSe"></param>
59+
/// <param name="serviceInfo"></param>
60+
public TiplanWebService(ConfiguracaoNFSe configuracaoNFSe, NFSeServiceInfo serviceInfo) :
61+
base(configuracaoNFSe, serviceInfo)
62+
{
63+
}
64+
/// <summary>
65+
/// Envio da DPS para geração da NFS-e de forma assíncrona.
66+
/// </summary>
67+
/// <param name="dps"></param>
68+
/// <returns></returns>
69+
/// <exception cref="InvalidOperationException"></exception>
70+
public override async Task<NFSeResponse<RespostaEnvioDps>> EnviarAsync(Dps dps)
71+
{
72+
dps.Assinar(Configuracao);
73+
74+
ValidarSchema(SchemaNFSe.DPS, dps.Xml, dps.Versao);
75+
76+
string documento = dps.Informacoes.Prestador.CPF ?? dps.Informacoes.Prestador.CNPJ ?? throw new InvalidOperationException("CPF ou CNPJ do prestador deve ser informado.");
77+
78+
GravarDpsEmDisco(dps.Xml, $"{dps.Informacoes.NumeroDps:000000}_dps.xml",
79+
documento, dps.Informacoes.DhEmissao.DateTime);
80+
81+
DpsEnvio envio = new DpsEnvio { XmlDps = dps.Xml };
82+
JsonContent content = JsonContent.Create(envio);
83+
string strEnvio = await content.ReadAsStringAsync();
84+
85+
this.Log().Debug($"Tiplan: [Enviar][Envio] - {strEnvio}");
86+
87+
GravarArquivoEmDisco(strEnvio, $"Enviar-{dps.Informacoes.NumeroDps:000000}-env.json", documento);
88+
89+
string url = ServiceInfo[Configuracao.WebServices.Ambiente][TipoUrl.Enviar] ?? throw new InvalidOperationException("URL de envio não encontrada na configuração do serviço.");
90+
HttpResponseMessage httpResponse = await SendAsync(content, HttpMethod.Post, $"{url}/adn/dps/recepcao");
91+
92+
string strResponse = await httpResponse.Content.ReadAsStringAsync();
93+
94+
this.Log().Debug($"Tiplan: [Enviar][Resposta] - {strResponse}");
95+
96+
GravarArquivoEmDisco(strResponse, $"Enviar-{dps.Informacoes.NumeroDps:000000}-resp.json", documento);
97+
98+
return NFSeResponse<RespostaEnvioDps>.Create(dps.Xml, strEnvio, strResponse, httpResponse.IsSuccessStatusCode, JsonOptions);
99+
}
100+
/// <summary>
101+
/// Envio de evento assincrono.
102+
/// </summary>
103+
/// <param name="evento"></param>
104+
/// <returns></returns>
105+
/// <exception cref="InvalidOperationException"></exception>
106+
public override async Task<NFSeResponse<RespostaEnvioEvento>> EnviarEventoAsync(PedidoRegistroEvento evento)
107+
{
108+
evento.Assinar(Configuracao);
109+
ValidarSchema(SchemaNFSe.Evento, evento.Xml, evento.Versao);
110+
111+
string? documento = evento.Informacoes.CPFAutor ?? evento.Informacoes.CNPJAutor ?? throw new InvalidOperationException("CPF ou CNPJ do autor do evento deve ser informado.");
112+
113+
GravarDpsEmDisco(evento.Xml, $"{evento.Informacoes.ChNFSe}{evento.Informacoes.Evento}_evento.xml",
114+
documento, evento.Informacoes.DhEvento.DateTime);
115+
116+
EventoEnvio envio = new EventoEnvio { XmlEvento = evento.Xml };
117+
JsonContent content = JsonContent.Create(envio);
118+
string strEnvio = await content.ReadAsStringAsync();
119+
120+
this.Log().Debug($"Tiplan: [Evento][Envio] - {strEnvio}");
121+
122+
GravarArquivoEmDisco(strEnvio, $"Evento-{evento.Informacoes.ChNFSe}{evento.Informacoes.Evento}-env.json", documento);
123+
124+
string url = ServiceInfo[Configuracao.WebServices.Ambiente][TipoUrl.EnviarEvento] ?? throw new InvalidOperationException("URL de envio não encontrada na configuração do serviço.");
125+
HttpResponseMessage httpResponse = await SendAsync(content, HttpMethod.Post, $"{url}/adn/dps/evento");
126+
127+
string strResponse = await httpResponse.Content.ReadAsStringAsync();
128+
129+
this.Log().Debug($"Tiplan: [Evento][Resposta] - {strResponse}");
130+
131+
GravarArquivoEmDisco(strResponse, $"Evento-{evento.Informacoes.ChNFSe}{evento.Informacoes.Evento}-resp.json", documento);
132+
133+
return NFSeResponse<RespostaEnvioEvento>.Create(evento.Xml, strEnvio, strResponse, httpResponse.IsSuccessStatusCode, JsonOptions);
134+
}
135+
136+
}

0 commit comments

Comments
 (0)