CASE STUDY

ERP and CRM Integration with KSeF - MPED KSeF Gateway Platform

KSeF logo

Challenge

The introduction of the Polish National e-Invoicing System (KSeF) requires companies to adapt their ERP and CRM systems to new electronic invoicing regulations.

Most existing business platforms were not designed to integrate directly with a government-operated asynchronous invoicing platform, which creates significant technical and operational challenges.

The most common issues include:

  • handling asynchronous communication with KSeF,
  • preventing duplicate invoice submissions,
  • tracking document status and KSeF identifiers,
  • retrieving and archiving UPO (official receipt confirmations),
  • ensuring security and regulatory compliance,
  • maintaining enterprise-grade operational stability and readiness.

In practice, this creates the need for a stable middleware layer that separates ERP and CRM systems from the external state platform.

Solution

MPED designed and implemented its own integration platform, MPED KSeF Gateway, which acts as a middleware layer between ERP/CRM systems and the KSeF platform.

The system exposes a consistent integration API, allowing business systems to submit invoices and retrieve processing information without communicating with KSeF directly.

MPED KSeF Gateway:

  • accepts invoices from ERP or CRM systems through API,
  • assigns correlation identifiers to documents,
  • queues invoices and processes them asynchronously in the background,
  • sends documents to KSeF,
  • monitors processing status,
  • retrieves and stores UPO confirmations and KSeF identifiers.

The platform was designed to support integration with both widely used business systems and custom-built client platforms.

Official GOV video introducing the KSeF context: https://youtu.be/rkOGprn4i_g.

MPED has prepared connectors and integration capabilities for systems such as:

  • HubSpot
  • Microsoft Dynamics
  • NetSuite
  • SAP
  • Xero
  • QuickBooks

and also delivers integration with custom ERP and CRM systems.

Functionality

MPED KSeF Gateway provides a complete integration platform for handling electronic invoices in the KSeF ecosystem.

  • receiving invoices from ERP and CRM systems via API,
  • validating input data,
  • duplicate control through idempotency,
  • queueing documents for asynchronous processing,
  • sending invoices to KSeF,
  • assigning and storing correlation identifiers for each invoice,
  • checking invoice status in KSeF,
  • retrieving the KSeF number and processing details,
  • automatic retrieval and archiving of UPO,
  • exposing API endpoints for status checks and UPO download,
  • handling incoming invoices from KSeF in pull mode,
  • storing technical artefacts and audit data,
  • resilience through retry, throttling, circuit breaker and DLQ mechanisms,
  • system monitoring, health checks and operational alerting,
  • secure secret management with Key Vault and Managed Identity,
  • redaction of sensitive data in logs,
  • multi-tenant deployments and environment isolation per client,
  • replay capability and process recovery after failure.

Technologies

  • C# / .NET 8
  • Azure Functions (isolated worker model)
  • Azure Service Bus for queues and asynchronous communication
  • Azure Storage (Blob Storage and Table Storage) for data and artefact storage
  • Azure Key Vault for secrets and token management
  • Managed Identity for secure service-to-service communication
  • Application Insights and Log Analytics for monitoring and logging
  • Bicep as Infrastructure as Code
  • Azure DevOps Pipelines for deployment automation
  • REST API (HTTP) for ERP and external system integration
  • JSON and XML as data exchange formats
  • official KSeF SDK / C# client for communication with KSeF
  • resilience mechanisms such as retry, circuit breaker and throttling
  • automated tests and end-to-end scenarios

Results

The implementation of MPED KSeF Gateway resulted in a scalable and resilient integration platform capable of processing high volumes of documents.

  • structured ERP/CRM integration process with KSeF,
  • automated invoice submission and document status handling,
  • full traceability of the invoicing process,
  • elimination of duplicate invoice submissions,
  • increased stability through asynchronous processing,
  • a central integration platform reusable across multiple clients and ERP systems.

Summary

MPED KSeF Gateway is an integration platform designed as a middleware layer between ERP and CRM systems and the Polish KSeF platform.

The solution automates the entire e-invoicing workflow:

  • receiving invoices from business systems,
  • validating data,
  • queueing documents,
  • sending them to KSeF,
  • tracking processing status,
  • retrieving and archiving UPO confirmations.

The architecture, based on Azure Functions, Service Bus and Azure Storage, separates the API layer from asynchronous processing, ensuring scalability and resilience during high load or temporary KSeF unavailability.

By using mechanisms such as idempotency, retry, DLQ, secure secret management and multi-tenant deployment, the solution is ready for enterprise environments and integration with multiple ERP and CRM systems.