Biblioteca não oficial de comunicação com a API de pagamento do ASAAS
Project description
asaas-sdk
Biblioteca não oficial de comunicação com a API de pagamento do ASAAS
Baseado na documentação especificada em https://asaasv3.docs.apiary.io/
Instalação
Instale o pacote via pip:
pip install asaas-sdk
Utilização
from asaas import Asaas
asaas = Asaas(access_token = 'acess_token', url_production='asaas_production_url', production = False)
A variável acess_token
deve receber um token válido.
A variável url_production
deve receber a url de produção do Asaas.
Customers
new_customer = asaas.customers.new(name = 'Roberto', cpfCnpj = '24971563792')
print(new_customer)
# Customer(id=cus_000005263646, name=Roberto, email=None)
Payments
Cartão de crédito
from asaas.payments import CreditCard, CreditCardHolderInfo, BillingType
from datetime import date
credit_card = CreditCard(
holderName = 'marcelo h almeida',
number = '5162306219378829',
expiryYear = '2024', expiryMonth = '05',
ccv = '318'
)
credit_card_holder_info = CreditCardHolderInfo(
name = 'Marcelo Henrique Almeida',
email = 'marcelo.almeida@gmail.com',
cpfCnpj = '24971563792',
postalCode = '89223-005',
addressNumber = '277',
addressComplement = '',
phone = '4738010919'
)
pagamento = asaas.payments.new(
customer = new_customer,
billingType = BillingType.CREDIT_CARD,
value = 100,
dueDate = date.today(),
creditCard = credit_card.json(),
creditCardHolderInfo = credit_card_holder_info.json()
)
print(pagamento)
# Payment(id=pay_6954209428403551, customer=Customer(id=cus_000005263646, name=Roberto, email=None), billingType=CREDIT_CARD, value=100)
Boleto
pagamento = asaas.payments.new(
customer = new_customer,
billingType = BillingType.BOLETO,
value = 100,
dueDate = date.today()
)
print(pagamento)
# Payment(id=pay_6954209428403552, customer=Customer(id=cus_000005263646, name=Roberto, email=None), billingType=BOLETO, value=100, invoiceUrl=https://sandbox.asaas.com/i/6997545710784231)
Pix
pagamento = asaas.payments.new(
customer = new_customer,
billingType = BillingType.PIX,
value = 100,
dueDate = date.today()
)
print(pagamento)
# Payment(id=pay_6954209428403553, customer=Customer(id=cus_000005263646, name=Roberto, email=None), billingType=PIX, value=100)
pix_info = asaas.payments.get_pix_qr(pagamento.id)
print(pix_info)
# 'Pix(success=True, expirationDate=2023-04-27 23:59:59, payload=00020101021226820014br.gov.bcb.pix2560qrpix-...)'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asaas_sdk-3.3.0.tar.gz
(9.6 kB
view details)
Built Distribution
asaas_sdk-3.3.0-py3-none-any.whl
(10.4 kB
view details)
File details
Details for the file asaas_sdk-3.3.0.tar.gz
.
File metadata
- Download URL: asaas_sdk-3.3.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f02705eb82056dbb3a981ba4df2c8d7b1cf98a3ff7c3d3ce29e39380f554451 |
|
MD5 | a554e340af59c7f23781278f191a28e8 |
|
BLAKE2b-256 | 65aae33b64e96897631f66ab1fe36d77258f6bfa14e5fc56310cef3dfeffa1b0 |
File details
Details for the file asaas_sdk-3.3.0-py3-none-any.whl
.
File metadata
- Download URL: asaas_sdk-3.3.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1374e3284dcf1fc125432d70788fd96d5fb07be59e3871bdb04c92f18eb4013 |
|
MD5 | e285183b5116b98dd1aae76730d57bf0 |
|
BLAKE2b-256 | e9739bee88257593cfee9be3d29b6e1f7dda1bfa7d95f30b46577d0b82a89e48 |