Skip to main content

Python

Learn how to install and configure our Python SDK to use Efí's APIs

Attention!

Requests made to Efí's APIs using the Python SDK require the certificate generated in your Efí account in the .pem format.

Check here the step-by-step guide to convert your P12 certificate to PEM format.


Instalation via PIP

$ pip install efipay

Installation via Git

Our SDK is also available in our Efí Github repository.

$ git clone https://github.com/efipay/sdk-python-apis-efi.git

Tested with

  • Python 2.7, 3.3 ,3.4 e 3.5

Basic Usage

# encoding: utf-8

from efipay import EfiPay

credentials = {
'client_id': 'client_id',
'client_secret': 'client_secret',
'sandbox': True,
'certificate': 'insira-o-caminho-completo-do-certificado'
}

efi = EfiPay(credentials)

body = {
'calendario': {
'expiracao': 3600
},
'devedor': {
'cpf': '12345678909',
'nome': 'Francisco da Silva'
},
'valor': {
'original': '123.45'
},
'chave': '71cdf9ba-c695-4e3c-b010-abb521a3f1be',
'solicitacaoPagador': 'Cobrança dos serviços prestados.'
}

response = efi.pix_create_immediate_charge(body=body)
print(response)

Examples

You can run the examples inside examples with:

$ python -m examples/pix/cob/pix_create_immediate_charge

Tests

Remember to set the correct credentials within examples/credentials.py before run.

$ py.test