https://github.com/emcfarlane/checkout
Simple Checkout Service
https://github.com/emcfarlane/checkout
Last synced: 2 months ago
JSON representation
Simple Checkout Service
- Host: GitHub
- URL: https://github.com/emcfarlane/checkout
- Owner: emcfarlane
- Created: 2020-08-03T17:36:17.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-04T10:43:29.000Z (almost 6 years ago)
- Last Synced: 2024-04-21T00:58:19.388Z (about 2 years ago)
- Language: Go
- Size: 34.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Checkout
===
Checkout implements a simple authorization flow service.
- gRPC service with HTTP bindings by [graphpb](https://github.com/emcfarlane/graphpb)
- Postgres service with library from [go cloud cdk](https://github.com/google/go-cloud)
Build
---
Build with go:
```
go install ./checkout
```
### Protobuf (optional)
Protobuffers can be rebuilt with protoc:
```sh
protoc -I checkoutpb --go_out=paths=source_relative:checkoutpb --go-grpc_out=paths=source_relative:checkoutpb checkoutpb/checkout.proto
```
NB: Requires both go & grpc protobuf generates installed locally as well as protoc with google apis included.
Run
---
Run must specify a DATABASE address.
```
POSTGRES=postgres://:@localhost/ checkout
```
The database URL pattern is described [here](https://gocloud.dev/howto/sql/).
Test
---
Unit tests can be run:
```
go test -v .
```
Integration tests require a postgresql database connection:
```
POSTGRES=postgres://:@localhost/ go test -v -tags=integration .
```
Examples
---
Create a new authorization:
```
curl -X POST -H "Content-Type: application/json" -d '{"pan":"4532111111111112","exp_month":"1","exp_year":"2022","cvv":"123","
amount":500,"currency":"gbp"}' localhost:8080/authorize
```
Capture an authorization:
```
curl -X PATCH -H "Content-Type: application/json" -d '{"id":"","amount":250}' localhost:8080/capture
```
Refund an authorization:
```
curl -X PATCH -H "Content-Type: application/json" -d '{"id":"","amount":250}' localhost:8080/refund
```
Void an authorization:
```
curl -X POST -H "Content-Type: application/json" -d '{"id":""}' localhost:8080/void
```