Mobile Payment Integration for IoT in Kenya: A Practical Guide

Connected devices in Kenya are increasingly paid for, not just monitored. A smart meter credits power when a customer pays, a vending machine dispenses after a payment is confirmed, and a solar controller unlocks for the days a customer has paid for. In each case, the device needs a reliable signal from the payment system, and the payment system needs to know which device it belongs to.

This guide explains how to integrate mobile money payments into IoT devices in Kenya. It covers the payment flow, the messages a device or its backend needs, how to match each payment to one device, and how to keep the device safe when messages repeat or arrive late. It’s written for IoT developers, device makers, and operators who connect hardware to M-Pesa.

Where the payment sits in an IoT system

An IoT payment system has four layers:

  1. The device measures, dispenses, credits or unlocks.
  2. The device platform runs the logic: prices, balances, stock, and rules for when to act.
  3. The payment layer requests the mobile money prompt and reports the result.
  4. The customer approves the payment on their own phone with their PIN.

The payment layer should not decide what a device does. It confirms that money has moved and tells the device platform, which then decides the action. Keeping those roles separate makes each part easier to test and easier to change later.

The integration flow

A typical sale follows this sequence:

  1. The customer requests a service from the device, its app, or a renewal reminder.
  2. The platform creates a payment request with the amount, the customer’s M-Pesa number, and a reference that identifies the device and this purchase.
  3. The customer approves the M-Pesa STK Push prompt on their phone.
  4. The payment provider confirms the result to the platform through a webhook, which is a message sent to an HTTPS address you control.
  5. The platform instructs the device to credit, dispense or unlock for the period paid.

The device should never act on the prompt alone. A prompt approved on a phone is not the same as money received. The action must follow the confirmed result.

Matching each payment to one device

The reference you send with each payment is the link between the money and the device. The payment provider returns it in the confirmation, and your platform uses it to find the right device.

Design the reference with three rules in mind:

  • Unique per attempt. Each purchase attempt gets its own reference, so two payments never share one.
  • Tied to the device. The reference should identify the meter, machine, cylinder, or controller, so the platform knows where to send the action.
  • Traceable. A support team should be able to look up any payment from its reference and see what it did.

If a confirmation arrives with a reference that doesn’t match any device, send it to a person for review. Don’t guess the device from the amount or the phone number.

Acting only on confirmed payments

The most important rule in IoT payments is that the device acts only on a confirmed state. Pending, processing, failed and cancelled payments should leave the device idle.

Check three things before the device acts:

  • State: the payment is complete.
  • Amount and currency: these match the price the device platform expected for that service.
  • Reference: it maps to a device and a purchase that is still open.

If any check fails, don’t act. Record the event, and let the customer know what happened.

Handling repeated and out-of-order messages

Payment messages can arrive more than once, and not always in the order they were sent. A payment can pass through several states, and an earlier state may arrive after a later one. The platform must be safe to repeat.

The practical approach is to key each action on the purchase reference together with the state. Store the states already handled, and act only on the first completed state for a given purchase. A repeat of the same message should do nothing.

This matters most where a double action has a real cost:

  • Smart meters: a double credit means lost revenue or a customer owed power they didn’t buy.
  • Vending and water dispensing: a double response means lost product or water.
  • Solar and gas: a double unlock extends access beyond what was paid for.

Respond to the webhook quickly with a success code, and do slower device work in the background. A payment provider counts any response other than a success code as a failed delivery, which can trigger retries.

Keeping the device and the payment record separate

A payment can succeed while the device fails to respond. The network may be down, the device may be offline, or the command may time out. These are two different failures, and they should be handled separately.

Keep two records for each purchase: the payment record, which shows what was paid, and the device record, which shows what the device was told to do and whether it confirmed. If the payment is complete but the device hasn’t responded, retry the device action. Don’t ask the customer to pay again.

Set a limit on retries, and flag any purchase that still hasn’t reached the device after that. A person should check those cases, because a stuck device with a paid customer is a support problem that grows quickly.

Connectivity and offline devices

Many IoT devices in Kenya sit where the network is weak or intermittent. A meter in a rural area, a solar controller on a rooftop, or a vending machine in a busy estate may not always be online when the payment completes.

Plan for that in three ways:

  • Queue the device action so it runs when the device reconnects, with a clear expiry.
  • Show the customer the status so they know a payment was received and the service is pending.
  • Confirm the device’s state when it comes back online, so the platform knows the action took effect.

A customer who pays for a day of solar power should not lose that day because the controller was offline for an hour. A queued action with a clear rule solves that. Our guide to M-Pesa payment collections for PAYG solar businesses covers the instalment side of this in more detail.

Testing before launch

IoT payment systems fail at the edges. Test these cases with real devices before opening to customers:

  • A confirmed payment that reaches the device.
  • A cancelled prompt, and a phone that can’t be reached.
  • A repeated confirmation for the same purchase.
  • A confirmation with an unknown reference.
  • A payment that completes while the device is offline.
  • A wrong amount, and a currency mismatch.

Time the full flow from payment to device response on a real phone and a real device. Record the results, and use them to set customer expectations.

Reconciliation for connected businesses

Each day, compare the device records with the payment records. Every confirmed payment should have a matching device action, and every device action should have a matching confirmed payment. Gaps in either direction need investigation.

Track a few figures each week:

  • Success rate: the share of payments that reached the device and produced the expected action.
  • Stuck purchases: payments confirmed but not acted on, after retries.
  • Failure reasons: cancelled prompts, unreachable phones, and device timeouts, counted separately.
  • Revenue by device and by network: the basis for planning and for spotting faults.

A device that repeatedly fails to respond is often a connectivity or hardware issue, not a payment issue. The records will show where to look. If your devices serve customers on more than one network, see M2M payments across M-Pesa, Airtel Money and MTN.

Security basics

Payment integration adds security obligations to any connected device. Keep these practices in place:

  • Keep API secret keys on your server, never on the device or in code that customers can read.
  • Verify the challenge value on every incoming webhook, and reject any request that doesn’t match.
  • Restrict who can send commands to devices, and log every manual override.
  • Protect the device’s control channel, so a payment message can’t be spoofed into a device action.

Treat the payment platform and the device platform as separate systems with separate access controls. A breach in one should not give control of the other. For more on protecting payment flows, read payment security basics every merchant should know.

Where IntaSend fits

IntaSend provides the mobile money collection layer for IoT and connected businesses in Kenya, Uganda, Tanzania, Rwanda and the DRC, using one integration where IntaSend is live. The API creates the M-Pesa prompt, and the webhook confirms the outcome to your platform. The device logic, the decision to credit or dispense, the device hardware, and the customer experience stay with your business.

To see which payment rails are live in each market, check the IntaSend coverage page. For the wider IoT and ISP setup, see the ISP and IoT solutions page. If you’re building an IoT product in Kenya and want to talk through the integration, speak to the IntaSend team. You can also reach us on WhatsApp at +254 711 082 947, by email at [email protected], or by phone at +254 114 114 644.

Banking services provided by licensed partners.

What Our Clients Say About Us

Don’t just take our word for it—hear what our satisfied customers have to say! IntaSend has helped businesses and individuals across Kenya and beyond streamline their payments.

  • The experience has been seamless, efficient, and hassle-free. One thing that makes Intasend stand out is the platform's ability to collect payments from anywhere in the world.

    Felistas Njihia - IntaSend customer
    Felistas NjihiaFelin Solutions
    ★★★★★
  • Our experience with IntaSend has been remarkable. The integration process was quite smooth with proper API documentation. Intasend won us over on the ease of B2B transactions which is our mainstay and remains our preferred payment solutions

    Kelvin Muriuki, C.E.O - IntaSend customer
    Kelvin Muriuki, C.E.Otaka.earth
    ★★★★★
  • Their platform is incredibly user-friendly, allowing our customers to easily pay for their weekly meals. The fast and secure payment process also provides peace of mind for both our customers and us.

    John Faderr - IntaSend customer
    John FaderrFoodtable by Roros Co.
    ★★★★★
  • @intaSendHQ I am currently blown away by your product. The documentation is so developer friendly as opposed to one pan-African payment gateway, market leader. Good job!

    @Matinde on Twitter - IntaSend customer
    @Matinde on Twitter
    ★★★★★
  • Their customer service is top-notch. The team at IntaSend Payments is friendly and super responsive, always there to lend a hand whenever you need it.

    Wearify on Shopify - IntaSend customer
    Wearify on ShopifyWearify Kenya
    ★★★★★
  • I would like to commend your service and especially point out your outstanding quick turn-around in processing payment and your after-office hour’s support. We are glad that you can be reached 24/7 for queries and round-the-clock support.

    Peter Nyotta - IntaSend customer
    Peter NyottaTwende Worldwide Tours and Travel Ltd
    ★★★★★
  • This payment processor has allowed me to continue serving my local as well as international customers. They also offer reasonable fees and their payouts are timely. Even without a website, IntaSend payment links works just fine.

    Shadrack Masinde - IntaSend customer
    Shadrack MasindeGofan Safaris Limited
    ★★★★★
  • I have been using Intasend for a while now both on my website as a payment gateway and my business as a payment solution and all I can say is, IntaSend is the best solution to sort out all business payment related difficulties.

    Daniel Nyongesa - IntaSend customer
    Daniel NyongesaA+ Academic Consultants
    ★★★★★
  • IntaSend is one of the best online money transfers with mobile and card payment options and helps in collecting emails for marketing.

    Moses Thoithi - IntaSend customer
    Moses ThoithiWizAdventures Safaris
    ★★★★★

Frequently Asked Questions

How does mobile payment integration for IoT work in Kenya?

The device platform creates an M-Pesa payment request with a reference tied to the device, the customer approves the prompt on their phone, a webhook confirms the result, and the platform then tells the device to credit, dispense or unlock.

Should an IoT device act when the customer approves the M-Pesa prompt?

No. A prompt approved on a phone is not money received. The device should act only on a confirmed payment state, with the amount, currency and reference checked against the open purchase.

How do you handle duplicate or out-of-order payment webhooks?

Key each action on the purchase reference and the payment state, store the states already handled, and act only on the first completed state for a purchase. A repeat of the same message should do nothing.

What happens if the device is offline when the payment completes?

Queue the device action with a clear expiry, show the customer that the payment was received and the service is pending, and confirm the device's state when it reconnects. Don't ask the customer to pay again.

Where should API keys be stored in an IoT payment system?

On your server only, never on the device or in code customers can read. Verify the challenge on every webhook and keep the payment platform and device platform under separate access controls.