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

ActiveLibrary[Payment Processing](/categories/payments)

mudassar1/pesapal
=================

A laravel package that integrates into the pesapal api

1.4.5(3y ago)019MITPHPPHP &gt;=7|^8.0|^8.1|^8.2

Since Oct 25Pushed 3y agoCompare

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

READMEChangelog (2)DependenciesVersions (24)Used By (0)

Pesapal Laravel 5,6,7,8,9 API
=============================

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

Laravel 5,6,7,8,9 Package for the Pesapal API

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

[](#installation)

### Add this package using Composer

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

From the command line inside your project directory, simply type:

`composer require knox/pesapal`

### Update your config (for Laravel 5.4 and below)

[](#update-your-config-for-laravel-54-and-below)

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

`Knox\Pesapal\PesapalServiceProvider::class,`

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

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

### Publish the package configuration (for Laravel 5.4 and below)

[](#publish-the-package-configuration-for-laravel-54-and-below)

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

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

Setup
-----

[](#setup)

### Pesapal IPN

[](#pesapal-ipn)

For the url of the route use /pesapal-ipn eg mysite.com/pesapal-ipn as the IPN on the Pesapal Merchant settings dashboard

### 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 u payment has gone thru..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 View

[](#example-view)

```
  {!! $iframe !!}

```

#### 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

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 70.2% 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 ~121 days

Recently: every ~265 days

Total

23

Last Release

1177d ago

Major Versions

0.0.0 → 1.0.02015-10-25

PHP version history (4 changes)0.0.0PHP &gt;=5.5.0

1.4.0PHP &gt;=7

1.4.4PHP &gt;=7|^8.0

1.4.5PHP &gt;=7|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f115a75cb2bcd6f2d49df470031598468f7171553c55911489a1ab00d90e5c0?d=identicon)[mudassar1](/maintainers/mudassar1)

---

Top Contributors

[![knox2](https://avatars.githubusercontent.com/u/2101866?v=4)](https://github.com/knox2 "knox2 (59 commits)")[![murwa](https://avatars.githubusercontent.com/u/4976870?v=4)](https://github.com/murwa "murwa (14 commits)")[![muvans](https://avatars.githubusercontent.com/u/21984756?v=4)](https://github.com/muvans "muvans (4 commits)")[![mudassar1](https://avatars.githubusercontent.com/u/32808751?v=4)](https://github.com/mudassar1 "mudassar1 (3 commits)")[![george-raphael](https://avatars.githubusercontent.com/u/11408141?v=4)](https://github.com/george-raphael "george-raphael (2 commits)")[![muruthi](https://avatars.githubusercontent.com/u/7661055?v=4)](https://github.com/muruthi "muruthi (2 commits)")

---

Tags

laravellaravel 6laravel 7laravel 8paymentslaravel 5mpesavisamastercardpesapalOrange Money

### Embed Badge

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

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

###  Alternatives

[unicodeveloper/laravel-paystack

A Laravel Package for Paystack

650975.6k11](/packages/unicodeveloper-laravel-paystack)[knox/pesapal

A laravel package that integrates into the pesapal api

29106.3k](/packages/knox-pesapal)[itsmurumba/laravel-mpesa

Laravel Package for Mpesa Daraja API

191.6k](/packages/itsmurumba-laravel-mpesa)[prevailexcel/laravel-nowpayments

A Laravel Package for NOWPayments

1414.2k](/packages/prevailexcel-laravel-nowpayments)[thepeer/sdk

Thepeer official Laravel SDK

272.8k](/packages/thepeer-sdk)

PHPackages © 2026

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