← All work
Case study · GOVTECH PAYMENTS

E-Voucher: paying nine parties correctly for every vaccinated animal

A World Bank-supported programme that collected and distributed over KES 10 million in vaccine subsidies.

ROLETeam lead & backend architect
CLIENTNational livestock agency & county programme
STATUSLive
STACKJava 17, Spring Boot 3, MariaDB, M-Pesa, partner bank API

The problem

Kenya subsidises Foot-and-Mouth Disease vaccines for cattle farmers. Paying out that subsidy across nine parties (field agents, vets, cooperatives, the vaccine supplier, county government, professional bodies and the platform) was manual and slow.

The platform had to issue each farmer a digital voucher, collect their co-payment by phone, calculate every stakeholder's share, pay them by bank transfer or M-Pesa, and stay in sync with the national farmer registry and the Mifugo360 field app.

Architecture

A deliberately simple monolith for a small team and a focused rollout. It collects via M-Pesa STK Push, allocates through a strategy-based engine, and disburses through a signed partner bank API.

What I built

  1. 01
    Two ways to onboard farmersA bulk import from the national registry (fetched sequentially to respect its rate limits, processed in parallel with each record in its own transaction, and matched with fallbacks for messy registry data), and real-time activation from the Mifugo360 field app that issues a voucher and texts the farmer their code.
  2. 02
    Collecting at the point of vaccinationThe field agent redeems a voucher, the farmer gets an M-Pesa STK Push for their co-payment, and the async callback is matched by its checkout request ID before the balance moves. Partial redemptions keep the voucher open.
  3. 03
    An allocation engine for nine stakeholdersOne strategy per stakeholder type, one orchestrator, and typed tables for fast reporting. Wards are processed in parallel; national totals are queued and written serially so there's no contention.
  4. 04
    Secure bank disbursementOAuth2 plus SHA-512 request signing on every bank call, AES-encrypted credentials per county account, M-Pesa B2C for individuals and internal transfers for institutions, and large payments split automatically to stay within bank limits.
  5. 05
    Built so no one is paid twiceThree separate idempotency guards make every step safe to re-run, bank callbacks are logged and processed by a retrying job, and allocation is triggered by an admin after review so auditors see the data before money moves.

Outcome

Over KES 10 million collected from farmers and distributed to vaccine providers, county and national bodies, and the field workers who vaccinated the animals.

I led the team end to end: technical architecture, sprint planning, and coordination with stakeholders and integration partners.

KES 10M+collected and distributed
9stakeholder types paid per vaccination
3idempotency guards between a vaccination and a payout

Skills demonstrated

Payment integrationsM-Pesa (STK Push, B2C)Bank APIs & request signingBatch & parallel processingIdempotencyEncryption at restTeam leadership