-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
8feb887
to
e0e776b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments there. I'd suggest having a look at some of the other repos for examples on best practices with Go. Otherwise though, this is looking great! Looks like the KSeF API is pretty complex!
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.
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.
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.
e0e776b
to
e11fc8c
Compare
a5d76a0
to
786be84
Compare
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
786be84
to
e8b4051
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Pull Request Summary
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 https://ksef.mf.gov.pl/web for production or from https://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/.
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.
The process is getting the authorization challenge, initializing the interactive session, posting the invoice using the session, waiting for the invoice to process by checking the status. When it is finished we terminate the session wait for the process to finish by checking the status and save the UPO.
An example of using the CLI to post an invoice would look like:
Changes
We add a CLI command for posting the invoice into the KSeF API.
We add handling for requests:
The process of sending a invoice works like presented on this graph: