Skip to content

Commit

Permalink
Merge pull request #23 from YuriAlessandro/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
YuriAlessandro authored Nov 30, 2018
2 parents b866ac0 + eef0387 commit 70e16fa
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 28 deletions.
207 changes: 180 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,227 @@
# Pagarme Surfmappers
An simple implementation of Pagar.me API to be used by Surfmappers.com
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
```Todo```
We're currently working to put this lib in PyPi, but you can install it by pip using the following command:

```pip install git+https://github.com/YuriAlessandro/pagarme-surfmappers```

# How to use
You can use this lib as Pagar.me documentation suggests to. Above we'll show some examples
You can use this lib as [Pagar.me documentation](https://docs.pagar.me/v2017-08-28/reference) suggests to. Above we'll show some examples

## Transaction
You can create an transaction.
We gonna assume that you already have an valid Pagar.me api key:

```python
YOUR_API_KEY = "your_pagarme_api_key"
```

## Summary


## Bank Account
You can create and get an bank account. Check [Pagar.me documentation](https://docs.pagar.me/v2017-08-28/reference#criando-uma-conta-banc%C3%A1ria) for more details:

### Create Bank Account
```python
import pagarme_surfmappers

params = {...} # As in Pagar.me documentation
YOUR_API_KEY = "your_pagarme_api_key"

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
transaction = pagarme_surfmappers.Transaction()
response = transaction.create(params)
bank_account = pagarme_surfmappers.BankAccount()

print(response)
```
params = {
...
}

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

## Capture Transcation
After create an transaction, you can capture it.
print(new_bank_account)
```
### Get Bank Account

```python
import pagarme_surfmappers

params = {...} # As in Pagar.me documentation
YOUR_API_KEY = "your_pagarme_api_key"

pagarme_surfmappers.set_api_key(YOUR_API_KEY)
transaction = pagarme_surfmappers.Transaction()
response = transaction.capture(params)
bank_account = pagarme_surfmappers.BankAccount()

print(response)
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](https://docs.pagar.me/v2017-08-28/reference#criando-uma-antecipa%C3%A7%C3%A3o) for more details:

```python
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
Creates a recipient
You can create, get and edit an recipient. You can also get an recipient balance. Check [Pagar.me documentation](https://docs.pagar.me/v2017-08-28/reference#criando-um-recebedor) for more details:

### Create Recipient
```python
import pagarme_surfmappers

params = {...} # As in Pagar.me documentation
YOUR_API_KEY = "your_pagarme_api_key"

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

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

print(new_recipient)
```

## Recipient's Balance
You can also get an recipient's balance
### Get Recipient
```python
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

```python
import pagarme_surfmappers

recipient_id = 'SOME_ID'
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()
response = recipient.get_balance(recipient_id)

print(response)
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](https://docs.pagar.me/v2017-08-28/reference#criar-transacao) for more details:

### Create transaction
```python
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 Transcation
```python
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)
```

## Transfer
You can create, get and cancel an transfer. Check [Pagar.me documentation](https://docs.pagar.me/v2017-08-28/reference#criando-uma-transfer%C3%AAncia) for more details:

### Create Transfer:
```python
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
Feel free to contribut to this code, improving it.
# 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.

# License
This lib is [MIT licensed](./LICENSE).
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name='pagarme-surfmappers',
version='1.2.1',
version='1.3.0',
description='Simple Pagar.me module made by Surfmappers.com',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 70e16fa

Please sign in to comment.