Skip to content

singularbek/payment-ingestion-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Payment Ingestion Module

Overview

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.

Tech stack

  • Go
  • PostgreSQL
  • RabbitMQ
  • Docker / Docker Compose
  • github.com/rabbitmq/amqp091-go
  • github.com/joho/godotenv
  • github.com/robfig/cron/v3
  • github.com/lib/pq

Architecture

The module is structured as a small microservice within a broader payment integration environment.

  • cmd/main.go bootstraps the service, creates DB connections, starts HTTP servers, and wires RabbitMQ listeners.
  • internal/config loads environment variables from .env.
  • internal/storage manages PostgreSQL connectivity and database creation.
  • internal/server implements the API servers.
  • internal/services contains business logic for payment and sandbox webhook processing.
  • internal/rabbitmq handles RabbitMQ publishing and consuming.
  • internal/models defines shared domain models and payload types.

Runtime behavior

  • When MODE=production, the service connects to RabbitMQ and listens on broker queues such as order_status and test_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_events rows to keep storage bounded.

Repository structure

  • cmd/ - main application entrypoint
  • internal/config/ - environment and config loader
  • internal/models/ - shared data models
  • internal/rabbitmq/ - RabbitMQ client abstraction
  • internal/server/ - HTTP API server logic
  • internal/services/ - payment processing and sandbox logic
  • internal/storage/ - database connection and storage helpers
  • internal/storage/migrations/ - production DB migrations
  • internal/storage/sandbox_migrations/ - sandbox DB migrations
  • utils/ - utility helpers

Important caveat

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.

Running locally

To run the service locally, ensure your environment provides the required variables and starts the necessary infrastructure.

Key environment variables include:

  • PORT
  • DB_USER
  • DB_PASSWORD
  • PROD_DB_HOST
  • PROD_DB_PORT
  • TEST_DB_HOST
  • TEST_DB_PORT
  • PROD_DB
  • TEST_DB
  • RABBITMQ_USER
  • RABBITMQ_PASSWORD
  • RABBITMQ_HOST
  • MODE

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.

Notes

  • The code is intended for demonstration and learning rather than production deployment.
  • The application assumes a surrounding microservices environment to be truly useful.

About

Go payment ingestion service. part of a micro-services architecture. for demonstrative purposes only.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages