Python

Our API is RESTful and responds in JSON. Gerencianet uses OAuth to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically.

Below, check out the procedures for installing the Gerencianet SDK in Python:

Installing via PIP

$ pip install gerencianet

Tested with

  • Python 2.7, 3.3 ,3.4 e 3.5

Basic use

# encoding: utf-8
from gerencianet import Gerencianet
credentials = {
'client_id': 'client_id',
'client_secret': 'client_secret',
'sandbox': True
}
gn = Gerencianet(credentials)
body = {
'items': [{
'name': "Product 1",
'value': 1000,
'amount': 2
}],
'shippings': [{
'name': "Default Shipping Cost",
'value': 100
}]
}
print gn.create_charge(body=body)

Exemplos

You can run the examples inside examples with $ python examples/example.py:

$ python examples/create_charge.py

Tests

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

$ py.test