PHP project that extracts structured JSON data from password protected M-Pesa statements.
# M-Pesa Statement JSON Extractor (PHP)
PHP project that extracts structured JSON data from M-Pesa statements.
---
## Features
- Parse M-Pesa statements and provided PIN
- Extract key transaction details:
- Transaction ID
- Date & Time
- Amount
- Balance
- Phone Number
- Transaction Type
- Output clean JSON format
- Simple and fast PHP implementation
---
## Use Case
- Financial reconciliation systems
- Expense tracking apps
- Business intelligence dashboards
- Integration with accounting software
---
## Sample Output
```json
{
"status": "ok",
"text_extracted": true,
"metadata": {
"Producer": "GPL Ghostscript 9.27",
"CreationDate": "2026-03-20T13:41:40-04:00",
"ModDate": "2026-03-20T13:41:40-04:00",
"Author": "Safaricom PLC",
"Creator": "Safaricom PLC",
"Title": "254722000000_2025-09-14 15:49:13_2026-03-14 15:49:13_1773492555624.pdf",
"Subject": "M-PESA Statement",
"Keywords": "M-PESA,Statement",
"Pages": 30,
"pdf:producer": "GPL Ghostscript 9.27",
"pdf:keywords": "M-PESA,Statement",
"xmp:modifydate": "2026-03-20T13:41:40-04:00",
"xmp:createdate": "2026-03-20T13:41:40-04:00",
"xmp:creatortool": "Safaricom PLC",
"dc:title": "254722000000_2025-09-14 15:49:13_2026-03-14 15:49:13_1773492555624.pdf",
"dc:creator": "Safaricom PLC",
"dc:description": "M-PESA Statement"
},
"biodata": {
"customer_name": "JOHN SMITH DOE",
"mobile_number": "0722000000",
"email_address": "johndoe@example.com",
"statement_period": "20 Sep 2025 - 20 Mar 2026",
"request_date": "20 Mar 2026"
},
"summary": [
{
"type": "SEND MONEY",
"paid_in": "0.00",
"paid_out": "100.00"
},
{
"type": "RECEIVED MONEY",
"paid_in": "201.44",
"paid_out": "0.00"
},
{
"type": "AGENT DEPOSIT",
"paid_in": "160.00",
"paid_out": "0.00"
},
{
"type": "AGENT WITHDRAWAL",
"paid_in": "0.00",
"paid_out": "881.00"
},
{
"type": "LIPA NA M-PESA (PAYBILL)",
"paid_in": "0.00",
"paid_out": "597.17"
},
{
"type": "LIPA NA M-PESA (BUY GOODS)",
"paid_in": "0.00",
"paid_out": "282.25"
},
{
"type": "OTHERS",
"paid_in": "5,991.09",
"pa …