Skip to content

shubhamDev73/wallet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wallet transaction system

Installation and running

  • Requires Python 3.8 or above installed
  • Install dependencies pip install -r requirements.txt
  • Create database python manage.py migrate
  • Create test user python manage.py createsuperuser
  • Run server python manage.py runserver

Note: tests can be run using python manage.py test

Structure

API structure

  • /<user_id>/wallet/ root node to access all functionalities for the wallet associated with user of id user_id
    • create/ (POST) creates new wallet
    • balance/ (GET) gets current balance
    • debit/ (POST) debits amount
    • credit/ (POST) credits amount

Response structure

Responses are returned in JSON format. Each response has a success field which indicates whether the given action was successfully performed or not. In case of failure, there is an error field which indicates the type of error which occurred.

Sample curl requests

  • curl --request POST --url http://localhost:8000/1/wallet/create/ create a new wallet for user 1
  • curl --request GET --url http://localhost:8000/1/wallet/balance/ get balance for wallet of user 1. returns {"success": true, "balance": 100}
  • curl --request POST --url http://localhost:8000/1/wallet/debit/ -H "Content-Type: application/json" -d '{"amount": 20}' debit 20 amount from wallet of user 1
  • curl --request POST --url http://localhost:8000/1/wallet/credit/ -H "Content-Type: application/json" -d '{"amount": 20}' credit 20 amount to wallet of user 1

Notes

  • all transactions create a log entry in the log file for the respective wallet. log files can be found in logs/ directory with format wallet<wallet_id>.log
  • debit transactions fail if balance is less than minimum balance (currently set to 100. can be adjusted in server/config.py)
  • this API does not handle user creation and authentication
  • only 1 create or credit or debit transaction is performed at a time for a user

About

Demo wallet transaction system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages