Giter Club home page Giter Club logo

digital-wallet's Introduction

Wallet Transaction System

Create a wallet transaction system, like Paytm

Problem Statement

Setup

docker-compose up

This should run the app on port 1970

Health Check

curl --location 'http://127.0.0.1:1970/ping'

should return pong

Test

docker-compose run test pytest --cov=app

Usage

  1. Create user
curl --location 'http://127.0.0.1:1970/user' \
--header 'Content-Type: application/json' \
--data '{
    "phone": "1234567890"
}'

Response

{
    "message": "User created successfully",
    "user": {
        "id": 3,
        "phone": "1234567890"
    }
}
  1. Create wallet
curl --location 'http://127.0.0.1:1970/wallet' \
--header 'Content-Type: application/json' \
--data '{
    "user_id": 1,
    "wallet_type": "standard"
}'

Response

{
    "wallet_id": 1
}
  1. Check wallet balance
curl --location 'http://127.0.0.1:1970/wallet/1'

Response

{
    "balance": 0.0
}
  1. Credit to wallet
curl --location 'http://127.0.0.1:1970/wallet/1/credit' \
--header 'Content-Type: application/json' \
--data '{
    "amount": 10000
}'

Response

{
    "message": "Wallet credited successfully"
}
  1. Debit from wallet
curl --location 'http://127.0.0.1:1970/wallet/1/debit' \
--header 'Content-Type: application/json' \
--data '{
    "amount": 300
}'

Response

{
    "message": "Wallet debited successfully"
}
  1. View Transactions
curl --location 'http://127.0.0.1:1970/wallet/1/transactions?null=null&start_date=2020-06-21&end_date=2025-06-21'

Response

{
    "transactions": [
        {
            "amount": 10000.0,
            "id": 1,
            "timestamp": "2024-04-21T22:11:31.995606",
            "transaction_type": "credit",
            "wallet_id": 1
        },
        {
            "amount": 300.0,
            "id": 2,
            "timestamp": "2024-04-21T22:12:37.804476",
            "transaction_type": "debit",
            "wallet_id": 1
        },
        {
            "amount": 1400.0,
            "id": 3,
            "timestamp": "2024-04-21T22:16:11.808685",
            "transaction_type": "credit",
            "wallet_id": 1
        },
        {
            "amount": 1400.0,
            "id": 4,
            "timestamp": "2024-04-21T22:28:12.668519",
            "transaction_type": "credit",
            "wallet_id": 1
        },
        {
            "amount": 1400.0,
            "id": 5,
            "timestamp": "2024-04-21T22:28:26.168124",
            "transaction_type": "credit",
            "wallet_id": 1
        },
        {
            "amount": 1400.0,
            "id": 6,
            "timestamp": "2024-04-21T22:28:26.951352",
            "transaction_type": "credit",
            "wallet_id": 1
        }
    ]
}

digital-wallet's People

Contributors

indrajithi avatar

Watchers

 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.