Skip to content

ERPNext ↔ M-Pesa Integration (C2B, B2C, B2B)

Payments rails for ERPNext: deterministic matching, safe retries, and evidence you can reconcile. Built for callbacks, reversals, and finance-grade audits.

Core outcome
Provable reconciliation
Designed for
Safe retries
Prevents
Duplicate posting
Problem

Why payments integrations break ERP projects

Payments don’t fail cleanly. They duplicate, arrive late, reverse, and trigger retries. Without deterministic rules and evidence, finance teams end up reconciling with guesswork.

Failure mode
Duplicate postings from retries

Callbacks and job retries are normal. If the integration is not idempotent, the same payment becomes multiple ERP entries.

  • Duplicate callbacks happen; a payment can be announced more than once.
  • Timeouts cause replays: money moved, but ERP didn’t post (or posted twice).
  • Duplicate entries create customer disputes and finance cleanup work.
Failure mode
Reconciliation without evidence

If you can’t prove what happened, you can’t reconcile. Screenshots are not evidence, and ‘it should be paid’ is not a ledger.

  • Weak matching rules lead to wrong invoices being closed.
  • No event trail makes dispute resolution slow and manual.
  • Failures hide in background jobs until customers complain.
Operating model

Deterministic matching + idempotent retries + evidence trails

This integration is engineered for accounting reality: every event is traceable, replay-safe, and explainable under audit.

Guarantee
Idempotency

Every transaction is processed with deterministic keys and “already applied” checks, so retries do not create duplicate postings.

Guarantee
Deterministic matching

Payments are matched using explicit rules (references, invoices, customers) - not heuristic guesswork.

Guarantee
Evidence trails

Each event stores payload + ERP outcomes + status so you can prove what happened and why.

Scope

What’s included (and how it stays correct)

We implement payment rails that finance teams can operate - not just callbacks that ‘post something’.

C2B
Customer payments into ERPNext

Customer payments are recorded with deterministic matching and status tracking so invoices, receipts, and ledgers remain correct.

  • Deterministic invoice matching (avoid wrong invoice closures).
  • Partial payments and overpayments handled explicitly.
  • Status tracking (received, posted, reversed, failed) with reasons.
B2C
Disbursements and refunds

Refunds and disbursements are processed idempotently with evidence and controlled workflows to avoid double sending.

  • Idempotent disbursement requests (no double payouts).
  • Posting rules aligned with your accounting structure.
  • Evidence logs per transaction for disputes and audits.
B2B
Business/vendor transfers with controls

Vendor and business payments are executed under approvals and traceability so finance retains operational control.

  • Approval workflows (who approved what, when).
  • Deterministic posting to the right accounts and documents.
  • Evidence and audit trails for vendor disputes.
Operations
Reconciliation + failure visibility

A production payments rail needs visibility: what failed, why it failed, what was retried, and what is safe to retry.

  • Automated reconciliation views (prove received vs posted).
  • Failure categories with actionable context (not raw logs).
  • Retry controls designed to be replay-safe.
Hard production realities

The payment realities we design for

These are common in Kenya. Treating them as edge cases is how payment systems become unreliable.

Callbacks
Duplicate callbacks

Same transaction can be sent multiple times. Duplicates are treated as normal and harmless.

Network
Timeouts & partial failures

Payment succeeded but ERP didn’t post. We can safely replay from evidence without duplicating.

Disputes
Reversals & disputes

Reversals require traceable linkage to original events and clear accounting outcomes.

Rollout

How we implement without disrupting finance operations

Payments touch trust. We roll out in phases with verification and guardrails.

Phase 1
Foundation + matching rules

We define deterministic matching, posting rules, evidence capture, and safe retry semantics.

  • Confirm document mapping (Invoice, Payment Entry, Journal rules).
  • Define reference strategy (invoice refs, account refs, customer refs).
  • Set up evidence logging + reconciliation views.
Phase 2
Live flows + reconciliation proof

Enable live C2B/B2C/B2B flows with monitoring, safe retries, and reconciliation proof.

  • Enable C2B with posting verification and exception handling.
  • Enable B2C/B2B with approvals and double-send prevention.
  • Train finance on evidence trails + dispute resolution workflow.
FAQ

Frequently asked questions

Straight answers to the questions we hear most about this integration.

Can I integrate M-Pesa with ERPNext?

Yes. We connect M-Pesa to ERPNext so customer payments (C2B), disbursements and refunds (B2C), and vendor transfers (B2B) post directly to the right documents - invoices, payment entries and journals - with deterministic matching and a full evidence trail, rather than being keyed in by hand.

How does the integration avoid duplicate postings?

Through idempotency. M-Pesa callbacks and job retries can announce the same payment more than once, so every transaction is processed with a deterministic key and an 'already applied' check. A payment that arrives twice is recorded once, which is what keeps the ledger correct under real-world retries and timeouts.

What happens when a payment succeeds but ERP does not post it?

That gap is the most common failure in payment integrations, and it is designed for explicitly. Every event stores its raw payload and outcome, so a payment that moved on M-Pesa but did not post in ERPNext is visible in the reconciliation view and can be safely replayed from the stored evidence - without any risk of double-posting.

Do I need a paybill or till number to integrate M-Pesa?

For direct Daraja integration, yes - you need a registered paybill or buy-goods till plus API credentials from Safaricom. A personal M-Pesa line cannot be integrated through Daraja. If you cannot get Daraja on your line, we can still reconcile automatically by capturing the confirmation SMS, so you are not stuck with manual matching.

How are payments matched to the correct invoice?

Through explicit, deterministic rules using the account reference - an invoice number, account number or customer reference - not amount-based guesswork, because two customers can owe the same figure. Part of the implementation is designing a clean reference scheme so payments auto-match instead of needing a person to sort them.

Can you reconcile M-Pesa payments without Daraja API access?

Yes. Where Daraja is not available - an unregistered till or a personal line - the M-Pesa confirmation SMS still arrives for every payment. A gateway forwards each message to your system, which parses the amount, code and reference and matches it to an invoice, giving you automatic reconciliation as a bridge until (or instead of) full Daraja integration.

Next step

Want payments you can reconcile, audit, and trust?

We’ll review your payment flow (collections, refunds, vendor payouts), your ERPNext accounting configuration, and your reconciliation requirements - then propose an implementation plan that is provable under audit and safe under retries.