This platform provides seamless integration with M-Pesa's Daraja API, enabling businesses to accept and process mobile money payments.
All API requests require authentication using OAuth 2.0 Bearer tokens.
POST /api/generate_token.php
Response:
{
"success": true,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ..."
}
Tokens are valid for 1 hour.
STK Push sends a payment prompt directly to the customer's phone.
POST /api/stk_push.php
Parameters:
- phone: Customer phone number (254XXXXXXXXX)
- amount: Amount to charge (minimum 1)
- reference: Account reference (alphanumeric)
- description: Transaction description
{
"status": 200,
"response": {
"MerchantRequestID": "29115-34620561-1",
"CheckoutRequestID": "ws_CO_191220191020363925",
"ResponseCode": "0",
"ResponseDescription": "Success. Request accepted for processing",
"CustomerMessage": "Success. Request accepted for processing"
}
}
C2B allows customers to pay directly to your PayBill or Till number.
POST /api/c2b_register.php
Register your validation and confirmation URLs (one-time setup).
Customer uses M-Pesa menu:
Your confirmation URL receives payment details:
{
"TransactionType": "Pay Bill",
"TransID": "LGR019G3J2",
"TransAmount": "100.00",
"BusinessShortCode": "600126",
"BillRefNumber": "account123",
"MSISDN": "254708374149",
"FirstName": "John"
}
| Code | Description | Action |
|---|---|---|
| 0 | Success | Transaction completed successfully |
| 1 | Insufficient Balance | Customer has insufficient funds |
| 1032 | Cancelled by User | Customer cancelled the request |
| 1037 | Timeout | User didn't enter PIN in time |
| 2001 | Invalid Initiator | Check your credentials |
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request |
| 401 | Unauthorized |
| 500 | Server Error |
Current configuration uses Safaricom's sandbox for safe testing.
| Parameter | Value |
|---|---|
| Environment | Sandbox |
| Test Phone Numbers | 254708374149, 254712345678 |
| Test Amounts | 1 - 70,000 KES |
| Shortcode | 174379 |
For assistance with integration or technical support: