Mpesa gateway for PMPRO
# M-Pesa Gateway for Paid Memberships Pro
Accept M-Pesa payments on your WordPress membership site powered by
Paid Memberships Pro using the
**Safaricom Daraja STK Push** (Lipa Na M-Pesa Online / M-Pesa Express) API.
> **Live page:**
urandu.github.io
---
## Features
- 🚀 **Daraja STK Push** – customers receive an M-Pesa PIN prompt directly on their phone; no manual "go to M-Pesa and pay" instructions
- 🔄 **Automatic status polling** – `mpesa_stk_query()` checks Daraja if the async callback hasn't arrived yet, so checkout completes on the second form submission
- 🔒 **Secure callback endpoint** – HMAC-safe secret UID validates every Safaricom server-to-server call
- 🛡️ **SQL-injection free** – all database operations use `wpdb->prepare()` / `wpdb->insert/update/delete()`
- ♻️ **WordPress HTTP API** – no raw cURL; respects WordPress proxy settings
- 🧪 **25 PHPUnit tests** included
---
## Requirements
| Requirement | Minimum version |
|---|---|
| PHP | 7.4 or higher |
| WordPress | 5.6 or higher |
| Paid Memberships Pro | 2.9 or higher |
| Safaricom Daraja API | v1 (sandbox + production) |
---
## Installation
### From a GitHub Release (recommended)
1. Go to the Releases page and download the latest `pmpro-mpesa-gateway-x.x.x.zip`.
2. In your WordPress admin, go to **Plugins → Add New → Upload Plugin**.
3. Upload the zip file and click **Install Now**, then **Activate**.
### Manual / Git
```bash
cd wp-content/plugins
git clone
github.com
```
Then activate the plugin from **Plugins → Installed Plugins**.
---
## Configuration
### 1 – Get your Daraja API credentials
1. Log in to the Safaricom Developer Portal.
2. Create an app (or use an existing one) and note down:
- **Consumer Key**
- **Consumer Secret**
3. Under **Lipa Na M-Pesa Online**, retrieve your **Passkey** for your shortcode.
### 2 – Configure the plugin
Go to **WordPress Admin → Memberships → Payment Settings** and select **M-Pesa …