Setting Up Laravel for M-Pesa Integration

 
Objective: Set up a Laravel application and prepare for M-Pesa API integration.
1. Install a fresh Laravel project:
 laravel new mpesa-integration
2. Add required packages for HTTP requests:
 
composer require guzzlehttp/guzzle
 3. Configure environment variables in .env:
MPESA_CONSUMER_KEY=your_consumer_key
MPESA_CONSUMER_SECRET=your_consumer_secret
MPESA_BASE_URL=https://sandbox.safaricom.co.ke
4. Create an M-Pesa Service for reusable code:
php artisan make:service MpesaService