Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api communication #11

Merged
merged 4 commits into from
Mar 20, 2024
Merged

Add api communication #11

merged 4 commits into from
Mar 20, 2024

Commits on Feb 7, 2024

  1. Authorize KSeF API session

    We want to be able to post invoices into the KSeF API and get back
    the UPO that proves that the invoice has been accepted by the system.
    
    The first step is communicating with the API to get the interactive
    session. To get the interactive session we need to have the context
    in which we send the requests this context is the tax id of the company.
    Next we need a valid token from ksef it can be generated from
    ksef.mf.gov.pl/web for production or from ksef-test.mf.gov.pl/web for
    test. The last thing is the public key provided from https://ksef.mf.gov.pl/ and
    https://ksef-test.mf.gov.pl/.
    
    To get the session token we first need to get the authorization challenge for
    our context. Then we use the context, token and authorization challenge to
    create a interactive session and get the session token used in other requests.
    noplisu committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    b2b4e3f View commit details
    Browse the repository at this point in the history
  2. Send invoice to the KSeF API

    We want to be able to post invoices into the KSeF API and get back
    the UPO that proves that the invoice has been accepted by the system.
    
    Here we prepare the request that posts the invoice to KSeF backend.
    We also prepare a request that checks the invoice status.
    
    With those requests we can post the invoice and check if it finished
    processing.
    noplisu committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    99b0ee2 View commit details
    Browse the repository at this point in the history
  3. Session management in KSeF API

    We want to be able to post invoices into the KSeF API and get back
    the UPO that proves that the invoice has been accepted by the system.
    
    The UPO files are generated after the interactive session is terminated.
    To get the files we first need to terminate the session then after it
    finishes generating the UPO files we can get them from the session status request.
    
    Here we the session termination and status requests used in the process.
    noplisu committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    b5c50be View commit details
    Browse the repository at this point in the history

Commits on Feb 8, 2024

  1. Add posting invoice into the CLI

    We want to be able to post invoices into the KSeF API and get back
    the UPO that proves that the invoice has been accepted by the system.
    
    Here we get the parameters from the CLI and use the requests we prepared
    to post the invoice and save the UPO. The example command would look like
    
    go run ./cmd/gobl.ksef send ./test/data/out/invoice-pl-pl.xml 1234567788 624A48824F01935DADE66C83D4874C0EF7AF0529CB5F0F412E6932F189D3864A ./api/keys/test.pem
    noplisu committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    e8b4051 View commit details
    Browse the repository at this point in the history