Coder Social home page Coder Social logo

wallet-example's Introduction

Wallet Service Example

Wallet Service with Event Sourcing.

Prerequisites

  • Go

Domain

  • Wallet

Getting Started

How To Serve

go run ./cmd/app

or

make run_dev

Tool

Make

  1. Migration
make migration version=YOUR_VERSION_NUMBER filename=YOUR_FILE_NAME
  1. Domain
make domain name=YOUR_DOMAIN_NAME

Service

Top Up

[POST] localhost:8001/wallet/{wallet_id}/top-up

Request Payload
{
    "amount": 25000
}
Response
{
    "data": {
        "amount": 25000,
        "job": "Top Up",
        "status": "succeed"
    },
    "metadata": {}
}

Withdraw

[POST] localhost:8001/wallet/{wallet_id}/withdraw

Request Payload
{
    "account_number": "5271531169",
    "account_holder": "Fredrick Widjaya",
    "bank": "bca",
    "amount": 500000
}
Response
{
    "data": {
        "amount": 500000,
        "job": "Withdraw",
        "status": "succeed"
    },
    "metadata": {}
}

GetBalance

[POST] localhost:8001/wallet/{wallet_id}/balance

Response
{
    "data": {
        "balance": 25000
    },
    "metadata": {}
}

GetTransaction

[POST] localhost:8001/wallet/{wallet_id}/transactions

Response
{
    "data": [
        {
            "transaction_id": "cbf3a305-326f-40b7-a947-265c03b64ed7",
            "amount": -500000,
            "balance_type": "withdraw",
            "notes": "{\"fee\": 4000, \"amount\": 500000.000000, \"message\": \"withdraw\", \"withdraw_destination\": {\"bank\": \"bca\", \"account_holder\": \"Fredrick Widjaya\", \"account_number\": \"5271531169\"}}"
        },
        {
            "transaction_id": "9a7fa26e-e177-47b5-b6a0-a3dd2a77fb01",
            "amount": 25000,
            "balance_type": "deposit",
            "notes": "{\"message\": \"add\"}"
        },
        {
            "transaction_id": "555aaa77-a43e-453a-af25-4d376905b97c",
            "amount": 250000,
            "balance_type": "deposit",
            "notes": "{\"message\": \"add\"}"
        },
        {
            "transaction_id": "235ce377-ca65-4fd5-a060-717fede5e205",
            "amount": 150000,
            "balance_type": "deposit",
            "notes": "{\"message\": \"add\"}"
        },
        {
            "transaction_id": "00fc28d7-bff8-46fc-8ff7-1292be2977c3",
            "amount": 50000,
            "balance_type": "deposit",
            "notes": "{\"message\": \"add\"}"
        },
        {
            "transaction_id": "981284eb-88d6-445b-9f55-927dd92c59ac",
            "amount": 50000,
            "balance_type": "deposit",
            "notes": "{\"message\": \"add\"}"
        }
    ],
    "metadata": {}
}

wallet-example's People

Contributors

fwidjaya20 avatar

Watchers

James Cloos 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.