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 β¦