The API Pagar.me is a simplified version of a market place and it is also a payment system where it is possible to buy products and process payments. This API uses python's framework Django and its Generic Views.
The Pagar.me API works with 4 tables: Users (Accounts), products (Product), fees (Fee), and payments (PaymentInfo). Bellow a brief description of each one and its register rules:
USERS:
Types:
There are 3 types of users: Seller (seller), Administrador (admin) and the common user (the one who's neither admin nor seller).
Permissons:
- Only logged admin users may register another user and list them.
- All logged users may update their own data.
PRODUCTS:
Permissons:
- Only logged seller users can register products and list them by id.
- A seller may list all of its registered products.
Register rules:
All products to be registered may have at least 1 copy.
FEES:
Permissons:
Only logged admin users can register fees and list them.
Other info:
- The default system fees are:
Credit card - 5%
Debit card - 3%
- Fees cannot be deleted.
PAYMENT INFO:
Permissons:
Only logged users that are neither administradors nor sellers can register cards and list them.
Register rules:
- Card numbers out of the expiration date cannot be registered.
- A card number may be registerd more than once if its payments metyhods are different (eg: credit or debit).
Other info:
- Only the last 4 card number digits are displayed.
- As well as the user's password, the card's CVV is registered but not displayed.
Bellow the tables diagram:
-
The code versioning Git.
-
A code editor, also known as IDE. For instance, Visual Studio Code (VSCode).
-
A client API REST program. Insomnia or Postman, for instance.
-
And versioning your directory to receive the aplication clone:
git init
git clone https://github.com/AndreKuratomi/pagar.me.git
WINDOWS:
Obs: In case of any mistake similar to this one:
unable to access 'https://github.com/AndreKuratomi/pagar.me.git/': SSL certificate problem: self-signed certificate in certificate chain
Configure git to disable SSL certification:
git config --global http.sslVerify "false"
Enter the directory:
cd pagar.me
LINUX:
python3 -m venv venv --upgrade-deps
WINDOWS:
py -m venv venv --upgrade-deps
LINUX:
source venv/bin/activate
WINDOWS:
On Windows operational system it is necessary to configure the Execution Policy at PowerShell:
Get-ExecutionPolicy # to check the Execution policy type
Set-ExecutionPolicy RemoteSigned # to change the type of policy if the command above shows 'Restricted'
Obs: It may often be necessary to open PowerShell as administrador for that.
.\env\Scripts\activate
pip install -r requirements.txt
WINDOWS:
In case any error similar to the one bellow be returned:
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\andre.kuratomi\\OneDrive - Company\\Área de Trabalho\\pagar.me\\pagar.me\\env\\Lib\\site-packages\\jedi\\third_party\\django-stubs\\django-stubs\\contrib\\contenttypes\\management\\commands\\remove_stale_contenttypes.pyi'
HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
Run cmd as adminstrador with the following command:
reg.exe add HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f
code .
LINUX:
python manage.py runserver
WINDOWS:
py manage.py runserver
For full description of endpoints and its responses check the insomnia documentation on the link bellow (necessary free login account):
https://pagar-5frujasuz-abkuras-projects.vercel.app/
- Django
- Django Rest Framework
- Generic views
- Git
- Insomnia-documenter
- Insomnia-documenter (quick tutorial)
- Python
- SQLite3
- Visual Studio Code (VSCode)
This project is exclusively for didatic purposes and has no commercial intent.