This version has become obsolete; To implement the signing of the previous validation version, use the Efacturacolombia_V2.V2 module .
Efacturacolombia. It is an unofficial bookstore developed in C#, which allows sign XML documents (invoices and debit notes) that are presented to the DIAN of Colombia for the electronic billing process.
Since January 1, 2019, electronic billing for taxpayers in Colombia will be mandatory, and at present many companies and obligatory persons have not implemented it.
Although the technical information provided by the DIAN should be sufficient, finding .NET resources for this process turns out to be quite difficult. The generation of XML documents and web services can be laborious but can be done without inconvenience, however the firm required by the DIAN can be extremely difficult to do, to the point of being necessary to acquire expensive solutions.
This bookstore is released with the aim of facilitating implementation on .NET platforms.
In order to generate, sign and issue electronic documents (invoices and notes of debit/credit) before the DIAN, the following requirements must be met:
For more information see the resources available in DIAN - Electronic Billing.
The FirmaElectronica class contains a simple method (in three variants) to sign the electronic documents, which returns the array of bytes resulting:
using eFacturacionColombia ;
using eFacturacionColombia . Firma ;
// crear instancia
var firma = new FirmaElectronica
{
RolFirmante = RolFirmante . FACTURANTE ,
RutaCertificado = "path/to/certificate.p12" ,
ClaveCertificado = "password here"
} ;
// usar horario colombiano
var fecha = DateTimeHelper . GetColombianDate ( ) ;
// variante 1:
// firmar archivo
var archivoXml = new FileInfo ( "path/to/unsigned-factura.xml" ) ;
var bytesArchivoFirmado = firma . Firmar ( archivoXml , TipoDocumento . FACTURA , fecha ) ;
// variante 2:
// firmar contenido
var contenidoXml = "<?xml ..." ;
var bytesContenidoFirmado = firma . Firmar ( contenidoXml , TipoDocumento . FACTURA , fecha ) ;
// variante 3:
// firmar bytes
var bytesXml = new byte [ 13042 ] ;
var bytesXmlFirmado = firma . Firmar ( bytesXml , TipoDocumento . FACTURA , fecha ) ;
// guardar xml (opcional)
File . WriteAllBytes ( "path/to/signed-factura.xml" , bytesXmlFirmado ) ;If the technical validation of the firm generates the following error (from the web service):
com.indra.mmdd.signature.exceptions.ValidateException: xades4j.verification.CertRefUtils$1: Verification failed for property 'SigningCertificate': Invalid issue name
It means that the certificateissuername - generated by the library - of the firm is not valid, in this case request from the provider of the certificate the valid chain, and assign it manually using the EmisorCertificado property of the FirmaElectronica class:
var firma = new FirmaElectronica
{
RolFirmante = RolFirmante . FACTURANTE ,
RutaCertificado = "path/to/certificate.p12" ,
ClaveCertificado = "password here" ,
EmisorCertificado = "C=CO,L=Bogota D.C.,O=..."
} ; Note: The resulting by the process should not be modified (passing them to another coding or loading them in an XmlDocument ) before saving or compressing them to send them to the Dian because they will invalidate the firm.
This project uses the following bookstores:
Although this repository is not from Open-Contribution , it can be contributed:
Miguel Huertas [email protected]
Review details in the Bachelor Archive.
The author of this project, for time reasons, will not provide support for implementation unless it is something simple (without being obliged).
On the other hand, the author of this project, puts at your disposal a .NET payment solution for the entire electronic billing process as well as advice for its implementation .