Logo Lanfrica

tishmalo/laravel-mpesa

Domaine:

digital infrastructure

Type de record:

software
Créateur:
tis
Hôte:
Laravel M-Pesa Lipa Na M-Pesa STK Push integration package # Laravel M-Pesa Package A Laravel package for integrating M-Pesa Lipa Na M-Pesa STK Push payments. ## Installation ### For Development/Testing (Package not yet published) 1. **Create the package structure in your Laravel project:** ```bash # In your Laravel project root mkdir -p packages/tish/laravel-mpesa ``` 2. **Copy all package files to `packages/tish/laravel-mpesa/`** (see file structure below) 3. **Add the local package repository to your main `composer.json`:** ```json { "repositories": [ { "type": "path", "url": "./packages/tish/laravel-mpesa" } ], "require": { "tish/laravel-mpesa": "dev-main" } } ``` 4. **Install the local package:** ```bash composer require tish/laravel-mpesa:dev-main ``` ### For Production (Once Published to Packagist) 1. **Install the package via Composer:** ```bash composer require tish/laravel-mpesa ``` 2. **Publish the config file and migrations:** ```bash php artisan vendor:publish --provider="Tish\LaravelMpesa\MpesaServiceProvider" php artisan migrate ``` 3. **Add your M-Pesa credentials to your `.env` file:** ```env MPESA_CONSUMER_KEY=your_consumer_key MPESA_CONSUMER_SECRET=your_consumer_secret MPESA_PASSKEY=your_passkey MPESA_BUSINESS_SHORT_CODE=your_shortcode MPESA_CALLBACK_URL=yourdomain.com MPESA_SANDBOX=true ``` 4. **Create listeners to handle payment events:** ```bash php artisan make:listener HandleSuccessfulPayment php artisan make:listener HandleFailedPayment ``` 5. **Register the event listeners in your `app/Providers/EventServiceProvider.php`:** ```php [ \App\Listeners\HandleSuccessfulPayment::class, ], PaymentFailed::class => [ \App\Listeners\HandleFailedPayment::class, ], ]; public function boot() { // } } ``` 6. **Implement your listeners:** **`app/Listeners/HandleSuccessfulPayment.php`:** ```php transaction; Log::info('Payment completed', [ 'account_reference' => $transaction->account_reference, 'receipt_number' => $transaction->mpesa_receipt_number, 'amount' => $transaction-> …

Languages

Licenses