|
1 | | -# AbacatePay |
2 | | -SDK Python para interagir com a API da AbacatePay (https://abacatepay.com) |
| 1 | +# AbacatePay SDK |
3 | 2 |
|
4 | | - |
5 | | - |
6 | | -## Instalação |
| 3 | + |
| 4 | + |
7 | 5 |
|
8 | | -### Instalação via PyPI |
9 | | -```bash |
10 | | -pip install abacatepay |
11 | | -``` |
| 6 | +> A Python SDK to simplify interactions with the AbacatePay API. <br /> |
| 7 | +> This SDK provides tools for billing management, customer handling, and more. |
| 8 | +
|
| 9 | + |
| 10 | +[English](README.md) | [Português](README-pt.md) |
| 11 | + |
| 12 | +--- |
12 | 13 |
|
13 | | -### Instalação via desenvolvimento |
| 14 | +## Table of Contents |
14 | 15 |
|
15 | | -Para o desenvolvimento, você deve clonar o repositório e instalar o pacote com o instalador de pacotes `uv` (https://docs.astral.sh/uv/). Este instalador é recomendado para projetos Python e já possui a criação de ambientes virtuais e outras dependências necessárias para o desenvolvimento: |
| 16 | +- [Installation](#installation) |
| 17 | +- [Getting Started](#getting-started) |
| 18 | +- [Usage Examples](#usage-examples) |
| 19 | + - [Create a Billing](#create-a-billing) |
| 20 | + - [List All Billings](#list-all-billings) |
| 21 | + - [Customer Management](#customer-management) |
| 22 | +- [Contributing](#contributing) |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Installation |
| 27 | + |
| 28 | +### Using pip |
16 | 29 |
|
17 | 30 | ```bash |
18 | | -uv sync |
19 | | -uv run pip install -e . |
20 | | -uv venv |
| 31 | +pip install abacatepay |
21 | 32 | ``` |
22 | 33 |
|
23 | | -#### Rodando os testes |
| 34 | +### Using Poetry |
24 | 35 |
|
25 | 36 | ```bash |
26 | | -uv run pytest |
| 37 | +poetry add abacatepay |
27 | 38 | ``` |
28 | 39 |
|
| 40 | +--- |
| 41 | + |
| 42 | +## Getting Started |
29 | 43 |
|
30 | | -## Usage/Examples |
| 44 | +To use the SDK, import it and initialize the client with your API key: |
31 | 45 |
|
32 | 46 | ```python |
33 | 47 | import abacatepay |
| 48 | + |
| 49 | +client = abacatepay.AbacatePay(api_key="<your-api-key>") |
| 50 | +``` |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Usage Examples |
| 55 | + |
| 56 | +### Create a Billing |
| 57 | + |
| 58 | +```python |
34 | 59 | from abacatepay.models import Product |
35 | 60 |
|
36 | | -token = "<your enviroment api token>" |
37 | | -client = AbacatePay(token) |
| 61 | +client = abacatepay.AbacatePay(api_key="<your-api-key>") |
| 62 | + |
| 63 | +products = [ |
| 64 | + Product( |
| 65 | + externalId="123", |
| 66 | + name="Test Product", |
| 67 | + quantity=1, |
| 68 | + price=5000, |
| 69 | + description="Example product" |
| 70 | + ) |
| 71 | +] |
| 72 | + |
| 73 | +billing = client.billing.create( |
| 74 | + products=products, |
| 75 | + returnURL="https://yourwebsite.com/return", |
| 76 | + completionUrl="https://yourwebsite.com/complete" |
| 77 | +) |
38 | 78 |
|
39 | | -billing = client.billing.create(products=[Product(externalId="123", name="Teste", quantity=1, price=101, description="Teste")], returnURL="https://abacatepay.com", completionUrl="https://abacatepay.com") |
40 | 79 | print(billing.data.url) |
41 | | -# > https://abacatepay.com/pay/aaaaaaa |
42 | | -``` |
| 80 | +``` |
| 81 | + |
| 82 | +### List All Billings |
| 83 | + |
| 84 | +```python |
| 85 | +billings = client.billing.list() |
| 86 | +for billing in billings: |
| 87 | + print(billing.id, billing.status) |
| 88 | +``` |
| 89 | + |
| 90 | +### Customer Management |
| 91 | + |
| 92 | +```python |
| 93 | +from abacatepay.models import Customer |
| 94 | + |
| 95 | +customer = Customer( |
| 96 | + email="customer@example.com", |
| 97 | + name="Customer Name", |
| 98 | + cellphone="+1234567890" |
| 99 | +) |
| 100 | + |
| 101 | +created_customer = client.customers.create(customer=customer) |
| 102 | +print(created_customer.id) |
| 103 | +``` |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## Contributing |
| 108 | + |
| 109 | +We welcome contributions to the AbacatePay SDK! Follow the steps below to get started: |
| 110 | + |
| 111 | +1. Fork the repository on GitHub. |
| 112 | + |
| 113 | +2. Clone your fork locally: |
| 114 | + |
| 115 | + ```bash |
| 116 | + git clone https://github.com/your-username/abacatepay.git |
| 117 | + cd abacatepay |
| 118 | + ``` |
| 119 | + |
| 120 | +3. Set up the virtual environment using [poetry](https://python-poetry.org/): |
| 121 | +> If you don't have poetry installed, you can install following the instructions [here](https://python-poetry.org/docs/#installing-with-the-official-installer). |
| 122 | +
|
| 123 | + ```bash |
| 124 | + poetry install |
| 125 | + ``` |
| 126 | + |
| 127 | +4. Make your changes in a new branch: |
| 128 | + |
| 129 | + ```bash |
| 130 | + git checkout -b feature-name |
| 131 | + ``` |
| 132 | + |
| 133 | +5. Run tests to ensure your changes don’t break existing functionality: |
| 134 | + |
| 135 | + ```bash |
| 136 | + poetry run pytest |
| 137 | + ``` |
| 138 | + |
| 139 | +6. Commit your changes and push the branch: |
| 140 | + |
| 141 | + ```bash |
| 142 | + git add . |
| 143 | + git commit -m "Add feature or fix description" |
| 144 | + git push origin feature-name |
| 145 | + ``` |
| 146 | + |
| 147 | +7. Open a pull request on GitHub and describe your changes. |
0 commit comments