This repository contains the code for a demonstration payment ingestion module implemented in Go. It shows how a payment integration microservice can:
- ingest webhook payloads
- consume RabbitMQ messages
- persist payment event data into Postgres
- run API servers for production and sandbox/test flows
- clean up old ingestion records with a cron job
This repository is intended for demonstration purposes only. It is one piece of a larger payment integration ecosystem and does not function as a complete payment system on its own.
- Go
- PostgreSQL
- RabbitMQ
- Docker / Docker Compose
github.com/rabbitmq/amqp091-gogithub.com/joho/godotenvgithub.com/robfig/cron/v3github.com/lib/pq
The module is structured as a small microservice within a broader payment integration environment.
cmd/main.gobootstraps the service, creates DB connections, starts HTTP servers, and wires RabbitMQ listeners.internal/configloads environment variables from.env.internal/storagemanages PostgreSQL connectivity and database creation.internal/serverimplements the API servers.internal/servicescontains business logic for payment and sandbox webhook processing.internal/rabbitmqhandles RabbitMQ publishing and consuming.internal/modelsdefines shared domain models and payload types.
- When
MODE=production, the service connects to RabbitMQ and listens on broker queues such asorder_statusandtest_order_status. - Incoming messages are unmarshaled into transaction payloads and forwarded into service processors.
- Separate production and sandbox API servers are started on different ports.
- A cron job periodically deletes old
payment_eventsrows to keep storage bounded.
cmd/- main application entrypointinternal/config/- environment and config loaderinternal/models/- shared data modelsinternal/rabbitmq/- RabbitMQ client abstractioninternal/server/- HTTP API server logicinternal/services/- payment processing and sandbox logicinternal/storage/- database connection and storage helpersinternal/storage/migrations/- production DB migrationsinternal/storage/sandbox_migrations/- sandbox DB migrationsutils/- utility helpers
This repository is part of an entire payment integration stack. It is not fully functional by itself because it expects external microservices like:
- message brokers (RabbitMQ)
- merchant API providers
- switch services
- notification services
- additional payment adapters
Without those external services and the rest of the integration landscape, this module only demonstrates one side of payment ingestion.
To run the service locally, ensure your environment provides the required variables and starts the necessary infrastructure.
Key environment variables include:
PORTDB_USERDB_PASSWORDPROD_DB_HOSTPROD_DB_PORTTEST_DB_HOSTTEST_DB_PORTPROD_DBTEST_DBRABBITMQ_USERRABBITMQ_PASSWORDRABBITMQ_HOSTMODE
The service currently uses Postgres for production and sandbox storage. The provided docker-compose.yaml illustrates a multi-container environment including Postgres, MySQL, RabbitMQ, and example companion services.
- The code is intended for demonstration and learning rather than production deployment.
- The application assumes a surrounding microservices environment to be truly useful.