A flexible and extensible payment service designed to integrate with multiple payment gateways. You can find the design document here and openapi spec here
- Modular architecture for easy integration of new payment gateways
- Configurable retry mechanism with customizable backoff strategies
- Flexible serialization/deserialization support
- Abstracted protocol handling for various communication methods
- Comprehensive error handling and logging
- Go 1.23
- make
- Docker
- Install necessary dependencies
make init
- Run app and postgres
make docker-compose/up
- Run database migrations
export PGDATABASE=payment
export DATABASE_URL=postgres://postgres:postgres@localhost:5432/payment
export GOOSE_MIGRATION_DIR=db/migrations
export GOOSE_DRIVER=postgres
export GOOSE_DBSTRING="$DATABASE_URL"
goose up
- Access the API on http://localhost:8080
To stop API and postgres
make docker-compose/down
make test
- Create transaction
curl --request POST \
--url http://localhost:8080/api/v1/transactions \
--header 'Content-Type: application/json' \
--data '{
"amount": 123,
"type": "withdrawal",
"currency": "USD",
"payment_method": "BANK_TRANSFER",
"description": "payment",
"customer_id": "cus123",
"preferred_gateway": "gatewayB",
"metadata": {
"orderID": 123
}
}'
- Gateway A callback
curl --request POST \
--url http://localhost:8080/api/v1/gateways/gatewayA/callback \
--header 'Content-Type: application/json' \
--data '{
"ref_id": "TiOIptTKAggASOT5wu3i",
"status": "success"
}'
- Gateway B callback
curl --request POST \
--url http://localhost:8080/api/v1/gateways/gatewayB/callback \
--header 'Content-Type: application/xml' \
--data '<?xml version="1.0" encoding="UTF-8"?>
<callback>
<ref_id>isbKQ4O8LHtIViY61ADa</ref_id>
<status>success</status>
</callback>'
- Update status API
Replace with id in the path
curl --request PATCH \
--url http://localhost:8080/api/v1/transactions/vxOAi2w6ZQB1pilXYitU/status \
--header 'Content-Type: application/json' \
--data '{
"gateway": "gatewayB",
"status": "success"
}'
- sqlc
- goose
- sony/gobreaker circuit breaker
- Improve test coverage
- Take config from environment variables