Giter Club home page Giter Club logo

cfdi33-utils's Introduction

rdomenzain/cfdi33-utils

Source Code Issues Software License Total Downloads Pagina Web GIT

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...

Installation

Use composer, so please run

composer require rdomenzain/cfdi33-utils

How create XML CFDI 3.3

<?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();

How signed only the XML

<?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);

How get certificate and certificate number

<?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));

Otras utilidades sobre CFDI 33

<?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&amp;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.

PHP Support

This library is compatible with PHP versions 7.0 and above. Please, try to use the full potential of the language.

Contributing

Contributions are welcome! Please read CONTRIBUTING for details and don't forget to take a look in the TODO and CHANGELOG files.

Copyright and License

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.

cfdi33-utils's People

Contributors

rdomenzain avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.