
PhpNuxBill Mpesa STK Push and C2B Offline
Uploaded: 25 Mar, 2025
M-Pesa STK Push Integration & C2B OFFLINE for PHPNUXBILL
Overview
Enhance your PHPNUXBILL billing system with seamless M-Pesa STK Push & C2B offline payment integration. This solution allows customers to make payments effortlessly by receiving a prompt on their mobile phones to enter their M-Pesa PIN and complete transactions securely. Additionally, it allows recording offline payments.
Key Features
- Automated Payment Requests – Sends an STK Push request to the customer’s phone.
- Real-Time Transaction Processing – Instantly confirms payments upon user approval.
- Seamless Integration – Designed for quick and easy setup in PHPNUXBILL.
- Secure and Reliable – Uses encrypted API requests to safeguard transactions.
- User-Friendly Interface – Simple UI template included for easy interaction.
Installation Guide
Prerequisites
Before proceeding with the installation, ensure that:
- Your PHP version is 5.6 or higher.
- You have the CreateHotspotUser.php file in your PHPNUXBILL root directory. If not, contact support at 0113015674.
Step-by-Step Installation
Extract the provided folder, which contains the following files:
- mpesa.php – Main integration file.
- c2b.php – Handles customer-to-business (C2B) transactions.
- initiatempesa.php – Triggers the M-Pesa STK Push.
- mpesa.tpl – UI template file.
- mpesa_transactions.php – Transaction management file.
- mpesa_transactions.tpl – UI template for transaction configuration.
- README.md – Documentation file.
Configure Your Credentials Open initiatempesa.php and enter your Safaricom API credentials:
- $consumerKey = ''; // Your M-Pesa Consumer Key $consumerSecret = ''; // Your M-Pesa Secret Key $BusinessShortCode = ''; // Your Business Short Code $Passkey = ''; // Your Lipa Na M-Pesa Passkey
File Placement Place the files into the appropriate directories within your PHPNUXBILL installation:
- mpesa.php → Place inside the paymentgateway folder.
- mpesa.tpl → Place inside the paymentgateway > ui folder.
- initiatempesa.php → Place inside the plugin folder.
- mpesa_transactions.php → Place inside the plugin folder.
- mpesa_transactions.tpl → Place inside the plugin > ui folder.
- c2b.php → Place inside the plugin folder.
Folder Structure After Installation
PHPNUXBILL/
PHPNUXBILL/
├── paymentgateway/
│ ├── mpesa.php
│ ├── ui/
│ ├── mpesa.tpl
├── plugin/
│ ├── initiatempesa.php
│ ├── mpesa_transactions.php
│ ├── c2b.php
│ ├── ui/
│ ├── mpesa_transactions.tpl
Additional Notes
- Ensure proper file permissions to avoid permission issues.
- Perform a test transaction to verify the integration.
- Refer to PHPNUXBILL documentation for troubleshooting steps.
Best Practices
- Use Version Control: Track modifications using Git or other versioning tools.
- Backup Before Changes: Save a copy of your PHPNUXBILL installation before adding new files.
For assistance or troubleshooting, feel free to reach out. Upgrade your PHPNUXBILL system today with fast and secure M-Pesa STK Push payments!
Related Scripts







