PHPackages                             toyosi/laravel-interswitch - 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. toyosi/laravel-interswitch

ActiveLibrary[Payment Processing](/categories/payments)

toyosi/laravel-interswitch
==========================

This package simplifies interswitch payment integration in laravel

153564PHP

Since Dec 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/toyosi12/laravel-interswitch)[ Packagist](https://packagist.org/packages/toyosi/laravel-interswitch)[ RSS](/packages/toyosi-laravel-interswitch/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-interswitch
===================

[](#laravel-interswitch)

[![Issues](https://camo.githubusercontent.com/fe0e35f3dd528f51948d443f6565557ed17bca54620a1edb56e6ceac5269750d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f746f796f736931322f6c61726176656c2d696e746572737769746368)](https://github.com/toyosi12/laravel-interswitch/issues)[![Forks](https://camo.githubusercontent.com/8bdcd6c5618e2befdd4f65477b7d4f0ffaff1af5e16a080ded29c5f981910f55/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f746f796f736931322f6c61726176656c2d696e746572737769746368)](https://github.com/toyosi12/laravel-interswitch/network/members)[![Stars](https://camo.githubusercontent.com/0722ecf5578910d0b644e0434f5ce9cc0164c7f6767a76ffcae6a988d7124046/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f746f796f736931322f6c61726176656c2d696e746572737769746368)](https://github.com/toyosi12/laravel-interswitch/stargazers)

> A laravel package to easily integrate interswitch

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

[](#installation)

[PHP](https://php.net) 7.2+ and [Composer](https://getcomposer.org) are required.

To get the latest version of Laravel Interswitch, simply require it

```
composer require toyosi/laravel-interswitch
```

Once installed, the package automatically registers its service provider and facade.

Next, run migration to get the database table that logs all transactions:

```
php artisan migrate
```

Configuration
-------------

[](#configuration)

You can publish the configuration file using this command:

```
php artisan vendor:publish --provider="Toyosi\Interswitch\InterswitchServiceProvider"
```

A configuration file 'interswitch.php' with some defaults is placed in your config directory.

With this package, you can easily integrate the three major payment types of interswitch which are webpay, paydirect or collegepay. Webpay is the default type.

Payment Flow
------------

[](#payment-flow)

The payment flow described below applies to interswitch and many other payment gateways

1. User clicks a button to make payment, the user is redirected to the payment provider's site, usually by submitting a form with hidden fields. A hash is generated from these fields.
2. On the payment provider's site, card details are entered.
3. The user is redirected back with details of the transaction indicating a successful or failed transaction.

Usage
-----

[](#usage)

### Test Environment

[](#test-environment)

### 1. Open .env and add:

[](#1-open-env-and-add)

```
INTERSWITCH_SITE_REDIRECT_URL="${APP_URL}/response"
```

This is the only variable in the test environment that is required. 'response' as indicated above could be anything. The specified value indicates the url the user is redirected to after every transaction. Don't forget to add this route in your project. In this case, it will be:

```
 Route::get('response', function(){
  return $_GET;
 });
```

Note: please ensure APP\_URL is correctly defined.

### 2. Create payment route and view

[](#2-create-payment-route-and-view)

Create your payment route in web.php. Something like:

```
Route::get('pay', function(){
  return view('payment');
});
```

Then create the view. In this case, 'payment.blade.php'. The view can be like so:

```

    Pay Now

```

**Note: 'amount' field must be in kobo**

Navigate to your newly created route, click the 'Pay Now' button and follow the required steps. Note that the form is submitted to route 'interswitch-pay', this is predefined in the package. All the fields are required. On clicking the 'Pay Now' button, the user is redirected to interswitch's payment page, where card details are entered. The user is then redirected back to your website as indicated by 'INTERSWITCH\_SITE\_REDIRECT\_URL'. This url will return the result of the transaction. Sample response will be like so:

```
{
  "paymentReference": "FBN|WEB|CDEM|10-12-2020|383104",
  "responseCode": "00",
  "responseDescription": "Approved Successful",
  "amount": "12000",
  "transactionDate": "2020-12-10T15:59:37.827",
  "customerEmail": "toyosioyelayo@gmail.com",
  "customerName": "Toyosi Oyelayo"
}
```

A list of test cards [can be found here](https://sandbox.interswitchng.com/docbase/docs/webpay/test-cards).

### Live Environment

[](#live-environment)

The same processes described in the test environment above also applies to the live environment. Do note that Interswitch does certain checks on your website before it can be approved to recieve live payments:

1. You must have the interswitch logo on your website
2. You must have filled and submitted the User Acceptance Test Form which has to be approved by interswitch. You can [download the form here](https://sandbox.interswitchng.com/docbase/docs/webpay/merchant-user-acceptance-testing)
3. After this, you are given your unique Product ID, MAC ID and Pay Item ID. These have to be included in your .env file like so:

```
INTERSWITCH_PRODUCT_ID=
INTERSWITCH_MAC_KEY=
INTERSWITCH_PAY_ITEM_ID=
```

You also have to change the environment to live like so:

```
INTERSWITCH_ENV=LIVE
```

To change the integration type, use:

```
INTERSWITCH_GATEWAY_TYPE=
```

The values could be 'WEBPAY', 'PAYDIRECT' or 'COLLEGEPAY'. 'WEBPAY' is the default.

Split Payment
-------------

[](#split-payment)

With split payment, you can divide money recieved on your site into multiple accounts. This is only available on COLLEGEPAY. Split implementation uses XML which I have handled in the package. You can setup split payments in two easy steps:

### 1. Enable split payments in .env like so:

[](#1-enable-split-payments-in-env-like-so)

```
 INTERSWITCH_SPLIT=true
```

### 2. Configure accounts and percentage allocation.

[](#2-configure-accounts-and-percentage-allocation)

You need to specify the account numbers to be credited and percentage of the total amount to be credited into each account. To do this, open 'config/interswitch.php' and edit the key 'splitDetails'. Do note that this key already exists, you only need to edit it:

```
'splitDetails' => [
         [
           'itemName' => 'item1',
           'bankID' => 7,
           'accountNumber' => 1234567890,
           'percentageAllocation' => 50

       ],
       [
           'itemName' => 'item2',
           'bankID' => 10,
           'accountNumber' => 4564567890,
           'percentageAllocation' => 50
       ]
     ],
```

In the above example, two bank accounts are indicated and the total amount is split into two equal parts (50% each) as indicated with 'percentageAllocation'. In the test environment, 'accountNumber' can be any 10 digit number. Don't forget to change to valid account numbers in the live environment. The package handles the conversion into XML and other necessary stuffs. Note: You can find the [list of bank IDs here.](https://sandbox.interswitchng.com/docbase/docs/collegepay-web/xml-split-bank-codes)

Transaction Logs
----------------

[](#transaction-logs)

You can find all transaction logs at the 'interswitch-logs' route. Don't forget to protect this route. You don't want just any user to have access to it.

### Requerying Transactions

[](#requerying-transactions)

Sometimes, things might go wrong while a user is making a payment. It could be power failure or flaky internet connectivity. To complete an already started payment process, you can click the 'requery' button in 'interswitch logs'. This updates the transaction as necessary.

Further Info
------------

[](#further-info)

Interswitch requires that the user gets a mail after every successful transaction. This has already been added to the package. You only need to add the following to your .env file:

```
INTERSWITCH_SEND_MAIL=true
```

Ensure that your mail variables are properly set in .env.

Contributing
------------

[](#contributing)

Do feel free to fork this repo and contribute by submitting a pull request. Let's make it better.

Star
----

[](#star)

I'd love you star this repo. Also [follow me on twitter](https://twitter.com/dev_toyosi)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5153088?v=4)[toyosi](/maintainers/toyosi)[@toyosi](https://github.com/toyosi)

---

Top Contributors

[![toyosi12](https://avatars.githubusercontent.com/u/26188489?v=4)](https://github.com/toyosi12 "toyosi12 (46 commits)")

---

Tags

fundinterswitchlaravellaravel-interswitchmoneytransfer

### Embed Badge

![Health badge](/badges/toyosi-laravel-interswitch/health.svg)

```
[![Health](https://phpackages.com/badges/toyosi-laravel-interswitch/health.svg)](https://phpackages.com/packages/toyosi-laravel-interswitch)
```

###  Alternatives

[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

181.1k](/packages/msilabs-bkash)

PHPackages © 2026

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