Payments

Safaricom APIs Integration & Consulting

Guidance for Safaricom Daraja API integration in Kenya, including Lipa Na M-Pesa STK Push, C2B, B2C, Bill Manager, USSD, callbacks, and reconciliation.

Safaricom's Daraja API Gateway provides the connection point for adding M-Pesa services to applications, ERPs, billing systems, and mobile checkouts. Statum helps teams understand the integration boundary and fit the callback, authentication, and transaction flow into their own systems.

The work is specific to the system being connected. It may include a custom bridge, callback handling, security review, USSD session mapping, reconciliation, or support while the integration is tested.

Safaricom Developer APIs Directory

The directory below summarises the Safaricom services covered by this page. Confirm availability, onboarding requirements, and payload details in the current Safaricom developer portal before implementation:

1. M-Pesa Express (STK Push)

Starts a payment prompt on the customer's phone. The customer confirms the request with their M-Pesa PIN.

2. Customer-to-Business (C2B)

Receives customer payments through a Paybill or Till and sends validation and confirmation callbacks to the configured server.

3. Business-to-Customer (B2C)

Sends money from a business wallet to individual recipients. Common uses include payouts, refunds, and disbursements.

4. Business-to-Business (B2B)

Moves funds between business wallets for use cases such as supplier payments or corporate settlement.

5. Dynamic QR Code

Creates a payment QR code that a customer can scan from the M-Pesa application.

6. Tax Remittance

Enables corporations to programmatically remit taxes (such as KRA payments) directly from their M-Pesa business wallets to government treasury systems.

7. Transaction Status

Checks the state of a specific M-Pesa transaction so your application can reconcile the result.

8. Account Balance

Reads the balance information exposed for a corporate Paybill or Till, including the account categories returned by the service.

9. Reversal API

Submits a request to reverse an incorrect payment, subject to the service's rules and the transaction state.

10. Bill Manager API

Supports invoice dispatch, billing setup, e-receipts, and payment reconciliation for connected billing systems.

11. Safaricom Voice & Native SMS APIs

Provides communication capabilities for outbound calls, SMS alerts, and authentication messages where enabled for the account.

12. USSD Session Integration

Connects interactive menus such as *xxx# to an application backend for account, service, and payment flows.

13. Business to Pochi (B2P)

Supports the documented business-to-Pochi disbursement flow for sending funds from a business wallet to a customer's merchant wallet.

14. SIM Swap Query API

Checks the SIM-swap information exposed to an authorised partner before a sensitive transaction.

15. IMSI Security API

Provides the subscriber and SIM information made available to authorised partners for security checks.

16. Lipa na Bonga

Supports the documented Lipa na Bonga payment flow for customers using eligible loyalty points.

17. B2B Hakikisha (Query Org Info)

Checks the shortcode and transfer information available to an authorised partner before sending money.

18. Mobile Number Validation

Validates mobile subscriber information available through the service before a transaction is submitted.

19. B2C Account Top Up

Moves funds to the documented B2C utility balance from a merchant or treasury system.

20. M-Pesa Ratiba (Standing Orders)

Supports recurring payment instructions, such as standing orders for subscriptions, bills, or loans, where the service is available.

21. IoT SIM Management

Provides programmatic management for the IoT connectivity operations exposed by the portal.

Official Developer SDK

Safaricom Daraja PHP & Laravel SDK

Use the open-source SDK as a starting point for Safaricom integrations. Check its repository for the APIs, framework support, and authentication behaviour currently implemented.

$ composer require statum/safaricom-daraja-sdk
View Repository on GitHub

Consultancy Focus Areas

Safaricom integrations need careful handling of callbacks, credentials, timeouts, and reconciliation. Areas we commonly review include:

  • Callback idempotency: Store a callback result before acknowledging it so a repeated notification does not create a second business event.
  • Callback verification: Follow the verification mechanisms documented by Safaricom rather than relying on an unverified source address alone.
  • Credential management: Keep consumer keys, secrets, and certificates out of the repository and restrict access to the services that need them.
  • USSD flow design: Keep the interactive path small and move longer work out of the time-limited session.
  • Reconciliation: Compare provider transaction records with your own ledger and make discrepancies visible for review.

Engage Statum for Safaricom Portal Integrations

If you are connecting a system to Daraja, adding corporate billing, or building a USSD flow, contact Statum with the service and transaction flow you are planning.