Utilerias para la todo lo relacionado a la generacion del CFDI 3.3 del SAT México.
Esta libreria contiene utilidades desde el manejo de certificados con SSH, generación del XML, sellado del XML, utilerias generales como fechas, generación de QR, etc...
Use composer, so please run
composer require rdomenzain/cfdi33-utils
<?php
// create XML...
$comprobante = new Comprobante();
$comprobante->Serie = "0A";
$comprobante->Folio = "11";
$comprobante->FormaPago = "03";
$comprobante->...
$emisor = new Emisor();
$emisor->Rfc = "XAXX010101000";
$emisor->Nombre = "Publico General";
$emisor->RegimenFiscal = "608";
$comprobante->Emisor = $emisor;
$cfdi = new Cfdv33($comprobante, $rutaCert, $rutaKey);
// This XML is already signed by the certificate and primary key
// Is ready to send to the favorite PAC
echo $cfdi->getXml();
<?php
// Declare utils
$utlXml = new XmlUtils();
// Get original string from the XML
$cadenaOriginal = $utlXml->GeneraCadenaOriginal(file_get_contents($pathXml));
// generated sign from original string, this add to the XML
$sello = $this->utlXml->GeneralSelloCfdi33($cadenaOriginal, file_get_contents($rutaKey), $claveKey);
<?php
// Certificate utilities declared
$utlCert = new CertificadoUtils();
// Get the bash from to certificate, this add to the XML
$certificado = $utlCert->GeneraCertificado2Pem(file_get_contents($rutaCert));
// Get the certificate number from file .cer, this add to the XML
$noCertificado = $utlCert->GetNumCertificado(file_get_contents($rutaCert));
<?php
// Certificate utilities declared
$utlCert = new CertificadoUtils();
$utlCommons = new CommonsUtils();
// Get date format requiered for the XML
echo $utlCommons->GetFechaActualCFDI();
// Out: 2019-10-18T13:21:36
// Replace characters especial
echo $utlCommons->ReplaceEncodeUtf8('Asociados&Otros');
// Out: Asociados&Otros
// Formato to numbers
echo $utlCommons->FormatNumber(100, 2)
// Out: 100.00
// Validate certificate
echo $utlCert->ValidateCertificado(file_get_contents($rutaCert));
// Out: Certificado emitido por el SAT.
// Validate file primary key
echo $utlCert->ValidatePrivateKey(file_get_contents($rutaKey));
// Out: Certificado emitido por el SAT.
This library is compatible with PHP versions 7.0 and above. Please, try to use the full potential of the language.
Contributions are welcome! Please read CONTRIBUTING for details and don't forget to take a look in the TODO and CHANGELOG files.
The rdomenzain/cfdi33-utils library is copyright © Ricardo Domenzain M. and licensed for use under the MIT License (MIT). Please see LICENSE for more information.