A smart automation tool that compares internal transaction records with payment gateway data (Paystack, Stripe, etc.) and automatically reports mismatches, missing transactions, and inconsistencies.
Ideal for Finance, QA, and DevOps teams looking to maintain accurate financial records and ensure gateway integrations are working correctly.
The Automated Transaction Reconciliation System streamlines financial verification by cross-checking internal transaction data from your systems against external payment gateways like Paystack or Stripe.
It helps you automatically detect:
- Missing or duplicate transactions
- Amount or currency mismatches
- Status inconsistencies
- Integration or API syncing errors
You can run it manually, on a schedule, or inside a CI/CD pipeline.
Reports can be sent to Slack, saved as CSV, or logged locally.
β Load internal transaction data from:
- CSV (mock/testing)
- SQL database (PostgreSQL / MySQL)
- MongoDB
β Fetch payment gateway data from:
- Paystack API
- Stripe API
- Mock CSV (for testing)
β Perform:
- Transaction reconciliation
- Field normalization & mapping
- Amount and currency validation
- Status mismatch detection
- Summary and detailed reports
β Notify & Export:
- Slack alerts with reconciliation summaries
- Local CSV or JSON reports
- Logs for automation pipelines
βββββββββββββββββββββββ
β Internal Data Source β
β (SQL / Mongo / CSV) β
βββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββ
β Data Loader β
β (src/data_loader.py)β
βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Reconciliation β
β (compare logic) β
βββββββββββββββββββ
β
βββββββββββββββ΄ββββββββββββββ
βΌ βΌ
ββββββββββββββββ ββββββββββββββββββ
β Slack Alerts β β CSV / JSON Log β
ββββββββββββββββ ββββββββββββββββββ
git clone https://github.com/kingdavidmiles/transaction-reconciliation-bot
cd transaction-reconciliation-botpython3 -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windowspip install -r requirements.txtExample requirements.txt includes:
pandas
requests
python-dotenv
sqlalchemy
pymongo
openpyxl
schedule
slack_sdk
Create a .env file in the root directory and fill it like this:
# =====================================
# MODES
# Choose your data sources independently
# =====================================
INTERNAL_MODE=mock # mock | mongo | sql
GATEWAY_MODE=mock # mock | paystack | stripe
# =====================================
# AI & SLACK
# =====================================
USE_AI=False
OPENAI_API_KEY=sk-projxxxxxxxxxxx
SLACK_BOT_TOKEN=xoxb-xxxxxxxx
SLACK_CHANNEL_ID=D09xxxxxx
USE_SLACK=True
# =====================================
# DATABASE CONFIG (Mongo + SQL)
# =====================================
SQL_DB_URI=postgresql://username:password@localhost:5432/fintech_db
MONGO_URI=mongodb://localhost:27017/
MONGO_DB=fintech_db
MONGO_COLLECTION=transactions
# =====================================
# PAYSTACK CONFIG
# =====================================
PAYSTACK_SECRET=sk_test_your_secret_key
PAYSTACK_API_URL=https://api.paystack.co/transaction
# =====================================
# STRIPE CONFIG
# =====================================
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
STRIPE_API_URL=https://api.stripe.com/v1/charges
# Logging & Reports
REPORT_PATH=reports/This project sends daily or on-demand reconciliation reports directly to a Slack channel.
- Go to Slack API Apps
- Click Create New App β βFrom Scratchβ
- Add these Bot Token Scopes under OAuth & Permissions:
chat:writechannels:readgroups:readusers:read
- Install the app to your workspace
- Copy the Bot User OAuth Token (looks like
xoxb-...) - Add it to your
.envasSLACK_BOT_TOKEN - Right-click your Slack channel β βView channel detailsβ β βMoreβ β βCopy Channel IDβ
Add it to.envasSLACK_CHANNEL_ID
β Example Slack Message:
π¨ Reconciliation Summary
-----------------------------------
β
Matched Transactions: 984
β οΈ Missing in Gateway: 12
β Status Mismatch: 4
π Timestamp Drift: 3
-----------------------------------
Report saved: reports/summary_2025-10-19.csv
python -m src.mainYou can schedule it to run periodically using the built-in scheduler:
python -m src.schedulerThis runs reconciliation every hour (you can adjust the schedule inside src/scheduler.py).
π Loading internal data from SQL...
π Fetching Paystack transactions...
β
Loaded 1,200 internal records and 1,198 gateway records
β οΈ 2 missing transactions detected
β
Reconciliation report generated and sent to Slack
| tx_id | amount | status_internal | status_gateway | match_status |
|---|---|---|---|---|
| TXN001 | 15000 | success | success | β |
| TXN002 | 12000 | failed | success | β |
| TXN003 | 9000 | success | missing |
src/
βββ main.py # Entry point
βββ data_loader.py # Load internal/gateway data
βββ reconciler.py # Compare and detect mismatches
βββ notifier.py # Slack notifications
βββ config.py # Environment and mappings
βββ scheduler.py # Periodic task runner
βββ utils/
βββ logger.py # Logging utility
data/
βββ internal_mock.csv
βββ gateway_mock.csv
reports/
βββ summary_2025-10-19.csv
Mappings are defined dynamically in config.py:
GATEWAY_MAPPINGS = {
"paystack": {
"reference": "tx_id",
"amount": "amount",
"status": "status",
"currency": "currency",
"paid_at": "created_at"
},
"stripe": {
"id": "tx_id",
"amount": "amount",
"status": "status",
"currency": "currency",
"created": "created_at"
}
}- Built using Python 3.10+
- Logging powered by
loggingmodule - Data pipelines via Pandas
- Compatible with PostgreSQL, MySQL, and MongoDB
- Slack integration via
slack_sdk
- Add webhook triggers for real-time reconciliation
- Support for additional gateways (Flutterwave, PayPal)
- Enhanced anomaly detection via ML
If you run into issues:
- Open an issue on GitHub Issues
- Or message via Slack integration
Contributions are welcome!
- Fork the repo
- Create a feature branch
- Commit changes and open a PR π
This project is licensed under the MIT License β free to use, modify, and distribute.
- π Slack API App Setup Guide
- π³ Paystack API Docs
- π° Stripe API Docs
- π§Ύ Pandas Documentation
- βοΈ SQLAlchemy Docs
- π§ MongoDB PyMongo Docs