Lib created in order to sign XML content for SOAP Envelops when a signature is required. This library is intended to be used within WebServices that require certificate signature values inside the XML body. Pure Python coded. Its features consist in extracting .CERT or .PEM files and PrivateKeys to add values on Signatures elements as SignatureValue and X509Certificate with rsa-sha1 encryption type, compliant with http://www.w3.org/2000/09/xmldsig. Sign a XML file or buffered string using A1 or A3 certificate, PKCS1_v1_5 supported by RFC3447. It serializes the data to request SOAP RPC services. Creates POST requests on WebServices as NFe and NFSe.
- Firstly, clone this repo to your local machine
git clone https://github.com/vsgobbi/nfe-library.git
python setup.py install
- Install main libs
pip install -r requirements.txt
Using the following libs:
- lxml, pyCrypto, requests, ssl, rsa
- Create virtualenv using Python2.7
virtualenv -p python2.7 venv
- Activate the virtualenv
source venv/bin/activate
- Verify if version is correct
python --version #expected return: Python2.7
pip --version
# coding: utf-8
from gateways.saopaulo import SaopauloGateway
certificateContent=open("../static/certificate.crt", "rb").read()
privateKeyContent = open("./static/rsaKey.pem").read()
###Create Nfe:
nota = {
"senderTaxId": "01234567890123",
"subscription": "01234567",
"rpsSeries": "TESTE",
"rpsNumber": "9117092019",
"rpsType": "RPS",
"issueDate": "2019-07-09",
"statusRps": "N",
"rpsTax": "T",
"issRetain": "false",
"serviceAmount": "1",
"deductionAmount": "0",
"pisAmount": "0",
"irAmount": "0",
"csllAmount": "0",
"cofinsAmount": "0",
"inssAmount": "0",
"serviceCode": "05895",
"aliquot": "2",
"receiverTaxId": "32109876543210",
"receiverName": "SOME COMPANY NAME",
"receiverStreetLine1": "Null",
"receiverStreetNumber": "123",
"receiverStreetLine2": "Null",
"receiverDistrict": "Null",
"receiverCity": "3550308",
"receiverState": "SP",
"receiverZipCode": "00000000",
"receiverEmail": "none@none",
"description": "Teste de emissao de NFS-e de boletos prestados",
}
print(SaopauloGateway.sendRps(
privateKeyContent=privateKeyContent,
certificateContent=certificateContent,
**nota
))
###How to delete a Nfe:
nota = {
"senderTaxId": "01234567890123",
"subscription": "01234567",
"nfeNumber": "001"
}
print(SaopauloGateway.cancelRps(
privateKeyContent=privateKeyContent,
certificateContent=certificateContent,
**nota
))
###Consult sent Nfes
parameters = {
"senderTaxId": "01234567890123",
"subscription": "01234567",
"dtInicio": "2019-09-15",
"dtFim": "2019-09-18",
}
print(SaopauloGateway.consultNfes(
privateKeyContent=privateKeyContent,
certificateContent=certificateContent,
**parameters
))
-
Step 1
- 🍴 Fork this repo!
-
Step 2
- 🔨🔨 Clone this repo to your local machine using
git clone `https://github.com/vsgobbi/nfe-library`
- Step 3
- 🔃 Create a new pull request using
https://github.com/vsgobbi/nfe-library/compare
- 🔃 Create a new pull request using
Reach out to me at one of the following places!
- E-mail at
[email protected]
- Github at
@vsgobbi
- GPL license
- Copyright 2019 © Vitor Gabriel Sgobbi.