parsepesa / php
Official PHP SDK for ParsePesa - The Stripe for M-Pesa SMS.
v2.0.0
2026-06-11 16:26 UTC
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.0
README
The official PHP SDK for ParsePesa - The Stripe for M-Pesa SMS. Convert raw M-Pesa messages into structured JSON in milliseconds.
Installation
Install the package via Composer:
composer require parsepesa/php
Quick Start
use ParsePesa\ParsePesa; $sdk = new ParsePesa('your_api_key'); // Parse a single message $result = $sdk->parse("Confirmed. You have received KES 500.00 from JOHN DOE..."); echo $result['amount']; // 500 echo $result['counterparty']; // JOHN DOE
Features
1. Single Parsing
$result = $sdk->parse($message);
2. Batch Parsing
$results = $sdk->batchParse([$msg1, $msg2]);
3. Account Balance
$balance = $sdk->getBalance(); echo "KES " . $balance;
4. Handling Webhooks
Use this in your callback URL endpoint:
$data = $sdk->handleWebhook(); // Process $data['type'], $data['amount'], etc.
Requirements
- PHP 7.4 or higher
guzzlehttp/guzzle7.0+
License
MIT