Skip to main content

Back to the list

Reading mobile money confirmations in real time

The need

You sell online in a country where people pay by mobile money. The operator confirms every payment by SMS to the merchant's number, immediately. An API, when one exists at all, takes weeks of paperwork, a registered company, a minimum volume, and often a cut of each transaction.

Meanwhile the confirmation you need is already arriving, on a phone, as a text message.

How it works

The SIM that receives the operator's confirmations is one of the SIM cards paired with your gateway. From there:

  1. The message arrives on the phone and is recorded by the gateway, on your own machine. An operator writes from a short code or a name, not a phone number: add it to Senders to record in Settings > Reception, or it will be refused like any unknown service. The Activity log shows its exact spelling the first time it writes.
  2. A webhook calls your application as the SMS lands: subscribe it to message.received on the Webhooks page. The call is signed with HMAC-SHA256, so you can prove it came from your gateway, and it carries the identifiers of the message, never its text.
  3. Your code reads the message through the gateway's API, with a key limited to the Read scope: GET /api/v1/messages/{id} returns the sender and the text.
  4. Your code checks the sender, reads the amount and the reference, and marks the order paid.

Nothing is polled and nothing waits: the webhook leaves as the SMS lands.

What you should know before building on it

  • The message format belongs to the operator. They can change the wording without telling you, and a parser written on the old wording then stops matching. Log what you could not parse, and watch that log.
  • An SMS is not a proof of payment. It says what the operator sent to that number. For an amount that matters, confirm against the operator's own statement or API before delivering anything irreversible.
  • Keep the receiving SIM for that, on a phone that stays on charge. A confirmation that arrives while the phone is off is read when it comes back, not lost, but it is read late.
  • Check your operator's terms: what you may automate on a mobile money account is their rule, not ours.

What it takes

A paired phone, the SIM that receives the confirmations, the operator's sender recorded in Settings > Reception, a webhook on message.received, an API key with the Read scope, and one endpoint in your application. The gateway holds the messages; the decision to accept a payment stays in your code.

Reading mobile money confirmations in real time - Selfhostsms, self-hosted SMS gateway with a lifetime licence