PHPackages                             cimplival/pesapal - 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. cimplival/pesapal

ActiveLibrary[Payment Processing](/categories/payments)

cimplival/pesapal
=================

A laravel package that integrates into the pesapal api

1.3.1(9y ago)122MITPHPPHP &gt;=5.5.0

Since Oct 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/cimplival/Pesapal)[ Packagist](https://packagist.org/packages/cimplival/pesapal)[ Docs](https://github.com/knox2/pesapal)[ RSS](/packages/cimplival-pesapal/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (16)Used By (0)

Pesapal Laravel 6 API
=====================

[](#pesapal-laravel-6-api)

Laravel 6 Package for the Pesapal API

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

[](#installation)

### Add this package using Composer

[](#add-this-package-using-composer)

Add the following line to your composer.json

`"nesbot/carbon": "2.24 as 2.25.1"`

NB: version of nesbot/carbon might be different

Run the following line:

`composer dump-autoload`

Then lastly run the following line:

`composer require cimplival/pesapal "dev-master"`

### Update your config

[](#update-your-config)

Add the service provider to the providers array in config/app.php:

`Cimplival\Pesapal\PesapalServiceProvider::class,`

Add the facade to the aliases array in config/app.php:

`'Pesapal' => Cimplival\Pesapal\Facades\Pesapal::class,`

### Publish the package configuration

[](#publish-the-package-configuration)

Publish the configuration file and migrations by running the provided console command:

`php artisan vendor:publish --provider="Cimplival\Pesapal\PesapalServiceProvider"`

Setup
-----

[](#setup)

### Environmental Variables

[](#environmental-variables)

PESAPAL\_CONSUMER\_KEY `pesapal consumer key`

PESAPAL\_CONSUMER\_SECRET `pesapal consumer secret`

PESAPAL\_CURRENCY `ISO code for the currency`

PESAPAL\_IPN `controller method to call for instant notifications IPN  as relative path from App\Http\Controllers\ eg "TransactionController@confirmation"`

PESAPAL\_CALLBACK\_ROUTE `route name to handle the callback eg Route::get('donepayment', ['as' => 'paymentsuccess', 'uses'=>'PaymentsController@paymentsuccess']);  The route name is "paymentsuccess"`

**NB: The controller method accepts 4 function parameters, Example:**

```
public function confirmation($trackingid,$status,$payment_method,$merchant_reference)
{
	$payments = Payments::where('tracking',$trackingid)->first();
    $payments -> payment_status = $status;
    $payments -> payment_method = $payment_method;
    $payments -> save();
}
```

### Config

[](#config)

**live** - Live or Demo environment

The ENV Variables can also be set from here.

Usage
-----

[](#usage)

At the top of your controller include the facade
`use Pesapal;`

### Example Code...Better Example..Haha

[](#example-codebetter-examplehaha)

Assuming you have a Payment Model

```
use Pesapal;
use Illuminate\Http\Request;
use App\Http\Requests;
use Illuminate\Support\Facades\Auth;
use App\Payment;

class PaymentsController extends Controller
{
    public function payment(){//initiates payment
        $payments = new Payment;
        $payments -> businessid = Auth::guard('business')->id(); //Business ID
        $payments -> transactionid = Pesapal::random_reference();
        $payments -> status = 'NEW'; //if user gets to iframe then exits, i prefer to have that as a new/lost transaction, not pending
        $payments -> amount = 10;
        $payments -> save();

        $details = array(
            'amount' => $payments -> amount,
            'description' => 'Test Transaction',
            'type' => 'MERCHANT',
            'first_name' => 'Fname',
            'last_name' => 'Lname',
            'email' => 'test@test.com',
            'phonenumber' => '254-723232323',
            'reference' => $payments -> transactionid,
            'height'=>'400px',
            //'currency' => 'USD'
        );
        $iframe=Pesapal::makePayment($details);

        return view('payments.business.pesapal', compact('iframe'));
    }
    public function paymentsuccess(Request $request)//just tells you payment has gone through..but not confirmed
    {
        $trackingid = $request->input('tracking_id');
        $ref = $request->input('merchant_reference');

        $payments = Payment::where('transactionid',$ref)->first();
        $payments -> trackingid = $trackingid;
        $payments -> status = 'PENDING';
        $payments -> save();
        //go back home
        $payments=Payment::all();
        return view('payments.business.home', compact('payments'));
    }
    //This method just tells u that there is a change in pesapal for your transaction..
    //u need to now query status..retrieve the change...CANCELLED? CONFIRMED?
    public function paymentconfirmation(Request $request)
    {
        $trackingid = $request->input('pesapal_transaction_tracking_id');
        $merchant_reference = $request->input('pesapal_merchant_reference');
        $pesapal_notification_type= $request->input('pesapal_notification_type');

        //use the above to retrieve payment status now..
        $this->checkpaymentstatus($trackingid,$merchant_reference,$pesapal_notification_type);
    }
    //Confirm status of transaction and update the DB
    public function checkpaymentstatus($trackingid,$merchant_reference,$pesapal_notification_type){
        $status=Pesapal::getMerchantStatus($merchant_reference);
        $payments = Payment::where('trackingid',$trackingid)->first();
        $payments -> status = $status;
        $payments -> payment_method = "PESAPAL";//use the actual method though...
        $payments -> save();
        return "success";
    }
}
```

#### Example ENV

[](#example-env)

```
 PESAPAL_IPN=PaymentsController@paymentconfirmation
 PESAPAL_LIVE=true
 PESAPAL_CALLBACK_ROUTE=paymentsuccess

```

#### Example Routes

[](#example-routes)

Relevant routes example, to help exclude entire webhooks route group in Csrf check in VerifyCsrfToken Middleware

```
Route::group(['prefix' => '/webhooks'], function () {
    //PESAPAL
    Route::get('donepayment', ['as' => 'paymentsuccess', 'uses'=>'PaymentsController@paymentsuccess']);
    Route::get('paymentconfirmation', 'PaymentsController@paymentconfirmation');
});
```

#### All Done

[](#all-done)

Feel free to report any issues

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 64.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~77 days

Total

15

Last Release

3308d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15650339?v=4)[Valentine Mwangi](/maintainers/cimplival)[@cimplival](https://github.com/cimplival)

---

Top Contributors

[![knox2](https://avatars.githubusercontent.com/u/2101866?v=4)](https://github.com/knox2 "knox2 (45 commits)")[![murwa](https://avatars.githubusercontent.com/u/4976870?v=4)](https://github.com/murwa "murwa (12 commits)")[![valentinemwangi](https://avatars.githubusercontent.com/u/90003905?v=4)](https://github.com/valentinemwangi "valentinemwangi (6 commits)")[![muvans](https://avatars.githubusercontent.com/u/21984756?v=4)](https://github.com/muvans "muvans (4 commits)")[![muruthi](https://avatars.githubusercontent.com/u/7661055?v=4)](https://github.com/muruthi "muruthi (2 commits)")[![cimplival](https://avatars.githubusercontent.com/u/15650339?v=4)](https://github.com/cimplival "cimplival (1 commits)")

---

Tags

paymentslaravel 5mpesavisamastercardpesapalOrange Money

### Embed Badge

![Health badge](/badges/cimplival-pesapal/health.svg)

```
[![Health](https://phpackages.com/badges/cimplival-pesapal/health.svg)](https://phpackages.com/packages/cimplival-pesapal)
```

###  Alternatives

[knox/pesapal

A laravel package that integrates into the pesapal api

29106.3k](/packages/knox-pesapal)[kingflamez/laravelrave

A Laravel Package for Flutterwave Rave

151286.1k4](/packages/kingflamez-laravelrave)[itsmurumba/laravel-mpesa

Laravel Package for Mpesa Daraja API

191.6k](/packages/itsmurumba-laravel-mpesa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
