RomaniaEFacturaLibrary 1.0.1
See the version list below for details.
dotnet add package RomaniaEFacturaLibrary --version 1.0.1
NuGet\Install-Package RomaniaEFacturaLibrary -Version 1.0.1
<PackageReference Include="RomaniaEFacturaLibrary" Version="1.0.1" />
<PackageVersion Include="RomaniaEFacturaLibrary" Version="1.0.1" />
<PackageReference Include="RomaniaEFacturaLibrary" />
paket add RomaniaEFacturaLibrary --version 1.0.1
#r "nuget: RomaniaEFacturaLibrary, 1.0.1"
#:package RomaniaEFacturaLibrary@1.0.1
#addin nuget:?package=RomaniaEFacturaLibrary&version=1.0.1
#tool nuget:?package=RomaniaEFacturaLibrary&version=1.0.1
Romania EFactura Library
A comprehensive C# library for integrating with the Romanian EFactura (SPV - Spatiu Privat Virtual) system from ANAF.
🚀 Quick Links
- 📋 Implementation Guide - Complete step-by-step setup
- ⚙️ Configuration Guide - All configuration options
- 📦 Publishing Guide - NuGet publishing instructions
- 📊 Project Summary - Complete project overview
Overview
This library provides a complete solution for:
- Authentication with ANAF using OAuth2 and digital certificates
- UBL 2.1 XML invoice creation and validation
- API Integration with ANAF test and production environments
- Invoice Management (upload, download, status tracking)
- XML Processing with proper namespace handling and validation
📁 Repository Structure
RomaniaEFacturaLibrary/
- Main library with all EFactura functionalityRomaniaEFacturaConsole/
- Interactive console application for testingRomaniaEFacturaLibrary.Tests/
- Comprehensive unit test suite (29 tests)ExampleBlazorUsage/
- Example Blazor application implementationdocumentation_efactura/
- Official ANAF documentation and guides- Documentation Files:
IMPLEMENTATION_GUIDE.md
- Step-by-step implementation guideCONFIGURATION_GUIDE.md
- Complete configuration referencePUBLISHING_GUIDE.md
- NuGet publishing instructionsPROJECT_SUMMARY.md
- Project overview and status
Features
🔐 Authentication
- OAuth2 authorization code flow with ANAF
- Client credentials (ClientId, ClientSecret) from ANAF application registration
- Automatic token management and refresh
- Support for test and production environments
📄 UBL 2.1 XML Support
- Complete UBL 2.1 invoice models
- Proper XML serialization/deserialization
- Romanian EFactura-specific customizations
- XML validation and formatting
🌐 ANAF API Integration
- Upload invoices to ANAF SPV
- Check upload status and validation results
- Download invoices and attachments
- List recent invoices with filtering
🏗️ ASP.NET Core Ready
- Dependency injection support
- Configuration-based setup
- Logging integration
- Easy integration with web applications
Quick Start
1. Installation
Add the library to your project:
<PackageReference Include="RomaniaEFacturaLibrary" Version="1.0.0" />
2. Configuration
Configure in appsettings.json
:
{
"EFactura": {
"Environment": "Test",
"ClientId": "your-anaf-client-id",
"ClientSecret": "your-anaf-client-secret",
"RedirectUri": "https://yourapp.com/auth/callback",
"TimeoutSeconds": 30
}
}
3. Dependency Injection Setup
// In Program.cs or Startup.cs
services.AddEFacturaServices(configuration);
// Or with custom configuration
services.AddEFacturaServices(options =>
{
options.Environment = EFacturaEnvironment.Test;
options.ClientId = "your-client-id";
options.ClientSecret = "your-client-secret";
options.RedirectUri = "https://yourapp.com/auth/callback";
});
4. Basic Usage
public class AuthController : ControllerBase
{
private readonly IAuthenticationService _authService;
public AuthController(IAuthenticationService authService)
{
_authService = authService;
}
[HttpGet("login")]
public IActionResult Login()
{
// Step 1: Get authorization URL for ANAF OAuth
var authUrl = _authService.GetAuthorizationUrl("efactura", "unique-state");
return Redirect(authUrl);
}
[HttpGet("callback")]
public async Task<IActionResult> Callback(string code, string state)
{
// Step 2: Exchange authorization code for access token
var token = await _authService.ExchangeCodeForTokenAsync(code);
if (token != null)
{
// Store token securely (session, database, etc.)
_authService.SetToken(token);
return Ok("Authentication successful");
}
return BadRequest("Authentication failed");
}
}
public class InvoiceController : ControllerBase
{
private readonly IEFacturaClient _eFacturaClient;
public InvoiceController(IEFacturaClient eFacturaClient)
{
_eFacturaClient = eFacturaClient;
}
[HttpPost("upload")]
public async Task<IActionResult> UploadInvoice([FromBody] UblInvoice invoice)
{
// Upload to ANAF (token will be automatically used)
var result = await _eFacturaClient.UploadInvoiceAsync(invoice);
if (result.IsSuccess)
{
return Ok(new { UploadId = result.UploadId });
}
return BadRequest(result.Errors);
}
}
Testing
Run the test suite:
dotnet test RomaniaEFacturaLibrary.Tests
Use the console application for interactive testing:
cd RomaniaEFacturaConsole
dotnet run
Requirements
- .NET 9.0 or later
- ANAF Application Registration (ClientId and ClientSecret)
- Registered Redirect URI with ANAF for OAuth callback
Key Dependencies
Microsoft.Extensions.DependencyInjection
- Dependency injectionMicrosoft.Extensions.Logging
- Logging frameworkMicrosoft.Extensions.Http
- HTTP client factorySystem.Security.Cryptography.X509Certificates
- Certificate handlingSystem.Text.Json
- JSON serialization
Build Status
✅ Solution builds successfully
✅ All 29 unit tests pass
✅ Release configuration ready
✅ Multi-target support (.NET 8.0 and .NET 9.0)
✅ NuGet package ready
🔗 Repository Information
- GitHub Repository: https://github.com/lucianbumb/RomaniaEFacturaSolution
- Package ID:
RomaniaEFacturaLibrary
- Current Version:
1.0.0
- License: MIT
Contributing
This library follows Romanian EFactura specifications and UBL 2.1 standards.
License
This project is provided as-is for educational and development purposes. Please ensure compliance with ANAF regulations and Romanian law when using in production.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Console (>= 9.0.0)
- Microsoft.Extensions.Logging.Debug (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- System.Security.Cryptography.X509Certificates (>= 4.3.2)
- System.Text.Json (>= 9.0.0)
- System.Xml.XmlSerializer (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release with full EFactura integration support including OAuth2 authentication, UBL 2.1 XML processing, and ANAF API client.