Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/MarinX/kit-payment

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/MarinX/kit-payment

  • v0.0.0-20190213002003-877dc428832b
  • Source
  • Go
  • Socket score

Version published
Created
Source

Payment service with go-kit

Build Status Go Report Card GoDoc License MIT

Getting started

Building

Clone the repo

git clone https://github.com/MarinX/kit-payment

Fetch dependencies

go get ./...

Build as any other go project

go build

Usage

Usage of ./kit-payment:
  -http.addr string
        HTTP listen address (default ":8080")

Storage

Kit-payment is using embedded key/value database called boltdb.

Endpoints

Accounts

Creating account
curl -H "Content-Type: application/json" -X POST http://localhost:8080/accounts
Listing accounts
curl -H "Content-Type: application/json" -X GET http://localhost:8080/accounts
Adding balance to account

Example addding $100 to account id 3479d3a8-42c4-4b40-8a1d-1b1661d7b6ef

curl -d '{"currency":"USD", "amount":100}' -H "Content-Type: application/json" -X POST http://localhost:8080/accounts/3479d3a8-42c4-4b40-8a1d-1b1661d7b6ef/balances

Transactions

List Transactions
curl -H "Content-Type: application/json" -X GET http://localhost:8080/transactions
Creating Transaction

Example of moving $50 from account 3479d3a8-42c4-4b40-8a1d-1b1661d7b6ef to account 06e39e77-776a-4694-bc59-fea69bc8afd8

curl -d '{"from":"3479d3a8-42c4-4b40-8a1d-1b1661d7b6ef", "to":"06e39e77-776a-4694-bc59-fea69bc8afd8", "currency":"USD", "amount":50}' -H "Content-Type: application/json" -X POST http://localhost:8080/transactions

If success, it will return a created transaction object

{"transaction":{"id":"fecf39a1-c4f2-4706-8eca-bc71f310eeb6","from":"3479d3a8-42c4-4b40-8a1d-1b1661d7b6ef","to":"06e39e77-776a-4694-bc59-fea69bc8afd8","status":"created","amount":50,"currency":"USD"}}
Get Transaction

Example of getting single transaction by id fecf39a1-c4f2-4706-8eca-bc71f310eeb6

curl -H "Content-Type: application/json" -X GET http://localhost:8080/transactions/fecf39a1-c4f2-4706-8eca-bc71f310eeb6
Commit Transaction

Once the transaction is created, you need to commit. Example is commiting created transaction fecf39a1-c4f2-4706-8eca-bc71f310eeb6

curl -H "Content-Type: application/json" -X PUT http://localhost:8080/transactions/fecf39a1-c4f2-4706-8eca-bc71f310eeb6/commit

Now you can check the status with Get Transaction method. If account has enough balance, you will see the change on amount when listing accounts.

Transaction verification

It provides a interface for merkle tree so we can check if all transactions are verified. Example of checking our last transaction fecf39a1-c4f2-4706-8eca-bc71f310eeb6

curl -H "Content-Type: application/json" -X GET http://localhost:8080/transactions/fecf39a1-c4f2-4706-8eca-bc71f310eeb6/hash

will return the hash for verification

{"hash":"fdf227bade5496e59824a4c9ef59ec992c61b4521fe0003c5be4d79cec3c885c"}

Tests

Nothing fancy, just run

go test -v ./...

Roadmap

  • Support currency conversion
  • Support user accounts
  • Integrate merkle tree so we can verify transactions and extend (mining?)

PR's welcome :)

FAQs

Package last updated on 13 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc