getnet-python
This project is a fork of Getnet-py
This project provider a SDK to handler Getnet API.
Installation
To install getnet-py you can use pip:
$ pip install getnet-python
or pipenv:
$ pipenv install getnet-python
Usage
For use this library the following information is needed:
- Seller ID
- Client ID
- Client Secret
The following environments are supported:
- Sandbox
- Homolog
- Production
At moment, we have support to the following services:
- Token
- Payments
- Credit Card
Instancing the client
from getnet import Environment, Client
client = Client("seller_id", "client_id", "client_secret", Environment.SANDBOX)
client.auth() # Optional, will be executed if needed
Using the Services
Examples
Consult Card BIN Informations
card_bin = client.card_bin("515590") # Card related information and Status
Customer
customer_service = client.customer_service()
Create Customer
customer_data = client.customer(
{
"first_name":"Joao",
"last_name":"Pedro da Silva",
"document_type":"CPF",
"document_number":"77261241563",
"birth_date":"1988-04-08",
"phone_number":"5575999999999",
"celphone_number":"5575999999999",
"email":"fabvitor@test.com",
"observation":"Test CLient",
"customer_id":"77261241563", # or uuid4
"seller_id":"6eb2412c-165a-41cd-b1d9-76c575d70a28",
"address":{
"street": "Rua Test",
"number": "40",
"complement": "Casa",
"district": "Centro",
"city": "São Paulo",
"state": "SP",
"country": "Brasil",
"postal_code": "77019098",
},
}
)
customer = customer_service.create(customer_data)
Get Customer
customer = customer_service.get("77261241563")
List All Customers Saved in Getnet
customers = customer_service.all()
Tokenizing a Credit Card
token = client.generate_card_token("5155901222280001", customer.customer_id)
token.number_token # token genered in getnet
Verify a Credit Card
card_verified: bool = client.card_verified(
number_token=tokenizado.number_token,
expiration_month="12",
expiration_year="28"
cardholder_name="JOAO DA SILVA",
brand="Mastercard",
security_code="123",
) # True or False
Generate a Credit Card
payment_card = client.credit_card(
number_token=tokenizado.number_token,
cardholder_name="JOAO DA SILVA",
security_code="123",
brand="Mastercard",
expiration_month="12",
expiration_year="28"
)
Generate a Order
payment_order = client.order("12345")
Generate a Payment Customer
payment_customer = client.customer(customer)
Generate a Credit Card Payment
payment = client.create_credit_transaction(
amount="1000",
delayed=False,
pre_authorization=True,
save_card_data=False,
transaction_type="FULL",
number_installments=1,
order=payment_order,
customer=payment_customer,
card=payment_card,
shipping_address={
"street": "Rua Test",
"number": "40",
"city": "São Paulo",
"state": "SP",
"postal_code": "77019098"
}, # The user's address may be different from the address registered with the consumer
)
payment_id = payment.payment_id # ID
status = payment.status # AUTHORIZED
Adjust a Payment Amount
payment_ajusted = client.adjust_credit_transaction(payment_id, "2000")
payment_ajusted.status # APROVED
Capture a Credit Card Payment
captured_payment = client.capture_credit_transaction(payment_id, "2000")
captured_payment.status # CONFIRMED
Cancel a Credit Card Payment
canceled_order = client.cancel_credit_transaction(payment_id)
canceled_order.status # CANCELED
cancel_payment_credit.credit_cancel.message # "Credit transaction cancelled sucessfully"
Handling error returns
Errors related to specific getnet returns can be accessed through the BusinessError Class
Example in Cancel Transaction:
try:
canceled_order = client.cancel_credit_transaction(payment_id)
except Exception as getnet_error:
error_code = getnet_error.details["error_code"]
print(error_code) # PAYMENTS-082
error_msg = getnet_error.details["description"]
print(error_msg) # Cancelamento inválido
Metadata
Release files for getnet-python 3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| getnet-python-3.5.tar.gz | 25.6 kB | Without provenance | Details for getnet-python-3.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| getnet_python-3.5-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for getnet_python-3.5-py2.py3-none-any.whl |
Total release size: 70.8 kB
Release files / getnet-python-3.5.tar.gz
| Download URL | getnet-python-3.5.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dacbb2f3ba5073f5c3458100cbb7dad6b06bba23a9e741e4a9b7645791ba65ce
|
|
BLAKE2b-256 checksum How to use checksums |
014bd269bac51265aa8faff1f3affad6fbbc94731f463dbbd355eeca8d2be1cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.9.17
|
Release files / getnet_python-3.5-py2.py3-none-any.whl
| Download URL | getnet_python-3.5-py2.py3-none-any.whl |
|---|---|
| Size | 45.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2c8d1918e2369a071e9e919a9a408734cb7a46d4e2b69844c24f92efae0b8d49
|
|
BLAKE2b-256 checksum How to use checksums |
401bdccf4be49877f57f119865ccd54c4ec1efad8b7404f464154955d3b93629
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.9.17
|
Security for getnet-python 3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.