STRIPE PAY SERVICE
Server side implementation of Stripe payment gateway.
RUN THE PROJECT
Make sure you have docker installed.
git clone https://github.com/swagftw/stripe_pay_service
Spin up server
Go to the postman environments and add variable
Download postman collections
Setup an environment in postman add the following variable:
If you are running locally
If you are running on the server
Choose the environment just created and check requests in above collections.
RUN THE TESTS
Make sure you have go installed
cd to cloned project
go mod download && go mod vendor
Get Stripe mock server
docker run -p 12111:12111 stripe/stripe-mock
go test -v ./...
MORE ABOUT PROJECT
Project is based on hexagonal architecture. It consists of three primary layers: - business logic layer - data layer - transport layer
More about architecture
- /cmd // contains all the executables |- /api // contains the API server startpoint - /pkg // contains all the packages, which is core business logic |- /api // initial API server, acts as dependency injection container for starting api server. |- /payments // payments core logic package |- /repository // payments database repository package |- payments.go // holds implementation of payments service interface |- service.go // contains repository interface and db models - /transaction // contains the global transaction interface, that can be implemented by multiple dbs |- /postgres // contains postgres implementation of transaction interface - /transport // contains the all sorts of transports, currently over http may contain rpc, grpc, etc |- /payments // contains the http handlers for payments service - /types // contains all the service interfaces & types, required for service and it sits on top of the project heirarchy - /utl // contains all the utility functions |- /config // config utility functions |- /constant // contains constants used over project |- /fault // fault is custom error type used over project to throw errors |- /logger // custom logger implementation over Uber's zap logger |- /migration // database migration utility functions |- /mock // mocks for different services |- /server // server utility functions and custom error handler, validators, middlewares |- /storage // database utitilies |- /stripeclient // custom implementation over stripe go sdk for abstracting stripe api
To test API run postman test collection provided above.
- Writing more test cases - Writing API test cases in project itself. - Remove env file from project, kept file for now in remote repo just for dev purposes.