Giter Site home page Giter Site logo

wallet's Introduction

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

wallet's People

Contributors

shubhamdev73 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.