Giter VIP home page Giter VIP logo

wallet's Introduction

Wallet Rest Api

Get account balance

Returns json data with current balance.

  • URL

    /account/:id

  • Method:

    GET

  • URL Params

    Required:

    id=[integer]

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content: { "balance": 1001 }
  • Error Response:

Deposit new funds to account

Returns json data with deposit effects.

  • URL

    /account/:id/deposit

  • Method:

    POST

  • URL Params

    Required:

    id=[integer]

  • Data Params

    amount: [integer]

  • Success Response:

    • Code: 200
      Content: { "change": 1001, "currentBalance":1001 }
  • Error Response:

Withdraw some funds from account

Returns json data with withdrawal effects.

  • URL

    /account/:id/dewithdrawposit

  • Method:

    POST

  • URL Params

    Required:

    id=[integer]

  • Data Params

    amount: [integer]

  • Success Response:

    • Code: 200
      Content: { "change": 1001, "currentBalance":1001 }
  • Error Response:

    • Code: 400
      Content: { "change": 10001, "currentBalance":1001, "msg":"Insufficient Funds" }

**Transfer funds from account A to account B **

Returns json data with unique transaction id, and transaction effect for donor account.

  • URL

    /account/:donorId/transfer/:recipientId

  • Method:

    POST

  • URL Params

    Required:

    donorId=[integer] recipientId=[integer]

  • Data Params

    amount: [integer]

  • Success Response:

    • Code: 200
      Content: {"transactionId": "2b878a1e-06ca-405a-8f50-177f6bbd6845","amount": 100, "currentBalance":901 }
  • Error Response:

    • Code: 400
      Content: { "transactionId": "1579f5c3-6829-4bb3-8888-e87ccde238f1", "donorId": "1", "recipientId": "2", "currentBalance": 901, "amount": 1000, "msg": "Insufficient Funds" }

**Get transfer state **

Returns json data with unique transaction id, and transaction effect for donor account.

  • URL

    /transfer/:transferId

  • Method:

    GET

  • URL Params

    Required:

    transferId=[integer]

  • Success Response:

    • Code: 200
      Content: { "transactionId": "267f5d8e-06b5-42a8-bb31-4ef9a051d418", "donorId": "1", "recipientId": "2", "stateName": "Succeeded", "amount": 100, "progress": 1 }
  • Error Response:

    • Code: 400
      Content: { "transactionId": "1579f5c3-6829-4bb3-8888-e87ccde238f1" "donorId": "1", "recipientId": "2", "stateName": "Failed", "amount": 1000, "progress": 1, "msg": "Insufficient Funds", }

Transfer mechanics:

  • Transfers are designed as persistent five stages FSM construct. That can end with success or failure in cass of insufficient founds on donor Account. Under REST Api implementation transfer are based on persistent Actors, which are triggered with Persisted Transfer Command. Command effects with first "Withdrawal" stage and account service call for withdraw funds from donor account. If succeeded deposit stage comes in. Current implementation dose not involve reversal. In case of failure or instance restart all uncompleted transfers should be restarted or reinstated. Starting transaction from beginning. All transaction ale register in Transfer Register actor that keeps collection of all uncompleted transfers. After wallet restart all uncompleted transfer are reinstated with WeakUp msg. Restarted Transaction recovers from journal original Transaction Command and retries all steps (withdrawal, deposit). Idempotency mechanism implemented in Account Actor stand as guarantee of no multiple operation processing threat (charging or deponing twice)

graph

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.