A Pix Automático engine for .NET 8: recurrences and the four authorization journeys, the 2–10 day scheduling window, the 00:00–08:00 and 18:00–21:00 settlement windows, PERMITE_3R_7D retries, the payer's maximum value and daily limit and the cancellation cut-offs, all on a simulated clock, plus the Brazilian banking calendar and the QR payloads of journeys 2–4.
It is a port of pix-automatico-go and the two are transcript-identical: the same script produces the same identifiers, outcomes, error messages and event log, byte for byte. The test suite replays the Go examples plus 40 randomized scripts generated by the Go implementation, and checks 21 years of holidays, cycle arithmetic and QR payloads against it.
No dependencies beyond the .NET 8 base class library. Trimming and AOT compatible.
src/PixAutomatico/
Calendar/ DateOnly cycle arithmetic, national banking holidays, business-day adjustment
Engine/ PixAutomaticoEngine: recurrences, journeys, scheduling, settlement, retries, cancellations
BrCode/ Pix Copia e Cola payloads with template 80, CRC16
Scenarios/ the script language shared with the Go implementation
tests/PixAutomatico.Tests/ unit tests and Go parity tests
samples/PixAutomatico.Demo/ a subscription over three months, fast-forwarded
tools/vecgen/ Go program that generates the parity vectors
dotnet run --project samples/PixAutomatico.Demo-- 2027-01-10: first window failed, the payer tops up before 18:00
-- February charge after a 22:30 cancellation on the eve: CONCLUIDA (kept: D+2 rule)
2026-11-27 10:00 rec.criada RR123456782026112700000000001 jornada 2 MENSAL R$ 39,90 PERMITE_3R_7D
2026-11-30 09:00 cobr.agendada AUT12345678000000000000000000002 R$ 39,90 vencimento 2026-12-10 ciclo 0
2026-12-10 00:00 cobr.liquidada AUT12345678000000000000000000002 R$ 39,90 janela 1 (AGND)
2027-01-10 00:00 cobr.janela1.falhou AUT12345678000000000000000000003 saldo insuficiente
2027-01-10 18:00 cobr.liquidada AUT12345678000000000000000000003 R$ 39,90 janela 2 (AGND)
2027-02-09 22:30 rec.cancelada RR123456782026112700000000001 por PAGADOR: assinatura encerrada; débitos a partir de 2027-02-11 cancelados
2027-02-10 00:00 cobr.liquidada AUT12345678000000000000000000004 R$ 39,90 janela 1 (AGND)
...
using PixAutomatico.Calendar;
using PixAutomatico.Engine;
var engine = new PixAutomaticoEngine(new DateOnly(2026, 11, 27).At(10, 0), ispb: "12345678");
engine.SetAccount("12345678909", new Money(100_00), Money.Zero);
Recurrence rec = engine.CreateRecurrence(new RecRequest
{
Contract = "ASSINATURA-778",
Debtor = new Debtor("12345678909", "Maria Souza"),
Start = new DateOnly(2026, 12, 10),
Periodicity = "MENSAL",
FixedValue = new Money(39_90),
RetryPolicy = "PERMITE_3R_7D",
Journey = 2,
});
engine.Approve(rec.Id);
engine.AdvanceTo(new DateOnly(2026, 11, 30), 9, 0);
Charge charge = engine.ScheduleCharge(new ChargeRequest(rec.Id, new DateOnly(2026, 12, 10), new Money(39_90)));
engine.AdvanceTo(new DateOnly(2026, 12, 10), 9, 0); // runs the 00:00 window
engine.GetCharge(charge.TxId).Status; // ChargeStatus.Settled (CONCLUIDA)Rule violations throw PixAutomaticoException with the API Pix error type
(RecOperacaoInvalida, CobrOperacaoInvalida, SolicRecOperacaoInvalida,
NaoEncontrado, PagamentoNaoRealizado) and a Portuguese detail.
Scenario scripts run the same in both languages:
string transcript = ScenarioRunner.Run(File.ReadAllText("energia.txt"));The rules, their sources and the script syntax are documented in the pix-automatico-go README.
MIT