PHPackages                             tish/laravel-mpesa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. tish/laravel-mpesa

ActiveLibrary[Payment Processing](/categories/payments)

tish/laravel-mpesa
==================

Laravel M-Pesa Lipa Na M-Pesa STK Push integration package with automatic callback handling

05PHP

Since Jul 17Pushed 9mo agoCompare

[ Source](https://github.com/tishmalo/laravel-mpesa)[ Packagist](https://packagist.org/packages/tish/laravel-mpesa)[ RSS](/packages/tish-laravel-mpesa/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel M-Pesa Package
======================

[](#laravel-m-pesa-package)

A Laravel package for integrating M-Pesa Lipa Na M-Pesa STK Push payments.

Installation
------------

[](#installation)

### For Development/Testing (Package not yet published)

[](#for-developmenttesting-package-not-yet-published)

1. **Create the package structure in your Laravel project:**

```
# 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`:**

```
{
    "repositories": [
        {
            "type": "path",
            "url": "./packages/tish/laravel-mpesa"
        }
    ],
    "require": {
        "tish/laravel-mpesa": "dev-main"
    }
}
```

4. **Install the local package:**

```
composer require tish/laravel-mpesa:dev-main
```

### For Production (Once Published to Packagist)

[](#for-production-once-published-to-packagist)

1. **Install the package via Composer:**

```
composer require tish/laravel-mpesa
```

2. **Publish the config file and migrations:**

```
php artisan vendor:publish --provider="Tish\LaravelMpesa\MpesaServiceProvider"
php artisan migrate
```

3. **Add your M-Pesa credentials to your `.env` file:**

```
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=https://yourdomain.com/mpesa/callback
MPESA_SANDBOX=true
```

4. **Create listeners to handle payment events:**

```
php artisan make:listener HandleSuccessfulPayment
php artisan make:listener HandleFailedPayment
```

5. **Register the event listeners in your `app/Providers/EventServiceProvider.php`:**

```
