Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Windows Tipps & SecurityDave Plummer Has Made the Task Manager of Your Dreams(21.09.2026 um 21:20 Uhr)
Sichere ProgrammierungSubqueries and CTEs: Asking a Question Inside a Question(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungTVL Trend Analysis & Liquidity Risk Assessment: Lido(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungReact is Officially Dead in 2026 (Thanks to AI)(21.09.2026 um 21:01 Uhr)
Sichere ProgrammierungUsing SHA256 to Build Trustworthy Data Portals in Brazil(21.09.2026 um 21:01 Uhr)
Sichere Programmierung🚀 I reached 1,001 views on DEV!(21.09.2026 um 21:03 Uhr)
Sichere ProgrammierungReact Mental Models 2(21.09.2026 um 21:05 Uhr)
Sichere ProgrammierungAustralian RAM and SSD prices climb as stock tightens(21.09.2026 um 21:09 Uhr)
Windows Tipps & SecurityDave Plummer Has Made the Task Manager of Your Dreams(21.09.2026 um 21:20 Uhr)
Sichere ProgrammierungSubqueries and CTEs: Asking a Question Inside a Question(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungTVL Trend Analysis & Liquidity Risk Assessment: Lido(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungReact is Officially Dead in 2026 (Thanks to AI)(21.09.2026 um 21:01 Uhr)
Sichere ProgrammierungUsing SHA256 to Build Trustworthy Data Portals in Brazil(21.09.2026 um 21:01 Uhr)
Sichere Programmierung🚀 I reached 1,001 views on DEV!(21.09.2026 um 21:03 Uhr)
Sichere ProgrammierungReact Mental Models 2(21.09.2026 um 21:05 Uhr)
Sichere ProgrammierungAustralian RAM and SSD prices climb as stock tightens(21.09.2026 um 21:09 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

MpesaBooks — devto

{ "title": "Building M-Pesa Accounting Software: The Technical Stack Behind MpesaBooks", "content": "# Building M-Pesa Accounting Software: The Technical Stack Behind MpesaBooks\n\nKenya processes over $320 billion annually through…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

{
"title": "Building M-Pesa Accounting Software: The Technical Stack Behind MpesaBooks",
"content": "# Building M-Pesa Accounting Software: The Technical Stack Behind MpesaBooks\n\nKenya processes over $320 billion annually through M-Pesa. Yet most SMEs still reconcile these transactions in spreadsheets.\n\nThat's the problem MpesaBooks solves. But here's what most people don't realize: building M-Pesa accounting software isn't just about connecting to an API. It's about designing systems that survive on African mobile networks, handle concurrency at scale, and make sense of chaotic cash flow patterns.\n\nThis is how we built it.\n\n## The Core Challenge: M-Pesa Isn't a Ledger\n\nM-Pesa transactions are notifications. Notifications that arrive out of order, sometimes duplicate, sometimes late. A customer sends you 500 KES. You get notified 30 seconds later. Then again 2 minutes later (network hiccup). Meanwhile, your accountant needs to see your cash position *right now*.\n\nTraditional accounting software assumes instant, sequential transactions. M-Pesa assumes none of this.\n\nSo we built around three principles:\n1. **Idempotency first** — Every transaction is a unique event\n2. **Eventually consistent** — Real-time is nice; correct is essential\n3. **Network-first** — Assume phones will drop, reconnect, and retry\n\n## API Design: Webhook Reliability Over Perfection\n\nWe use M-Pesa's C2B (Customer to Business) webhook system. Here's the flow:\n\n```

javascript
\n// Our webhook receiver — first line of defense\napp.post('/mpesa/callback', async (req, res) => {\n const transaction = req.body;\n \n // Step 1: Acknowledge immediately (before processing)\n res.status(200).json({ \n ResultCode: 0, \n ResultDesc: 'Accepted'\n });\n \n // Step 2: Queue async (don't process in the request)\n await queue.add('process-mpesa-txn', transaction, {\n attempts: 5,\n backoff: {\n type: 'exponential',\n delay: 2000\n }\n });\n});\n

```
\n\nWhy this pattern? M-Pesa expects a response within 30 seconds. If we're slow, it retries. If we acknowledge first, then process in the background, we never lose a transaction.\n\nWe use Bull queues (backed by Redis) for this. On Heroku? AWS SQS works too. The point: decouple receipt from processing.\n\n## Database Design: Events Over Entities\n\nWe store transactions as immutable events, not mutable records.\n\n```

sql
\n-- The source of truth: raw M-Pesa notifications\nCREATE TABLE mpesa_events (\n id UUID PRIMARY KEY,\n merchant_request_id VARCHAR(255) UNIQUE NOT NULL,\n checkout_request_id VARCHAR(255),\n mpesa_receipt_number VARCHAR(100) UNIQUE,\n amount DECIMAL(15, 2) NOT NULL,\n phone_number VARCHAR(20) NOT NULL,\n transaction_timestamp TIMESTAMP NOT NULL,\n received_at TIMESTAMP DEFAULT NOW(),\n raw_payload JSONB,\n idempotency_key VARCHAR(255) UNIQUE,\n status ENUM('pending', 'processed', 'failed', 'reversed'),\n created_at TIMESTAMP DEFAULT NOW()\n);\n\n-- Derived: account ledger (rebuilt from events)\nCREATE TABLE account_ledger (\n id UUID PRIMARY KEY,\n business_id UUID REFERENCES businesses(id),\n mpesa_event_id UUID REFERENCES mpesa_events(id),\n debit DECIMAL(15, 2),\n credit DECIMAL(15, 2),\n balance DECIMAL(15, 2),\n posted_at TIMESTAMP,\n created_at TIMESTAMP DEFAULT NOW(),\n INDEX (business_id, posted_at)\n);\n

```
\n\nWhy separate tables? **Auditability + Flexibility**.\n\nIf M-Pesa sends a reversal (refund), it arrives as a new event with a reference to the original `mpesa_receipt_number`. We don't delete or update the original transaction. We add a new event and let the ledger rebuild itself.\n\n```

javascript
\n// Processing a transaction\nconst processTransaction = async (mpesaEvent) => {\n const db = await getConnection();\n \n try {\n await db.transaction(async (trx) => {\n // Check if already processed\n const existing = await trx('mpesa_events')\n .where('mpesa_receipt_number', mpesaEvent.mpesa_receipt_number)\n .first();\n \n if (existing) {\n return; // Idempotent — don't reprocess\n }\n \n // Insert the event\n const [eventId] = await trx('mpesa_events').insert({\n mpesa_receipt_number: mpesaEvent.mpesa_receipt_number,\n amount: mpesaEvent.amount,\n phone_number: mpesaEvent.phone_number,\n transaction_timestamp: mpesaEvent.transaction_date,\n raw_payload: mpesaEvent,\n status: 'processed'\n });\n \n // Append to ledger\n await trx('account_ledger').insert({\n mpesa_event_id: eventId,\n business_id: mpesaEvent.business_id,\n credit: mpesaEvent.amount,\n posted_at: new Date()\n });\n \n // Trigger balance recalculation\n await recalculateBalance(trx, mpesaEvent.business_id


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten MpesaBooks — devto

Thematisch verwandte Begriffe: MpesaBooks, devto · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94494 | jshERP through 3.6 contains a tenant isolation bypass vulnerability that…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick