Facturacion Electronica - Sunat en PHP

123 views
Skip to first unread message

Miguel Panuera

unread,
Nov 23, 2016, 2:39:39 PM11/23/16
to PHP Perú
Buenas tardes, 

Actualmente estoy implementando facturación electronica, para una empresa, a lo cual he tenido algunos inconvenientes, quisiera saber si alguno de ustedes ha llegado a implementar la generación, firma y envío de la facturacion electronica con PHP.

Si fuera asi, me gustaria saber con que librerías realizo cada procedimiento. o en todo caso, si me podria dar una asesoria, a lo cual agradeceria me envie un correo con sus pretensiones económicas a mpan...@gmail.com.

Saludos y Gracias.

Francis Angelino Gonzales Tello

unread,
Nov 23, 2016, 2:41:56 PM11/23/16
to php...@googlegroups.com
Hola Miguel,

En mi trabajo ya implementamos facturación electrónica hace 2 años y liberamos la librería que modificamos

para hacer el firmado de los xml, el repo es https://github.com/xmlseclibs


Best Regards,

Francis A. Gonzales Tello / Informatic
fgonzale...@gmail.com / +51988301243

www.francis-gonzales.info

Twitter LinkedIn Github Wordpress


--
You received this message because you are subscribed to the Google Groups "PHP Perú" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phpperu+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Miguel Panuera

unread,
Nov 23, 2016, 2:48:13 PM11/23/16
to php...@googlegroups.com

Muchas Gracias, lo voy a revisar en estos momentos.


You received this message because you are subscribed to a topic in the Google Groups "PHP Perú" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phpperu+unsubscribe@googlegroups.com.

Miguel Panuera

unread,
Nov 25, 2016, 11:28:14 AM11/25/16
to php...@googlegroups.com, fgonzale...@gmail.com
Buenos dias, Francis

Estoy probando el codigo y de verdad, me es de mucha ayuda, pero tengo una duda, 
cuando firmo un documento estoy usando esto:

require 'AdapterInterface.php';
require 'XmlseclibsAdapter.php';
require 'xmlseclibs-master/xmlseclibs.php';

$ReferenceNodeName = 'ExtensionContent';
$privateKey = file_get_contents('files/privKey.pem');

$domDocument = new \DOMDocument();
$objSign = new \FR3D\XmlDSig\Adapter\XmlseclibsAdapter();

$domDocument->load('archivo.xml');
$objSign->setDigestAlgorithm();
$objSign->setPrivateKey($privateKey);
$objSign->setPublicKey($privateKey);
$objSign->addTransform(\FR3D\XmlDSig\Adapter\XmlseclibsAdapter::ENVELOPED);
$objSign->setCanonicalMethod();

$objSign->sign($domDocument, $domDocument->getElementsByTagName($ReferenceNodeName)->item(0));

me genera la firma, pero cuando reviso en el tag KeyInfo, me envia vacio, derrepente porque me falta adicionar alguna funcion, espero me pueda ayudar, muchas gracias.

<ds:KeyInfo><ds:X509Data/></ds:KeyInfo>

--
Miguel Panuera, 
Jefe de Proyectos
IUVADE SRL.
Soluciones Integrales
mpanuera[AT]gmail.com
RPC  958335798

Yannick Warnier

unread,
Nov 25, 2016, 11:33:39 AM11/25/16
to php...@googlegroups.com
No sería mejor que hagan debug a través de issues de Github? :-p

Le 25/11/16 à 11:27, Miguel Panuera a écrit :
> Buenos dias, Francis
>
> Estoy probando el codigo y de verdad, me es de mucha ayuda, pero tengo
> una duda,
> cuando firmo un documento estoy usando esto:
>
> require 'AdapterInterface.php';
> require 'XmlseclibsAdapter.php';
> require 'xmlseclibs-master/xmlseclibs.php';
>
> $ReferenceNodeName = 'ExtensionContent';
> $privateKey = file_get_contents('files/privKey.pem');
>
> $domDocument = new \DOMDocument();
> $objSign = new \FR3D\XmlDSig\Adapter\XmlseclibsAdapter();
>
> $domDocument->load('archivo.xml');
> $objSign->setDigestAlgorithm();
> $objSign->setPrivateKey($privateKey);
> $objSign->setPublicKey($privateKey);
> $objSign->addTransform(\FR3D\XmlDSig\Adapter\XmlseclibsAdapter::ENVELOPED);
> $objSign->setCanonicalMethod();
>
> $objSign->sign($domDocument,
> $domDocument->getElementsByTagName($ReferenceNodeName)->item(0));
>
> me genera la firma, pero cuando reviso en el tag KeyInfo, me envia
> vacio, derrepente porque me falta adicionar alguna funcion, espero me
> pueda ayudar, muchas gracias.
>
> <ds:KeyInfo><ds:X509Data/></ds:KeyInfo>
>
>
> El 23 de noviembre de 2016, 14:48, Miguel Panuera<mpan...@gmail.com
> <mailto:mpan...@gmail.com>> escribió:
>
> Muchas Gracias, lo voy a revisar en estos momentos.
>
>
> El 23/11/2016 14:41, "Francis Angelino Gonzales Tello"
> <f.gonzale...@gmail.com <mailto:f.gonzale...@gmail.com>>
> escribió:
>
> Hola Miguel,
>
> En mi trabajo ya implementamos facturación electrónica hace 2
> años y liberamos la librería que modificamos
>
> para hacer el firmado de los xml, el repo
> es https://github.com/xmlseclibs <https://github.com/xmlseclibs>
>
>
> Best Regards,
>
> Francis A. Gonzales Tello / Informatic
> fgonzale...@gmail.com
> <mailto:f.gonzale...@gmail.com> / +51988301243
>
> www.francis-gonzales.info <http://www.francis-gonzales.info/>
>
> Twitter <https://twitter.com/FraGoTe> LinkedIn
> <https://pe.linkedin.com/in/fragote> Github
> <https://github.com/FraGoTe> Wordpress
> <https://fgonzalestello.wordpress.com/>
>
>
> El 23 de noviembre de 2016, 14:39, Miguel
> Panuera<mpan...@gmail.com <mailto:mpan...@gmail.com>> escribió:
>
> Buenas tardes,
>
> Actualmente estoy implementando facturación electronica,
> para una empresa, a lo cual he tenido algunos
> inconvenientes, quisiera saber si alguno de ustedes ha
> llegado a implementar la generación, firma y envío de la
> facturacion electronica con PHP.
>
> Si fuera asi, me gustaria saber con que librerías realizo
> cada procedimiento. o en todo caso, si me podria dar una
> asesoria, a lo cual agradeceria me envie un correo con sus
> pretensiones económicas a mpan...@gmail.com
> <mailto:mpan...@gmail.com>.
>
> Saludos y Gracias.
>
> --
> You received this message because you are subscribed to the
> Google Groups "PHP Perú" group.
> To unsubscribe from this group and stop receiving emails
> from it, send an email to
> phpperu+u...@googlegroups.com
> <mailto:phpperu+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to a topic
> in the Google Groups "PHP Perú" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe <https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email
> to phpperu+u...@googlegroups.com
> <mailto:phpperu+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
>
> --
> Miguel Panuera,
> Jefe de Proyectos
> IUVADE SRL.
> Soluciones Integrales
> mpanuera[AT]gmail.com <http://gmail.com>
> RPC 958335798
>
> --
> You received this message because you are subscribed to the Google
> Groups "PHP Perú" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to phpperu+u...@googlegroups.com
> <mailto:phpperu+u...@googlegroups.com>.

Francis Angelino Gonzales Tello

unread,
Dec 1, 2016, 9:43:52 PM12/1/16
to php...@googlegroups.com
Si seria mejor :-P

Espero que ya hayan solucionado su problema! :-)

Best Regards,

Francis A. Gonzales Tello / Informatic


    escribió:

        Hola Miguel,

        En mi trabajo ya implementamos facturación electrónica hace 2
        años y liberamos la librería que modificamos

        para hacer el firmado de los xml, el repo
        es https://github.com/xmlseclibs <https://github.com/xmlseclibs>


        Best Regards,

        Francis A. Gonzales Tello / Informatic
        fgonzale...@gmail.com


        www.francis-gonzales.info <http://www.francis-gonzales.info/>

        Twitter <https://twitter.com/FraGoTe> LinkedIn
        <https://pe.linkedin.com/in/fragote> Github
        <https://github.com/FraGoTe> Wordpress
        <https://fgonzalestello.wordpress.com/>


        El 23 de noviembre de 2016, 14:39, Miguel
        Panuera<mpan...@gmail.com <mailto:mpan...@gmail.com>> escribió:

            Buenas tardes,

            Actualmente estoy implementando facturación electronica,
            para una empresa, a lo cual he tenido algunos
            inconvenientes, quisiera saber si alguno de ustedes ha
            llegado a implementar la generación, firma y envío de la
            facturacion electronica con PHP.

            Si fuera asi, me gustaria saber con que librerías realizo
            cada procedimiento. o en todo caso, si me podria dar una
            asesoria, a lo cual agradeceria me envie un correo con sus
            pretensiones económicas a mpan...@gmail.com
            <mailto:mpan...@gmail.com>.


            Saludos y Gracias.

            --
            You received this message because you are subscribed to the
            Google Groups "PHP Perú" group.
            To unsubscribe from this group and stop receiving emails
            from it, send an email to
            phpperu+unsubscribe@googlegroups.com
            <mailto:phpperu+unsubscribe@googlegroups.com>.

            For more options, visit https://groups.google.com/d/optout
            <https://groups.google.com/d/optout>.


        --
        You received this message because you are subscribed to a topic
        in the Google Groups "PHP Perú" group.
        To unsubscribe from this topic, visit
        https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe <https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe>.

        To unsubscribe from this group and all its topics, send an email

        For more options, visit https://groups.google.com/d/optout
        <https://groups.google.com/d/optout>.




--
Miguel Panuera,
Jefe de Proyectos
IUVADE SRL.
Soluciones Integrales
mpanuera[AT]gmail.com <http://gmail.com>
RPC  958335798


--
You received this message because you are subscribed to the Google
Groups "PHP Perú" group.
To unsubscribe from this group and stop receiving emails from it, send

For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "PHP Perú" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phpperu+unsubscribe@googlegroups.com.

Miguel Panuera

unread,
Dec 1, 2016, 11:39:59 PM12/1/16
to php...@googlegroups.com
Si lo solucione, solo faltaba enviar al clave publica!! :)
Gracias su código me ayudo mucho.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phpperu+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Miguel Panuera, 
Jefe de Proyectos
IUVADE SRL.
Soluciones Integrales
mpanuera[AT]gmail.com
RPC  958335798

Francis Angelino Gonzales Tello

unread,
Dec 2, 2016, 6:47:11 AM12/2/16
to php...@googlegroups.com
Éxito !


    escribió:

        Hola Miguel,

        En mi trabajo ya implementamos facturación electrónica hace 2
        años y liberamos la librería que modificamos

        para hacer el firmado de los xml, el repo
        es https://github.com/xmlseclibs <https://github.com/xmlseclibs>


        Best Regards,

        Francis A. Gonzales Tello / Informatic
        fgonzale...@gmail.com
        <mailto:f.gonzale...@gmail.com> / +51988301243


        www.francis-gonzales.info <http://www.francis-gonzales.info/>

        Twitter <https://twitter.com/FraGoTe> LinkedIn
        <https://pe.linkedin.com/in/fragote> Github
        <https://github.com/FraGoTe> Wordpress
        <https://fgonzalestello.wordpress.com/>


        El 23 de noviembre de 2016, 14:39, Miguel
        Panuera<mpan...@gmail.com <mailto:mpan...@gmail.com>> escribió:

            Buenas tardes,

            Actualmente estoy implementando facturación electronica,
            para una empresa, a lo cual he tenido algunos
            inconvenientes, quisiera saber si alguno de ustedes ha
            llegado a implementar la generación, firma y envío de la
            facturacion electronica con PHP.

            Si fuera asi, me gustaria saber con que librerías realizo
            cada procedimiento. o en todo caso, si me podria dar una
            asesoria, a lo cual agradeceria me envie un correo con sus
            pretensiones económicas a mpan...@gmail.com
            <mailto:mpan...@gmail.com>.


            Saludos y Gracias.

            --
            You received this message because you are subscribed to the
            Google Groups "PHP Perú" group.
            To unsubscribe from this group and stop receiving emails
            from it, send an email to
            phpperu+u...@googlegroups.com
            <mailto:phpperu+u...@googlegroups.com>.

            For more options, visit https://groups.google.com/d/optout
            <https://groups.google.com/d/optout>.


        --
        You received this message because you are subscribed to a topic
        in the Google Groups "PHP Perú" group.
        To unsubscribe from this topic, visit
        https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe <https://groups.google.com/d/topic/phpperu/RSllWbkaVuU/unsubscribe>.

        To unsubscribe from this group and all its topics, send an email
        to phpperu+u...@googlegroups.com
        <mailto:phpperu+u...@googlegroups.com>.

        For more options, visit https://groups.google.com/d/optout
        <https://groups.google.com/d/optout>.




--
Miguel Panuera,
Jefe de Proyectos
IUVADE SRL.
Soluciones Integrales
mpanuera[AT]gmail.com <http://gmail.com>
RPC  958335798


--
You received this message because you are subscribed to the Google
Groups "PHP Perú" group.
To unsubscribe from this group and stop receiving emails from it, send

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "PHP Perú" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phpperu+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "PHP Perú" group.
To unsubscribe from this group and all its topics, send an email to phpperu+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Miguel Panuera, 
Jefe de Proyectos
IUVADE SRL.
Soluciones Integrales
mpanuera[AT]gmail.com
RPC  958335798

--
You received this message because you are subscribed to the Google Groups "PHP Perú" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phpperu+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Enviado con Gmail Mobile
Reply all
Reply to author
Forward
0 new messages