Payment service aims to process payment thorugh various payment systems such as SWIFT, CHAPS etc.
We are using gin-swagger (https://github.com/swaggo/gin-swagger) - see the comments added in each endpoint handler (api/handler.go
)
You can access swagger documentation: http://localhost:8080/swagger/index.html. The swagger doc has already been generated
To generate a newer version of the operations to be exposed. Run these steps:
- Install the swag tool using this script:
./scripts/install_swag.sh
- Run
swag init
. This will generate a new swagger docs file see -./docs/docs.go
You can download docker from here
The payment service uses dep
to install its dependencies. Details on how to install dep
can be found here
-
Adding the project for the first time:
dep ensure -vendor-only
-
Adding a new dependency
dep ensure -add <dependecy path>
- Install GO:
brew install go
- Install DEP
brew install dep
- Set the GOPATH env variable and add it to the path in your bash profile (~/.profile):
export GOPATH=$WAVE_PROJECT_HOME/go
export PATH=$PATH:$GOPATH/bin
Note when you run the test for the first time it will take some time. The test run a cockroach database
docker container in the background
scripts/./run-tests.sh
docker-compose up --build
curl http://localhost:8080/health
HTTP/1.1 200 OK
Content-Length: 29
Content-Type: application/json; charset=utf-8
Date: Mon, 20 Aug 2018 07:18:49 GMT
{
"message": "Up and running!"
}
curl -d @samples/paymentRequest.json -H "Content-Type: application/json" -X POST http://localhost:8080/payment
{ "id": "5bd7506a9900b30008edf576", "organisation_id": "743d5b63-8e6f-432e-a8fa-c5d8d2ee5fcb" }
curl -X GET http://localhost:8000/payment
curl -X GET http://localhost:8080/payment/5bd7506a9900b30008edf576
curl -X DELETE http://localhost:8080/payment/5bd7506a9900b30008edf576
curl -d @samples/paymentRequest.json -H "Content-Type: application/json" -X PUT http://localhost:8080/payment/5bd7506a9900b30008edf576
To generate a mock for an interface run the followings:
1- Install gomock
go get github.com/golang/mock/gomock
2- Install mockgen
go get github.com/golang/mock/mockgen
mockgen
binary should be installed in $GOPATH/bin
To gnerate the mock repository run the following command:
1 - Create mock
directory.
2 - $GOPATH/bin/mockgen -destination=mocks/mock_repository.go -package=mocks payment-service/repository Repository