Skip to main content

Safaricom M-Pesa

Connect your Safaricom M-Pesa Paybill or Buy Goods Till to automate hotspot purchases and recurring PPPoE bill collections.

Integrating Safaricom M-Pesa

Safaricom M-Pesa is the primary mobile money payment channel across Kenya. Nukta integrates natively with Safaricom's Daraja API to support both:

  • M-Pesa Express (STK Push): Dispatches an automated PIN authorization prompt directly to customer mobile handsets when they initiate checkout on captive portals or invoices.
  • Customer to Business (C2B): Listens for incoming payments made directly to your Paybill or Buy Goods Till number via the customer's phone SIM menu, automatically matching the transaction to their account.

Step-by-step M-Pesa configuration

Step 1: Create a Daraja developer app

  1. Log in to the Safaricom Daraja Developer Portal.
  2. Navigate to My Apps and click Create App.
  3. Name your app Nukta and check the Lipa na M-Pesa Online (STK Push) and Customer-to-Business (C2B) checkboxes.
  4. Click Create App.
  5. Copy your Consumer Key and Consumer Secret.

Step 2: Retrieve your production passkey

  • If using a standard Safaricom Daraja production account, your Passkey is generated in your Safaricom merchant onboarding portal or issued securely by Safaricom API support upon production go-live.
  • The passkey is a 64-character base64 string required to authenticate STK push requests.

Step 3: Enter credentials in your Nukta dashboard

  1. In your Nukta dashboard, navigate to Settings → Payments.
  2. Locate the Safaricom M-Pesa card and click Configure.
  3. Fill in your merchant parameters:
    • Shortcode Type: Select Paybill or Buy Goods / Till.
    • Business Shortcode: Enter your Paybill or Till number.
    • Consumer Key: Paste from Daraja.
    • Consumer Secret: Paste from Daraja.
    • Passkey: Paste your Lipa na M-Pesa Online passkey.
  4. Review the pre-generated Confirmation URL (https://{subdomain}.nukta.one/api/payments/saf/callback) and Validation URL (https://{subdomain}.nukta.one/api/payments/saf/validation) displayed on the screen.
  5. Click Run Readiness Test to confirm credentials.
  6. Toggle the status to Live and click Save Changes.

Automated transaction matching

When an M-Pesa payment arrives, Nukta's intelligent payment matcher processes the payment:

  1. Exact Account Match: For Paybill transactions, Nukta matches the entered Account Number against your customer usernames (e.g., S102).
  2. Mobile Phone Match: If the account number does not match an existing customer (or if payment was sent to a Buy Goods Till without an account field), Nukta searches your directory for a customer registered with that mobile phone number.
  3. Instant Activation: The matching customer's account validity is extended, the transaction is logged in Finance → Payments, and speed queues are applied on the router in under three seconds.
  4. SMS Receipt Confirmation: If automated SMS notifications are enabled under Settings → Notifications, the customer immediately receives an SMS confirming payment and their updated expiration date.