MPESA Package for Laravel
# M-Pesa Integration for Laravel
A robust PHP library for integrating Safaricom's M-Pesa API with Laravel applications. This package simplifies payments, QR code generation, and transaction management.
## Features
* Dynamic QR Code Generation
* STK Push (Customer Payment)
* C2B Simulations
* B2C Transactions
* Transaction Status Checks
* Account Balance Inquiry
* Reversals
* Secure Authentication
## Installation
Install via Composer:
```bash
composer require nyanumba-codes/mpesa
```
## Configuration
First Run the Installation:
```bash
php artisan mpesa:install {environment}
```
The Environment value can either be left blank, or written `sandbox` for The Sandbox Certificate file to be downloaded into the public folder or `production` for the Production Certificate to be downloaded.
```bash
# For Sandbox
php artisan mpesa:install
# or
php artisan mpesa:install sandbox
```
```bash
# For Production
php artisan mpesa:install production
```
Ensure the Safaricom public certificate (cert.cer) is stored securely under `public/mpesa`.
After this you may proceed to update your .env file. This one is rather longer this time round because all the MPESA APIs have been covered by this application. I have even separated all the Callbacks, Timeouts and Result URL to allow for development maleability.
```bash
# Environment (sandbox or production)
MPESA_ENV=sandbox
# Consumer credentials
MPESA_CONSUMER_KEY=your_consumer_key_here
MPESA_CONSUMER_SECRET=your_consumer_secret_here
# Security credential
MPESA_USERNAME=your_username_here
MPESA_SECURITY_CREDENTIAL=your_security_credential_here
# Shortcode and passkey
MPESA_SHORTCODE=your_shortcode_here
MPESA_PASSKEY=your_passkey_here
# C2B (Customer to Business) URLs
MPESA_C2B_CONFIRMATION=
yourdomain.com
MPESA_C2B_VALIDATION=
yourdomain.com
# Transaction status callback URLs
MPESA_TRANSACTION_RESULT=
yourdomain.com
MPESA_TRANSACTIO …