# mpesa_parser 💳
A zero-dependency, high-precision **Dart & Flutter package** for parsing Kenyan **M-PESA** payment confirmation SMS messages (Till, PayBill, Fuliza, Sent, and Received transfers) into structured Dart objects.
---
## ⚡ Features
- 🛒 **Till Payments**: Matches Till numbers, merchant names, amounts, and transaction IDs.
- 🏢 **PayBill Payments**: Extracts business numbers, account numbers, and merchant titles.
- 💸 **Personal Transfers**: Parses sender/receiver phone numbers and names into Title Case.
- 💰 **Balance Extraction**: Detects remaining M-PESA account balances when available.
- 🔒 **PII Safe**: Performs purely offline parsing with zero remote network calls or PII storage.
---
## 📦 Installation
Add `mpesa_parser` to your `pubspec.yaml`:
```yaml
dependencies:
mpesa_parser: ^1.0.0
```
Or install via terminal:
```bash
flutter pub add mpesa_parser
```
---
## 💡 Usage Example
```dart
import 'package:mpesa_parser/mpesa_parser.dart';
void main() {
final sms = 'RKT123456 Confirmed. Ksh500.00 paid to BINGWA FAST Till 400200. New M-PESA balance is Ksh2,500.00.';
final receipt = MpesaParser.parse(sms);
if (receipt != null) {
print('Transaction ID: ${receipt.txId}'); // RKT123456
print('Amount: KES ${receipt.amount}'); // 500
print('Name: ${receipt.name}'); // Bingwa Fast
print('Merchant: ${receipt.accountOrMerchant}'); // Till 400200
print('Balance: KES ${receipt.remainingBalance}'); // 2500
}
}
```
---
## 🧪 Testing
Run the included Dart unit test suite:
```bash
dart test
```
---
## 📄 License
Distributed under the **MIT License**. See `LICENSE` for details.
Created by **@officialmrlyco**.