-
Notifications
You must be signed in to change notification settings - Fork 2
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
Communication with SdI - sending invoice #28
Communication with SdI - sending invoice #28
Conversation
d8c825c
to
f5fdd13
Compare
f5fdd13
to
72d0756
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.
In general the code looks good! But I understand that its still not working, which is frustrating :-(
314f43e
to
5d576ea
Compare
bbe0525
to
b701920
Compare
Ignore files that should be kept private such as: - Certificate Signing Request files - Private RSA key files - p7m files Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
We found the following information on an Italian blog: [1] > Tuttavia è possibile che nel wsdl troverai > “http://servizi.fatturapa.it/ricevi_file”, > per passare in produzione ricordati di modificare > l’endpoint in “https://servizi.fatturapa.it/ricevi_file” In translate: > However, it is possible that in the wsdl you will find > "http://servizi.fatturapa.it/ricevi_file", > to go into production remember to change > the endpoint to "https://servizi.fatturapa.it/ricevi_file" That's why we changed http to https. [1]: https://massimomorchio.medium.com/fattura-elettronica-accreditamento-canale-sdicoop-ef6afb65cacb Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
The provided WSDL files have an endpoint used in production. Most SOAP-enabled packages don't have the ability to change this endpoint, so we have prepared separate files for communication with the test server. Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
On the Exchange System documentation page, [1] we found the public keys of the client certificate of the SDICoop Transmission and SDICoop Reception Service. [1]: https://www.fatturapa.gov.it/en/norme-e-regole/DocumentazioneSDI/ Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
The CA certificates provided were in different formats, and some of them had no headers. I added headers and transformed them all to PEM format. [1] ```console openssl x509 -inform DER - w INPUT.cer -out OUTPUT.pem ``` [1]: https://www.openssl.org/docs/man1.1.1/man1/x509.html Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
We initially intended to utilize SOAP packages, however, we encountered multiple obstacles. The available packages were outdated and unable to handle TLS authentication properly. Additionally, we discovered that the SOAP server responded with multipart data, complicating the integration further. Consequently, we made the decision to switch to Resty and build SOAP requests from scratch to overcome these challenges. Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Since we want to run the code in different environments (development, test, production), it is a good practice to set separate variables for each environment. Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
b701920
to
290aa72
Compare
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Since we receive certificates as data within the context, the functions in the cert pool file are no longer needed. Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
6d35fe0
to
abb776e
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.
Looks good! Nice one! Just a few potential considerations with the public method names to consider.
} | ||
|
||
// SoapRequestToSendInvoice prepares the request content for SOAP to send an invoice | ||
func SoapRequestToSendInvoice(fileName string, fileBody []byte) string { |
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.
public?
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.
In this case I have a bit of a dilemma. I know this function doesn't have to be public, but I like that it only does one thing and I can easily test it.
Any ideas?
These functions can be useful both on the server and client side, in the code and perhaps also in tests. Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
This command is intended to demonstrate sending an invoice to SdI. Added CA cert and verbose flags for better control from the command line. The verbose flag provides more detailed debugging information about the package's execution. The ca-cert flag accepts a path to the CA Certificate. Example usage of the command: ```console $ go run ./cmd/gobl.fatturapa transmit --ca-cert ./ca-all.pem --cert ./SDI-B85905495.pem --key ./key_client.key --verbose invoice.xml ``` Additionally, separated responsibilities and added flexibility in certificate storage. The CLI handles the loading of the certificate path, while the SdI package uses the loaded key. Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
Co-authored-by: Alex Malaszkiewicz <[email protected]> Co-authored-by: Grzeg Lisowski <[email protected]>
d62dd80
to
f017b89
Compare
Pull Request Summary
We have implemented functionalities for sending invoices to SdI.
We've also introduced context, following the pattern established in other packages.
Furthermore, we've standardized CA (public) certificates, consolidating them into a single file. We have overcome authentication problems (on the client side).
Feedback
We have removed the server-related part from this PR to complete the process of sending invoices to SdI as one whole.
Below are some logs from the console commands.
Transmit
Co-authored-by: @noplisu
Co-authored-by: @torrocus