Skip to main content

Simple Pagar.me module made by Surfmappers.com

Project description

Pagarme Surfmappers

Latest PyPI version Wheel Status Supported Python Versions License

An implementation of the Pagar.me API for Python. This repository appears as an alternative to the Pagar.me library suggested by the documentation, that has some problems and which, for example, was not used by us because of this.

Install

pip install pagarme-surfmappers

How to use

You can use this lib as Pagar.me documentation suggests to. Above we'll show some examples

We gonna assume that you already have an valid Pagar.me api key:

YOUR_API_KEY = "your_pagarme_api_key"

Table of Contents

Bank Account

You can create and get an bank account. Check Pagar.me documentation for more details:

Create Bank Account

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
bank_account = pagarme_surfmappers.BankAccount()

params = {
    ...
}

try:
    new_bank_account = bank_account.create(params)
except Exception as e:
    print(e)
    raise

print(new_bank_account)

Get Bank Account

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
bank_account = pagarme_surfmappers.BankAccount()

try:
    user_bank_account = bank_account.get()
except Exception as e:
    print(e)
    raise

print(user_bank_account)

Bulk Anticipation

You can create, confirm, calcel and get limits of a bulk anticipation. Check Pagar.me documentation for more details:

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
bulk = pagarme_surfmappers.BulkAnticipation()
recipient_id = "some_user_recipient"
params = {
    ...
}

try:
    new_bulk = bulk.create(recipient_id, params)
except Exception as e:
    print(e)
    raise

print(new_bulk)

Recipient

You can create, get and edit an recipient. You can also get an recipient balance. Check Pagar.me documentation for more details:

Create Recipient

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

params = {
    ...
}
pagarme_surfmappers.set_api_key(YOUR_API_KEY)
recipient = pagarme_surfmappers.Recipient()

try:
    new_recipient = recipient.create(params)
except Exception as e:
    print(e)
    raise

print(new_recipient)

Get Recipient

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

recipient_id = "some_user_recipient_id"
pagarme_surfmappers.set_api_key(YOUR_API_KEY)
recipient = pagarme_surfmappers.Recipient()

try:
    user_recipient = recipient.get(recipient_id)
except Exception as e:
    print(e)
    raise

print(user_recipient)

Get Recipient's Balance

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

recipient_id = 'some_user_recipient_id'
pagarme_surfmappers.set_api_key(YOUR_API_KEY)
recipient = pagarme_surfmappers.Recipient()

try:
    user_balance = recipient.get_balance(recipient_id)
except Exception as e:
    print(e)
    raise

print(user_balance)

Transaction

You can create and capture an transaction. Check Pagar.me documentation for more details:

Create Transaction

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

params = {
    ...
}

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
transaction = pagarme_surfmappers.Transaction()

try:
    new_transaction = transaction.create(params)
except Exception as e:
    print(e)
    raise

print(new_transaction)

Capture Transaction

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

params = {
    ...
}

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
transaction = pagarme_surfmappers.Transaction()
token_id = "some_transaction_token_id"

try:
    captured_transaction = transaction.capture(token_id, params)
except Exception as e:
    print(e)
    raise

print(captured_transaction)

Calculate Installments

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

params = {
    ...
}

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
transaction = pagarme_surfmappers.Transaction()
token_id = "some_transaction_token_id"

try:
    installments = transaction.calculate_installments_amount(token_id, params)
except Exception as e:
    print(e)
    raise

print(installments)

Transfer

You can create, get and cancel an transfer. Check Pagar.me documentation for more details:

Create Transfer:

import pagarme_surfmappers

YOUR_API_KEY = "your_pagarme_api_key"

params = {
    ...
}

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
transfer = pagarme_surfmappers.Transfer()

try:
    new_transfer = transfer.create(params)
except Exception as e:
    print(e)
    raise

print(new_transfer)

Contributing and Support

Feel free to contribut to this code, improving it. Any problems can be reported in form of github issue, as any doubts.

Changelog

License

This lib is MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pagarme_surfmappers-1.4.1-py2-none-any.whl (7.5 kB) Copy SHA256 hash SHA256 Wheel py2
pagarme_surfmappers-1.4.1-py3-none-any.whl (7.5 kB) Copy SHA256 hash SHA256 Wheel py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page