Giter Club home page Giter Club logo

satwebservice's Introduction

Servicio Web SAT

Build Status

CircleCI codecov

Como iniciar

  • Instalar docker

FIEL

En este caso, para protegernos un poco y tener multi-usuarios lo ideal es crear keystores por usuario. Agregue una librería ayuda a crear el PFX. Solo necesitas correr $ ./create-p12 -k FIEL.key -c FIEL.cer -p passwordFiel -r RFC. Esto creara un archivo <RFC>.p12 en ./kestore/<RFC>.p12.

Por ahora creamos en el file system (proteger) el keystore (.p12)

Base de datos

Por ahora solo contiene una tabla sat_client con id, rfc, password_plain, kestore donde:

  • id: Se auto-genera
  • rfc: El RFC del cliente que pide sus CFDI
  • password_plain: El password del keystore (creado en el paso de creación de PFX)
  • keystore: El archivo creado por la utilidad create-p12 (Por default se guarda como ./kestore/<RFC>.p12)

Iniciando la APP

Usa docker, te hara la vida sencilla.

  • Docker necesita estar instalado en tu máquina.
  • Corre mvn -U clean install
  • Si el setup está completo, corre docker-compose up --build. Esto creara una base de datos en docker y creara las tablas necesarias

Una vez, ya se levantaron los servicios. Ya estás listo para empezar.

Peticiones en order

Subiendo tu CER, KEY y PASSWORD de tu FIEL

Request:

curl -X "POST" "http://localhost:8080/v1/persona-fisica/upload-key" \
     -H 'Content-Type: multipart/form-data; charset=utf-8;' \
     -F "file-key='MultiPart KEY'" \
     -F "file-cert='MultiPart CERT'" \
     -F "password=FIEL_PASS" \
     -F "rfc=RFC_CLIENT"

Response:

{"message":"Keystore created for RFC_CLIENT"}

Solicitud Descarga (One Shot)

En este método (endpoint). Hacemos en el back todas las necesarias interacciones con el SAT. Si responde inmediatamente obtendrás las facturas, si no un menaje: READY, ACCEPTED o REJECTED.

Request

EL header con el token no es necesario el backend administra el manejo de ellos y la peticion de nuevos.

curl -X "POST" "http://localhost:8080/v1/persona-fisica/download-received" \
     -H 'Content-Type: application/json' \
     -d $'{
  "rfc": "RFC_CLIENT",
  "dateEnd": "2021-10-09T04:09:12Z",
  "dateStart": "2021-08-09T04:09:15Z"
}'

Response

{"message":null,"satState":"ACCEPTED","invoices":[]}

Si el valor de satState es ACCEPTED intentante de nuevo con los mismos parametros del request. Esto se guardo en la DB y de forma automatica buscara el limite del SAT (cerca de 10 veces) para intentar descargar.

Por default este servicio wvit mas peticiones al SAT si se ha llamado mas de 5 veces en un rango de 4 horas. Cuando eso pasa tendras una respuesta similar a:

{"message":"Backing off validation request. Wait time: 217 minutes","satState":"ACCEPTED","invoices":[]}

Open Source

La idea de esto es que la comunidad lo haga robusto. No temas en crear Issues y colaborar!

Pasa a revisar nuesta licencia Open Source (GNU General Public License): GNU GPL

satwebservice's People

Contributors

mikkezavala avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

satwebservice's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency org.apache.commons:commons-exec to v1.4.0
  • Update dependency org.apache.commons:commons-lang3 to v3.16.0
  • Update mysql Docker tag to v8.4
  • Update amazoncorretto Docker tag to v21
  • Update cimg/openjdk Docker tag to v21
  • Update dependency codecov to v4
  • Update mysql Docker tag to v9
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • codecov 3.2.2
  • cimg/openjdk 17.0
docker-compose
docker-compose.yml
  • mysql 8.0
dockerfile
Dockerfile
  • amazoncorretto 17-alpine
maven
pom.xml
  • org.springframework.boot:spring-boot-starter-parent 2.6.2
  • commons-io:commons-io 2.11.0
  • org.projectlombok:lombok 1.18.22
  • org.apache.commons:commons-lang3 3.12.0
  • org.apache.commons:commons-exec 1.3
  • org.xmlunit:xmlunit-core 2.8.4
  • org.xmlunit:xmlunit-assertj3 2.8.4
  • com.sun.xml.bind:jaxb-impl 3.0.2
  • org.jacoco:jacoco-maven-plugin 0.8.7

  • Check this box to trigger a request for Renovate to run again on this repository

xml mal formado

Hola @mikkezavala
Estoy obteniendo un xml mal formado, adjunto el request y response
Sabes a que se deba?

SOAP Request

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <ns6:SolicitaDescarga xmlns:ns2="http://DescargaMasivaTerceros.gob.mx" xmlns:ns3="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns6="http://DescargaMasivaTerceros.sat.gob.mx">
        <ns6:solicitud FechaFinal="2018-01-01T04:09:15.000Z" FechaInicial="2017-10-01T04:09:12.000Z" RfcReceptor="TEST12345" RfcSolicitante="TEST12345" TipoSolicitud="CFDI">
        <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
            <SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
            <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
            <Reference URI="">
                <Transforms>
                    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                </Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                <DigestValue>A652UElrtYYMD1cNyXgEQP6wIPY=</DigestValue>
            </Reference></SignedInfo><SignatureValue>j6EdG4glMoJ75zMoEKKmQisqKwLPc0z4pkis7P/wfZy3Xm+mDTtX/YxNqL2jv0J0ybzQd1SFjaEy&#13;
Xn+UNHCd7lgQsrzn8id8v/5k/p+9D7hvHr7MOfNKB/zEwUprxRyoLTat1omflRB810s6GnZmmaBt&#13;
PyFY/ZREjJEFQyLMSXpr2WU2apUtZAUzWEm9uALX99dhugpDMLoeYSiLGwi1pfre2CavHABdnchm&#13;
8jtlFsqyaDreg45YHuxt/+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rvj+iTJ5V5PYT/FuG&#13;
NMc0KITCS+2fds9MZwg7pz5CFalLRr1iS/md4H02apZdb2O3LwnlnIVlCEKpL+YCfKTHF52VXK5p&#13;
jsrPsn0sS9KE4jYn5lgIfKtHqXYRkdNqXQbShNH4PQoJ6iP2wrcq3vYYBEajW9JLCWDZWsaFDDKI&#13;
RtQnt5P372ymOnoBAkQy3WLGqyuecXbEDwkTeqyKYoCSPBJqtqbAgGP0GXi+UTOWNA==
</X509Certificate><X509IssuerSerial><X509IssuerName>ISSUE DATA</X509SerialNumber></X509IssuerSerial></X509Data></KeyInfo></Signature></ns6:solicitud></ns6:SolicitaDescarga></SOAP-ENV:Body></SOAP-ENV:Envelope>

SOAP Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SolicitaDescargaResponse xmlns="http://DescargaMasivaTerceros.sat.gob.mx">
     <SolicitaDescargaResult CodEstatus="301" Mensaje="XML Mal Formado"/>
</SolicitaDescargaResponse></s:Body></s:Envelope>

Error generating P12

Hola @mikkezavala
Estoy obteniendo un error a la hora de generar el p12.

Error generating P12 en la clase FielUtil.java

Revisando el codigo, creo que es porque en el archivo Dockerfile tienes la siguiente linea:

COPY create-p12.sh ./create-pfx.sh

Y en la la clase tienes algo como

./create-p12.sh -r %s -c %s -k %s -p %s

El script al que se hace referencia en la clase FielUtil.java no existe.

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.