Qualitysys.Pix.NET 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Qualitysys.Pix.NET --version 1.0.2                
NuGet\Install-Package Qualitysys.Pix.NET -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Qualitysys.Pix.NET" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Qualitysys.Pix.NET --version 1.0.2                
#r "nuget: Qualitysys.Pix.NET, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Qualitysys.Pix.NET as a Cake Addin
#addin nuget:?package=Qualitysys.Pix.NET&version=1.0.2

// Install Qualitysys.Pix.NET as a Cake Tool
#tool nuget:?package=Qualitysys.Pix.NET&version=1.0.2                

Seja bem vindo ao PIX.NET!

Esta biblioteca foi desenvolvida com o intuito de auxiliar na implementação de PIX em aplicações .NET. Baseada em .NET Standard para que possa funcionar com qualquer versão do .NET.

Dependências

  1. Newtonsoft (13.0.1) - Biblioteca para trabalhar com JSON.

Bancos Homologados

  • Banco do Brasil (Homologação e Produção)
  • Santander (Homologação e Produção)
  • Itaú (Homologação e Produção)
  • Sicoob (Homologação e Produção)
  • Bradesco (Em Testes)

Como Utilizar

A primeira coisa que deve-se atentar, é sobre a classe Model.ProvedorToken. Esta classe é do tipo enum, representando os bancos disponíveis com seus respectivos códigos:

  • NONE = 0,
  • SICOOB = 756,
  • Santander = 33,
  • BancoBrasil = 1,
  • Itau = 341,
  • Bradesco = 237

1. Para iniciar o fluxo do código, precisamos definir qual banco será utilizado:

ProvedorToken psp = (ProvedorToken)Enum.Parse(typeof(ProvedorToken), "33");

2. Com o banco definido, precisamos instanciar o objeto PixPayload:

PixPayload payload = new PixPayload
{
    calendario = new Calendario
    {
        expiracao = 3600
    },
    chave = "suachavepix@email.com",
    valor = new Valor
    {
        original = "1122.43"
    },
    txid = "TESTE000000000000000000000000000001",
    solicitacaoPagador = "Descrição da transação",
    devedor = new Devedor {
	    nome = "Fulano de tal",
	    cpf = "00000000000" //cnpj
    },
    infoAdicionais = new List<InfoAdicionais>
    {
	    new InfoAdicionais 
	    {
		    nome = "Info 1",
		    valor = "Valor info 1"
	    }
	}
};

📝 NOTE: Vale ressaltar que a classe Devedor() aceita tanto o atributo cpf quanto cnpj.

3. Definir o objeto de credenciais:

Credentials credentials = new Credentials
{
    clientId = "xxxxxxxxxxxxxx",
    clientSecret = "yyyyyyyyyyyy",
    developerKey = "zzzzzzzzzzzzzzzzzzz"
};

📝 NOTE: O Atributo developerKey deve ser setado para os bancos:

  • Banco do Brasil

4. Definir o certificado digital (obrigatório em ambiente de produção):

byte[] cer = System.IO.File.ReadAllBytes("Path do arquivo PFX");
string password = "password";

5. Iniciando a classe PIX:

5.1. Criando uma cobrança imediata

Com async/await:

using PIX pix = new PIX(payload, credentials, psp, cer, password, PixAmbiente.Homologacao);
pix.SetNomeRazaoSocial("Nome da empresa proprietária da chave");
pix.SetCidade("Cidade Sede");
PixPayload cob = await pix.CreateCobrancaAsync();

Sem async:

using PIX pix = new PIX(payload, credentials, psp, cer, password, PixAmbiente.Homologacao);
pix.SetNomeRazaoSocial("Nome da empresa proprietária da chave");
pix.SetCidade("Cidade Sede");
PixPayload cob = pix.CreateCobranca();

5.2. Consultando uma cobrança imediata:

Com async/await:

PixPayload cob = await pix.ConsultaCobrancaAsync("txid");

Sem async/await:

PixPayload cob = pix.ConsultaCobranca("txid");

5.3. Listando cobranças:

Com async/await:

PixRecebidosPayload payload = new PixRecebidosPayload
 {
     fim = DateTime.Now.Date,
     inicio = DateTime.Now.Date,
 };

 using PIX pix = new PIX(payload, credentials, psp, cer, request.password, request.ambiente);
 var lista = await pix.ConsultaPixRecebidosAsync();

Sem async/await:

PixRecebidosPayload payload = new PixRecebidosPayload
 {
     fim = DateTime.Now.Date,
     inicio = DateTime.Now.Date,
 };

 using PIX pix = new PIX(payload, credentials, psp, cer, request.password, request.ambiente);
 var lista = pix.ConsultaPixRecebidos();

Créditos

  • Autor: Eduardo Carvalho Costa
  • Email: eduardoccosta@outlook.com
  • Analista de sistemas: Quality Systems

Dúvidas somente pelo GitHub

Licença

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 279 7/7/2022
1.0.2 244 7/7/2022
1.0.1 243 7/7/2022
1.0.0 237 7/7/2022