Integrating M-Pesa into WordPress enables Kenyan businesses to accept mobile payments seamlessly, boosting e-commerce sales. This guide provides a step-by-step process using WooCommerce and popular plugins, tailored for users in Nairobi like you working in ICT services.

Prerequisites

Ensure your WordPress site runs WooCommerce, as M-Pesa gateways rely on it for checkout functionality. You'll need a Safaricom Daraja API account for credentials like Consumer Key, Consumer Secret, and Passkey—register at developer.safaricom.co.ke. Basic hosting and admin access are required.

Plugin Name Key Features Cost Best For Download Source 
IntaSend WooCommerce M-Pesa, cards; easy shortcodes Free/Paid Standard sites, quick setup intasend.com
Woo M-Pesa Gateway STK Push, till/paybill support Free WooCommerce stores WordPress.org
MickWeb M-Pesa Daraja API, video tutorials Paid Beginners mickwebagency.com
WenPay Full store build, live demos Paid New e-commerce sites wencreatives.com

Step-by-Step Integration Process

1. Install WooCommerce

Log into your WordPress dashboard, go to Plugins > Add New, search "WooCommerce," install, and activate. Run the setup wizard to configure store pages, currency (KES), and basic settings like shipping.​​

2. Choose and Download Plugin

Select a plugin from the table above. For IntaSend: Download the ZIP from their site. For free options like Woo M-Pesa, get it from WordPress.org. Save the file locally—avoid uploading untrusted sources to prevent security risks.

3. Upload and Activate Plugin

Navigate to Plugins > Add New > Upload Plugin. Select your ZIP file, click Install Now, then Activate. Confirm it appears in your plugins list. Some plugins auto-add an M-Pesa tab under WooCommerce > Settings > Payments.

4. Obtain Safaricom Daraja Credentials

Go to developer.safaricom.co.ke, log in or create an account. Generate Consumer Key/Secret for your app (sandbox for testing). For production, submit business details for approval; receive Passkey via email. Note your Paybill/Till number.

5. Configure Plugin Settings

In WooCommerce > Settings > Payments > M-Pesa (or plugin-specific tab), enter:

  • Consumer Key

  • Consumer Secret

  • Passkey

  • Paybill/Till Number

  • Callback/Validation URLs (plugin generates these)
    Enable the gateway, save changes, and set title/description for customers (e.g., "Pay via M-Pesa").

6. Set Up Webhooks/Endpoints

Copy plugin-provided URLs (e.g., yoursite.com/wc-api/mpesa-callback). Paste into Daraja portal under your app's webhook settings for STK Push confirmation. Test in sandbox mode first to verify prompts on your phone.​

7. Test the Integration

Add a test product to your store. Proceed to checkout, select M-Pesa, enter phone number. You should receive an STK Push; complete payment. Check if order status updates to "Processing" and funds reflect in your till (sandbox uses test numbers like 254708374149).

8. Go Live and Customize

Switch plugin to production mode using live credentials. Customize checkout with CSS for branding. Add shortcodes (e.g., IntaSend) for payment buttons on non-Woo pages: [intasend amount="1000"]. Monitor transactions via Daraja dashboard.​​

Troubleshooting Common Issues

  • No STK Push: Verify webhook URLs and credentials; ensure site uses HTTPS.​

  • Sandbox Errors: Use test phone/credentials; clear cache.

  • Order Not Updating: Check server logs or plugin support forums.

  • Plugin Conflicts: Deactivate others; update WordPress/WooCommerce.

Security and Best Practices

Use HTTPS (via Really Simple SSL plugin). Limit Daraja access to your IP. Regularly update plugins to patch vulnerabilities. For high-volume sites like ICT services, consider paid gateways with fraud detection. Comply with Kenya's Data Protection Act by adding privacy notices.​

Advanced Customizations

Embed payments anywhere with shortcodes or hooks. For subscriptions, pair with Woo Subscriptions. Developers can extend via Daraja API docs for custom flows. Track analytics with Google Analytics e-commerce events post-payment