An open API service indexing awesome lists of open source software.

https://github.com/ghmeier/coinage

:moneybag: Expresso's Billing microservice, written in Go
https://github.com/ghmeier/coinage

Last synced: 5 months ago
JSON representation

:moneybag: Expresso's Billing microservice, written in Go

Awesome Lists containing this project

README

          

# coinage
[![Build Status](https://travis-ci.org/ghmeier/coinage.svg?branch=master)](https://travis-ci.org/ghmeier/coinage)
[![Coverage Status](https://coveralls.io/repos/github/ghmeier/coinage/badge.svg?branch=master)](https://coveralls.io/github/ghmeier/coinage?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/ghmeier/coinage)](https://goreportcard.com/report/github.com/ghmeier/coinage)

A go service for handling Expresso billing

## Quick Start
```bash
$ docker run jonnykry/coinage:latest
```

## Setup
```bash
$ go get github.com/jonnykry/coinage
$ cd $GOPATH/src/github.com/jonnykry/coinage
$ make deps
$ make run
```

## API

### Roaster

### Customer

#### `POST /api/customer` creates a new stripe customer and stores its token.

Example:

*Request:*
```
POST localhost:8081/api/customer
{
"userId": "",
"token": ""
}
```

*Response:*
```
{
"data": {
"id": ,
"userId": ,
"customerId": ,
"subscriptions": {},
"sources": {},
"meta": {}
}
}
```

#### `GET /api/customer?offset=0&limit=20` gets stripe `limit` customers starting at `offset`

Example:

*Request:*
```
GET localhost:8081/api/customer?offset=0&limit=20
```

*Response:*
```
{
"data": [
{
"id": ,
"userId": ,
"customerId": ,
"subscriptions": {},
"sources": {},
"meta": {}
}, ...
]
}
```

#### `GET /api/customer/:id` gets a stripe customer by userId

Example:

*Request:*
```
GET localhost:8081/api/customer/1
```

*Response:*
```
{
"data": {
"id": ,
"userId": "1",
"customerId": ,
"subscriptions": {},
"sources": {},
"meta": {}
}
}
```

#### `DELETE /api/customer/:id` removes the stripe customer

Example:

*Request:*
```
DELETE localhost:8081/api/customer/1
```

*Response:*
```
{
"data": true
}
```

#### `POST /api/customer/:id/source` updates a user's default payment option by userId

Example:

*Request:*
```
POST localhost:8081/api/customer/1/source
{
"token": ""
}
```

*Response:*
```
{
"data": {
"id": ,
"userId": ,
"customerId": ,
"subscriptions": {},
"sources": {},
"meta": {}
}
}
```

#### `POST /api/customer/:id/subscription` subscribes the user to a new stripe plan

*NOT IMPLEMENTED*

Example:

*Request:*
```
POST localhost:8081/api/customer/1/subscription
```

#### `DELETE /api/customer/:id/subscription/:pid` unsubscribes the user from the plan where id=:pid

*NOT IMPLEMENTED*

Example:

*Request:*
```
POST localhost:8081/api/customer/1/subscription/2
```