Notes · Schools

Matching school fee payments to learners automatically

How a school can match M-Pesa fee payments to the right learner without a bursar copying codes: Paybill account numbers, C2B callbacks, partial payments and the daily check.

Published
Read
8 min

In many private schools, fee payments arrive on M-Pesa and someone in the bursar’s office spends hours matching them to learners. They read the SMS or the M-Pesa statement, find the admission number, look up the learner, type the payment into a spreadsheet or the school system, and write a receipt. It’s slow, and every step is a place for a mistake.

None of that needs a person. Here is how we set it up so that a parent’s payment lands on the right learner’s fees within seconds, and the bursar only looks at the exceptions.

Step 1: one Paybill, the admission number as the account

Parents pay the school’s Paybill and type the learner’s admission number as the account number. That single habit does most of the work. Print it on every fee statement and every report form, and put it in the SMS reminders.

Step 2: get every payment as it happens

Safaricom’s Daraja API lets the school register two URLs against its Paybill (the C2B API):

  • Validation: called before the payment completes, so the system can reject an account number that isn’t a learner (if Safaricom has enabled validation on the shortcode)
  • Confirmation: called after the payment completes, with the amount, the M-Pesa receipt, the payer’s name and the account number they typed

Validation is the real win: the parent who types ADM 2231 instead of 2231 gets told on their phone, before the money moves, rather than the bursar finding a mystery payment a week later.

Step 3: match, forgivingly

People type account numbers in creative ways. Our matcher tries, in order:

  1. The exact admission number
  2. The number cleaned up: spaces, dashes, “ADM”, “NO.” and leading zeros removed, letters uppercased
  3. The paying phone number, if it belongs to exactly one family with one learner
  4. Otherwise: the unmatched queue, with the payer’s name and phone shown so the bursar can assign it in one click

Step 4: apply it to the fees

  • Partial payments reduce the balance on the oldest invoice first, so arrears clear before the new term
  • Overpayments become a credit on the learner, carried to next term’s invoice, not a refund nobody asked for
  • One payment, several learners: let the bursar split it, and record the split against the one M-Pesa receipt
  • Bank deposits and cheques come in by importing the bank statement, through the same matcher

Step 5: tell the parent

The moment a payment is applied, the parent gets an SMS: learner, amount, receipt number, new balance. That one message removes most of the “did you get my payment?” calls the office takes in the first week of term.

Step 6: the daily check

Callbacks occasionally fail: the school’s server was down, the internet dropped. So once a day the system compares what it recorded against the M-Pesa statement for the Paybill and flags anything missing on either side. The bursar starts the morning with a short list, not a long hunt.

What the school gets

  • Balances that are right at any moment, for the bursar, the head and parents
  • Receipts without anyone writing them
  • Arrears reports by class and term in seconds
  • A bursar who spends the first week of term on exceptions, not data entry

This is the core of ConceptualAI Schools, our school management system for private schools. If you want the technical side of taking M-Pesa payments, start with our Daraja STK Push guide.