Payment Integration

How to Accept M-Pesa Payments on Your Website (2026 Guide)

A comprehensive guide to integrating M-Pesa into your website or e-commerce store. We cover the Daraja API, payment gateways like PesaPal and Flutterwave, costs, requirements, and best practices for Kenyan businesses.

M-Pesa is not just a payment method in Kenya — it's the payment method. With 96% mobile money penetration and over 30 million active M-Pesa users, any Kenyan e-commerce business that doesn't accept M-Pesa payments is leaving money on the table. Literally.

But integrating M-Pesa into your website can be confusing. Should you use Safaricom's Daraja API directly? Go through a payment gateway like PesaPal? What about Flutterwave? How much does it cost? What are the technical requirements?

This guide answers all of these questions and helps you choose the right M-Pesa integration approach for your business.

Why M-Pesa Is Essential for Kenyan E-Commerce

If you're selling anything online to Kenyan customers, M-Pesa integration is not optional — it's a necessity. Here's why:

  • 96% mobile money penetration: Kenya leads the world in mobile money adoption. Most Kenyans use M-Pesa as their primary payment method, ahead of bank transfers and credit cards.
  • Low credit card penetration: Unlike Western markets, only a small percentage of Kenyans have credit or debit cards. If your website only accepts card payments, you're excluding the majority of potential customers.
  • Trust and familiarity: Kenyans trust M-Pesa. They use it daily for everything from buying groceries to paying rent. An M-Pesa payment option feels safe and familiar.
  • Instant confirmation: M-Pesa transactions are confirmed within seconds, allowing you to process and fulfill orders immediately.
  • Lower transaction costs: M-Pesa transaction fees are typically lower than credit card processing fees, keeping your costs down.

3 Ways to Integrate M-Pesa Into Your Website

There are three main approaches to accepting M-Pesa payments on your website. Each has different levels of complexity, cost, and features.

Option 1: Safaricom Daraja API (Direct Integration)

The Daraja API is Safaricom's official API for M-Pesa integration. It gives you direct access to M-Pesa's payment infrastructure with maximum control and flexibility.

Key Features

  • STK Push (Lipa Na M-Pesa Online): The most popular feature. Your website sends a payment prompt directly to the customer's phone. They simply enter their M-Pesa PIN to complete payment. No need to manually enter Paybill numbers or amounts.
  • C2B (Customer to Business): For traditional Paybill and Till number payments where the customer initiates the transaction from their phone.
  • B2C (Business to Customer): Send money to customers — useful for refunds, cashbacks, or payouts.
  • Transaction Status Query: Check the status of any transaction programmatically.
  • Account Balance Query: Check your M-Pesa account balance via API.

Pros

  • Full control over the payment experience
  • No intermediary fees — only standard M-Pesa transaction charges
  • Direct relationship with Safaricom
  • Real-time callbacks for instant payment confirmation
  • Customizable to your exact business needs

Cons

  • Requires significant development effort
  • You handle security, error handling, and reconciliation yourself
  • Safaricom's API documentation can be challenging
  • Only supports M-Pesa (no card payments, no bank transfers)
  • Going live requires Safaricom approval process

Best for: Businesses with development teams that need maximum control and want to avoid gateway fees. For a deeper technical walkthrough, see our M-Pesa integration technical guide.

Option 2: PesaPal

PesaPal is Kenya's most established payment gateway. It acts as a middleman between your website and M-Pesa (plus other payment methods), simplifying integration significantly.

Key Features

  • Accepts M-Pesa, Airtel Money, Visa, Mastercard, and bank transfers
  • Pre-built checkout pages and iFrames
  • Plugins for WordPress, WooCommerce, Shopify, and other platforms
  • Merchant dashboard for tracking payments and generating reports
  • Recurring payment support
  • Multi-currency support for businesses selling internationally

Pros

  • Much easier to integrate than direct Daraja API
  • Multiple payment methods in one integration
  • PCI DSS compliant — PesaPal handles card security
  • Reliable and well-established in Kenya
  • Good customer support

Cons

  • Transaction fees on top of M-Pesa charges (typically 1.5–3.5%)
  • Settlement takes 1–3 business days (not instant)
  • Less control over the payment experience
  • Checkout page redirect can increase cart abandonment

Best for: Businesses that want a quick, reliable integration with multiple payment methods and don't mind paying slightly higher fees for convenience.

Option 3: Flutterwave

Flutterwave is a pan-African payment gateway that supports M-Pesa alongside dozens of other payment methods across the continent.

Key Features

  • M-Pesa, Airtel Money, cards, bank transfers, and mobile money across 30+ African countries
  • Beautiful, modern checkout experience
  • Developer-friendly APIs and SDKs
  • Subaccount and split payment features (useful for marketplaces)
  • Payment links for businesses without websites
  • Subscription and recurring billing

Pros

  • Best option if you sell across multiple African countries
  • Modern, well-documented API
  • Supports more payment methods than PesaPal
  • Split payments for marketplace businesses
  • Excellent developer experience

Cons

  • Transaction fees (typically 1.4% for local transactions)
  • Settlement times vary
  • Customer support can be slow during peak periods
  • Less local presence than PesaPal in Kenya

Best for: Tech-savvy businesses, pan-African companies, and marketplace platforms that need split payments.

Comparison: Daraja API vs PesaPal vs Flutterwave

Here's a quick comparison to help you decide:

  • Setup complexity: Daraja: High | PesaPal: Low | Flutterwave: Medium
  • Setup time: Daraja: 2–4 weeks | PesaPal: 1–3 days | Flutterwave: 1–3 days
  • Transaction fees: Daraja: Standard M-Pesa only | PesaPal: 1.5–3.5% | Flutterwave: ~1.4%
  • Payment methods: Daraja: M-Pesa only | PesaPal: M-Pesa + cards + banks | Flutterwave: M-Pesa + cards + banks + 30+ countries
  • Settlement: Daraja: Instant | PesaPal: 1–3 days | Flutterwave: 1–2 days
  • Control: Daraja: Full | PesaPal: Limited | Flutterwave: Moderate
  • Best for: Daraja: High-volume, M-Pesa only | PesaPal: Most Kenyan businesses | Flutterwave: Pan-African businesses

Requirements for M-Pesa Integration

Regardless of which approach you choose, you'll need these basics in place:

Business Requirements

  • Safaricom Business Account: You need a registered Safaricom Paybill or Till number. This requires a valid Kenyan business registration certificate, KRA PIN, and company bank account.
  • Daraja API credentials: Register at developer.safaricom.co.ke to get your API keys for testing and production. Even if you use a gateway, understanding these credentials is helpful.
  • Business registration: Payment providers require proof of legitimate business registration in Kenya.

Technical Requirements

  • SSL certificate: Your website must have HTTPS enabled. M-Pesa callbacks and payment gateway integrations require secure connections. Any professional web development includes SSL as standard.
  • Server with callback URL: M-Pesa's Daraja API sends payment confirmations to a callback URL on your server. You need a reliable server that can receive and process these callbacks.
  • Database: To store transaction records, order status, and reconciliation data.
  • Testing environment: Safaricom provides a sandbox for testing before going live. Always test thoroughly before accepting real payments.

How M-Pesa STK Push Works on Your Website

The STK Push flow is the most popular M-Pesa integration for websites because it provides the smoothest customer experience. Here's how it works:

  1. Customer clicks "Pay with M-Pesa" on your website checkout page and enters their phone number.
  2. Your server sends an STK Push request to Safaricom's Daraja API with the customer's phone number, amount, and transaction description.
  3. Safaricom sends a payment prompt (SIM Toolkit Push) to the customer's phone. The prompt shows the amount and your business name.
  4. Customer enters their M-Pesa PIN on their phone to authorize the payment.
  5. Safaricom processes the payment and deducts the amount from the customer's M-Pesa wallet.
  6. Safaricom sends a callback to your server confirming the payment was successful (or failed).
  7. Your website updates the order status and shows a confirmation message to the customer.

The entire process takes about 10–15 seconds from the customer's perspective. They never leave your website, and they don't need to remember any Paybill numbers or account numbers.

Transaction Fees Breakdown

Understanding the fee structure helps you price your products correctly and choose the right integration method:

Safaricom M-Pesa Fees (Direct Daraja)

  • Transactions KES 1–100: No charge to customer, KES 0 to merchant
  • Transactions KES 101–500: Minimal fees to customer, merchant receives full amount
  • Transactions KES 501–1,000: Customer pays KES 7–15, merchant receives full amount
  • Higher amounts follow Safaricom's published tariff schedule
  • Paybill withdrawal fees apply when transferring from your Paybill to bank account

Note: With direct Daraja integration, the customer pays the M-Pesa transaction fee, not the merchant. This makes it the most cost-effective option for businesses.

Payment Gateway Fees

  • PesaPal: 1.5–3.5% per transaction depending on payment method and volume
  • Flutterwave: 1.4% for local transactions, capped at certain amounts

These gateway fees are charged to the merchant (you) and come on top of any standard M-Pesa fees. For high-volume businesses processing millions of shillings monthly, these percentages add up significantly.

Security Considerations

Handling payments requires strict attention to security. Here are the essential security practices for M-Pesa integration:

  • Always use HTTPS: Never send payment data over unencrypted connections. Your entire website should use SSL/TLS.
  • Validate callbacks: Verify that payment callbacks actually come from Safaricom or your payment gateway. Check the source IP, validate the signature, and cross-reference transaction IDs.
  • Never trust the client: Always verify payment amounts and statuses on your server. A malicious user could modify client-side code to show fake payment confirmations.
  • Store API credentials securely: Never hardcode your Daraja API keys or payment gateway credentials in your frontend code. Use environment variables on your server.
  • Implement idempotency: Ensure that processing the same callback twice doesn't result in duplicate order fulfillment.
  • Log everything: Keep detailed logs of all payment transactions, callbacks, and errors for reconciliation and dispute resolution.
  • Regular reconciliation: Compare your transaction records with M-Pesa statements regularly to catch any discrepancies.

Common M-Pesa Integration Challenges

Based on our experience building e-commerce platforms for Kenyan businesses, here are the most common challenges and how to handle them:

  • Timeout issues: STK Push prompts expire after about 60 seconds. If the customer doesn't respond in time, you need to handle the timeout gracefully and allow them to retry.
  • Network delays: Sometimes M-Pesa callbacks are delayed. Implement a polling mechanism or transaction status query to check payment status if the callback doesn't arrive within expected time.
  • Going live process: Safaricom's production approval process can take 1–2 weeks. Start this early and have your sandbox integration fully tested before applying.
  • Phone number validation: Ensure you validate and format phone numbers correctly (254XXXXXXXXX format). Invalid phone numbers are the most common cause of STK Push failures.
  • Insufficient balance: Handle the case where a customer doesn't have enough M-Pesa balance gracefully, with a clear error message and option to try again.

Which Integration Should You Choose?

Here's our recommendation based on business type:

  • Small e-commerce store: PesaPal — quick to set up, multiple payment methods, minimal development needed.
  • Growing online business: Flutterwave — modern API, competitive fees, room to scale across Africa.
  • High-volume business: Direct Daraja API — lowest fees, full control, worth the development investment.
  • Marketplace platform: Flutterwave — split payment features make it ideal for multi-vendor platforms.
  • WordPress/WooCommerce site: PesaPal — ready-made plugins, easiest integration, no custom development needed.

We Handle M-Pesa Integration for You

M-Pesa integration is technical work that requires experienced developers who understand both the payment APIs and the Kenyan business context. At KenZobe Technologies, we've integrated M-Pesa into dozens of websites and applications for Kenyan businesses.

Whether you need a new e-commerce website with M-Pesa built in or want to add M-Pesa payments to your existing website, our team handles the entire process — from Safaricom registration to API integration to testing and going live. You focus on selling; we handle the technical complexity.

Contact us today for a free consultation. We'll assess your current setup, recommend the best integration approach, and give you a clear timeline and cost estimate. Most M-Pesa integrations are completed within 1–2 weeks.