P88.KSeF.Interop 2.0.0.5

dotnet add package P88.KSeF.Interop --version 2.0.0.5
                    
NuGet\Install-Package P88.KSeF.Interop -Version 2.0.0.5
                    
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="P88.KSeF.Interop" Version="2.0.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="P88.KSeF.Interop" Version="2.0.0.5" />
                    
Directory.Packages.props
<PackageReference Include="P88.KSeF.Interop" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add P88.KSeF.Interop --version 2.0.0.5
                    
#r "nuget: P88.KSeF.Interop, 2.0.0.5"
                    
#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.
#:package P88.KSeF.Interop@2.0.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=P88.KSeF.Interop&version=2.0.0.5
                    
Install as a Cake Addin
#tool nuget:?package=P88.KSeF.Interop&version=2.0.0.5
                    
Install as a Cake Tool

Instalacja

  1. Dodaj źródło GitHub Packages CIRFMF
  2. Dodaj paczkę KSeF.Client.Core
  3. Dodaj paczkę P88.KSeF.Interop
  4. Zainstaluj KSeF.Interop.Server
    • Metoda 1
      1. Edytuj app.manifest (Dodaj > Nowy element > Plik manifestu aplikacji)
        <?xml version="1.0" encoding="utf-8"?>
        <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
          <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
        
          <dependency>
            <dependentAssembly>
              <assemblyIdentity type="win32" name="KSeF.Interop.Server.X" version="2.0.0.3"/>
            </dependentAssembly>
          </dependency>
        
        </assembly>
        
      2. Ustaw Platform target na x64
      3. Wypakuj KSeF.Interop.Server.2.0.0.3.zip do KSeF.Interop.Server.X w katalogu aplikacji (np. bin\Debug\KSeF.Interop.Server.X).
    • Metoda 2 (Wymaga uprawnień administratora)
      1. Wypakuj KSeF.Interop.Server.2.0.0.3.zip.
      2. Uruchom register.ps1 jako administrator.
    • Metoda 3 (Wymaga uprawnień administratora)
      1. Wypakuj KSeF.Interop.Server.2.0.0.3.zip.
      2. Uruchom cmd jako administrator.
      3. W cmd uruchom:
        regsvr32 /s "ścieżka_do_folderu\KSeF.Interop.Server.comhost.dll"
        

Użycie

Inicjalizacja

KsefClient ksef = new KsefClient(connectionString: "Data Source=1.2.3.4;Initial Catalog=db;User ID=user;Password=password;TrustServerCertificate=True;");
await ksef.InitializeAsync(login: "login", nip: "1234567890");
await ksef.AuthenticateAsync();

Wysyłka pojedynczej faktury (sesja interaktywna)

// Wyślij fakturę
SendOnlineInvoiceResponse sendInvoiceResponse = await ksef.SendInvoiceAsync(invoiceId: 12345);

// Poczekaj na przetworzenie
SessionStatusResponse sessionStatusResponse = await ksef.PollSessionAsync(sendInvoiceResponse.SessionReferenceNumber);

// Pobierz przetworzoną fakturę
SessionInvoice sessionInvoice = await ksef.GetSessionInvoiceAsync(sendInvoiceResponse.SessionReferenceNumber, sendInvoiceResponse.ReferenceNumber);
// Wyślij fakturę
SendOnlineInvoiceResponse sendInvoiceResponse = await ksef.SendInvoiceAsync(invoiceId: 12345);

// Poczekaj na przetworzenie
SessionInvoice sessionInvoice;
do
{
    sessionInvoice = await ksef.GetSessionInvoiceAsync(sendInvoiceResponse.SessionReferenceNumber, sendInvoiceResponse.ReferenceNumber);
    await Task.Delay(1000);
} while (sessionInvoice.Status.Code < 200);

Wysyłka wielu faktur (sesja wsadowa)

// Wyślij faktury
SendBatchInvoiceResponse  sendInvoicesResponse = await ksef.SendInvoiceAsync(invoiceIds: [624, 625, 626]);

// Poczekaj na przetworzenie
SessionStatusResponse sessionStatusResponse = await ksef.PollSessionAsync(sendInvoicesResponse.SessionReferenceNumber);

// Pobierz przetworzone faktury
List<SessionInvoice> sessionInvoices = await ksef.GetSessionInvoicesAsync(sendInvoiceResponse.SessionReferenceNumber);
// Wyślij faktury
SendBatchInvoiceResponse sendInvoicesResponse = await ksef.SendInvoicesAsync(invoiceIds: [624, 625, 626]);

// Poczekaj na przetworzenie
List<SessionInvoice> sessionInvoices;
int processing, success, error;
do
{
    sessionInvoices = await ksef.GetSessionInvoicesAsync(sendInvoiceResponse.SessionReferenceNumber);
    processing = sessionInvoices.Count(x => x.Status.Code < 200);
    success = sessionInvoices.Count(x => x.Status.Code == 200);
    error = sessionInvoices.Count(x => x.Status.Code > 200);
    await Task.Delay(1000);
} while (sessionInvoices.Count < <InvoiceIds>.Length || processing > 0);

Pobieranie listy faktur

// Przykładowy filtr: faktury sprzedażowe z ostatnich 30 dni
InvoiceQueryFilters filters = new InvoiceQueryFilters()
{
    SubjectType = InvoiceSubjectType.Subject1,
    DateRange = new DateRange()
    {
        DateType = DateType.Invoicing,
        From = DateTime.UtcNow.AddDays(-30),
    },
};

// Pobierz listę faktur
List<InvoiceSummary> invoices = [];
PagedInvoiceResponse queryResponse;
do
{
    const int maxPageSize = 250;
    queryResponse = await ksef.QueryInvoices(filters, pageOffset: invoices.Count / maxPageSize, pageSize: maxPageSize);
    invoices.AddRange(queryResponse.Invoices);
} while (queryResponse is { HasMore: true, IsTruncated: false });

Eksport faktur

// Przykładowy filtr: faktury zakupowe z ostatnich 7 dni
InvoiceExportFilters filters = new InvoiceExportFilters()
{
    SubjectType = InvoiceSubjectType.Subject2,
    DateRange = new DateRange()
    {
        DateType = DateType.Invoicing,
        From = DateTime.UtcNow.AddDays(-7),
    },
};

// Eksport faktur
PackageProcessingResult packageResult = await ksef.ExportInvoicesAsync(filters);
foreach (var metadata in packageResult.MetadataSummaries)
{
    string xmlContent = packageResult.InvoiceXmlFiles[$"{metadata.KsefNumber}.xml"];
}

Generowanie linków weryfikacyjnych

var ksef = new KsefClient(connectionString);
await ksef.InitializeAsync(userId, nip);
// AuthenticateAsync() nie jest wymagane do generowania linków weryfikacyjnych

string invoiceVerificationUrl = await ksef.BuildInvoiceVerificationUrl(invoiceId: 12345);
string certificateVerificationUrl = await ksef.BuildCertificateVerificationUrl(invoiceId: 12345);
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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
2.0.0.5 139 1/22/2026
2.0.0.4 119 1/15/2026
2.0.0.3 123 1/9/2026
2.0.0.2 121 1/9/2026
2.0.0.1 125 1/7/2026
2.0.0 130 1/5/2026
0.6.1-rc1.3 154 12/23/2025
0.6.1-rc1.2 152 12/23/2025
0.6.1-rc1 188 12/22/2025