Skip to content

M-Pesa (Safaricom, Kenya)

A module for shops in Kenya that take payment through M-Pesa — Safaricom mobile payments. The customer pays from their phone to the shop's number (Till — "Buy Goods", or Paybill), and Safaricom notifies ERPJS of every payment. The payment appears in the register by itself — with the transaction code from the customer's SMS, the amount and the payer's name.

The cashier does not type an M-Pesa amount: they choose the payment from the register. A receipt whose M-Pesa amount does not match the chosen payments is not posted. This way every M-Pesa shilling in receipts is matched against money that actually arrived.

The route: from the customer's payment to a posted receipt

M-Pesa account (Till / Paybill number, till payment method, Daraja keys)
        ↓
Notification address registered with Safaricom
        ↓
Customer pays → Safaricom notification → row in "M-Pesa Payments"
        ↓
Till: third payment method button → choose the payment → receipt posted
        ↓
Transaction code and amount on the receipt; receipt number on the payment
  1. M-Pesa Accounts — the shop's number at Safaricom, the till payment method for payments to it, the Daraja keys and the address Safaricom notifies about payments.
  2. M-Pesa Payments — every payment Safaricom reported (or that was entered by hand) and the receipt or Payments document it was taken into.
  3. M-Pesa instruction — connecting step by step and working at the till.

What matters

One payment — one receipt or one Payments document. A payment taken by one receipt cannot be taken by another receipt (or another till). An unposted receipt deleted — its payments are free again. Money that came in advance is taken into a Payments document as a customer prepayment.

A payment is taken whole. If it is more than what is left to pay on the receipt, the till refuses: M-Pesa gives no change.

The receipt is checked when it is posted. The amount of each M-Pesa payment method in the receipt must equal the payments taken by the receipt to the numbers of that method — whether the till closes the receipt or the invoice is posted from its window.

A closed account switches M-Pesa off for its payment method. The till takes the amount from the keyboard again, with no check. The account is closed by whoever has rights to M-Pesa accounts, not by the cashier.

The module exists only in the Kenya edition of ERPJS. The Ukrainian edition has none of its registers, buttons or the "M-Pesa transaction code" column in the Payments document. The edition is set by the ERPJS server's configuration, not by role rights. In the Kenya edition, without an open M-Pesa account the till takes the third-method amount from the keyboard, as before, and Safaricom notifications are not accepted.

Where to start

  1. A payment method for M-Pesa and the till's third payment method.
  2. M-Pesa account — number, payment method, Daraja keys.
  3. The notification address — at Safaricom (with the button in the account window or through Safaricom).
  4. A test payment and a test receipt at the till.

Common tasks

Need to Go to
connect a Till or Paybill number M-Pesa Accounts
find a payment by the SMS code M-Pesa Payments
see which receipt took a payment M-Pesa Payments, column "Invoice"
the notification did not arrive, the money did M-Pesa Payments → new payment by hand
record a customer prepayment from M-Pesa M-Pesa Payments → "Create customer payment (prepayment)"
take M-Pesa at the till M-Pesa instruction, the till section