Downloads
Stars
Version
![Issues]( https://img.shields.io/github/issues/techquest/isw-laravel-sdk) ![Forks]( https://img.shields.io/github/forks/techquest/isw-laravel-sdk) ![Stars]( https://img.shields.io/github/stars/techquest/isw-laravel-sdk)
Interswitch's official laravel package to easily integrate to Quickteller Business to collect payments. To begin, create an account at https://business.quickteller.com if you haven't already.
PHP 7.2+ and Composer are required.
To get the latest version of Laravel Interswitch, simply require it like so:
composer require interswitch/laravel-interswitch
Once installed, the package automatically registers its service provider and facade.
You can publish the configuration file using this command:
php artisan vendor:publish --provider="Interswitch\Interswitch\InterswitchServiceProvider"
A configuration file 'interswitch.php' with some defaults is placed in your config directory.
The payment flow is described below:
Quickteller Business provides a test and a live environment.
The test environment allows you to test your integration without actually charging any bank account.
After successfully testing your integration, you can easily switch to the live environment (after all required documents have been uploaded).
For the test environment, in your .env file, add:
INTERSWITCH_ENV=TEST
For the live environment, in your .env file, add:
INTERSWITCH_ENV=LIVE
If none is present, the test environment is assummed by default.
Furthermore, you need to add the following environment variables:
INTERSWITCH_REDIRECT_URL=
INTERSWITCH_PAY_ITEM_ID=
INTERSWITCH_MERCHANT_CODE=
The INTERSWITCH_REDIRECT_URL is the endpoint you will like to get the status of a transaction. Also define this route in your route file and make a call to confirmTransaction() like so:
use Interswitch\Interswitch\Facades\Interswitch;
...
Interswitch::confirmTransaction();
To get your INTERSWITCH_PAY_ITEM_ID and INTERSWITCH_MERCHANT_CODE, visit https://business.quickteller.com/developertools
Create your view like so:
NOTE: The form must be submitted to interswitch-pay using post method.
<form action="interswitch-pay" method="post">
<input type="hidden" name="customerEmail" value="[email protected]" />
<input type="hidden" name="amount" value="15000" />
<input type="hidden" name="transactionReference" value="abcdfi1389jk">
<!-- Amount must be in kobo-->
<button
type="submit"
style="
padding: 12px 22px;
background-color: #c80e0e;
border: none;
color: #fff;
font-size: 1em;
border-radius: 5px;
"
>
Pay Now
</button>
</form>
Note: 'amount' field must be in kobo
Below is a list of all the supported parameters. These parameters can be added in your form:
Parameters | Data Type | Required | Description |
---|---|---|---|
customerEmail | string | true | The email of the person making the payment. |
amount | string | true | The cost of the item being paid for in kobo. |
transactionReference | string | true | This is a unique reference string required for every transaction. You can create a method to generate this. |
currency | string | false | The ISO code of the currency being used. If this field is not added, the currency naira is assumed. |
customerName | string | false | The name of the person making the payment. |
customerID | string | false | The ID of the person making the payment. |
payItemName | string | false | The name of the item being paid for. |
{
"transactionReference": "y84KWu1617176725",
"responseCode": "00",
"responseDescription": "Approved by Financial Institution",
"paymentReference": "FBN|WEB|MX26070|31-03-2021|3511400|927085",
"returnedReference": "1287984345",
"cardNumber": "",
"approvedAmount": "15000",
"amount": "15000",
"mac": ""
}
For integrity purpose, you need to make a server side request to get the final status of a transaction before giving value. To do this, make a call to confirmTransaction(transactionReference, amount) like so:
use Interswitch\Interswitch\Facades\Interswitch;
...
Interswitch::confirmTransaction(transactionReference, amount);
It returns a JSON object containing the status of the transaction. Consider the sample response below:
{
"paymentReference": "FBN|WEB|MX26070|31-03-2021|3511400|927085",
"responseCode": "00",
"responseDescription": "Approved by Financial Institution",
"amount": "15000",
"transactionDate": "2021-03-31T08:45:31",
"merchantReference": "y84KWu1617176725"
}
Below is a description of the response keys:
Key | Meaning |
---|---|
responseCode | A code indicating the status of the transaction. |
responseDescription | This gives a full description of the transaction status |
amount | This indicates the total amount transacted in kobo. |
paymentReference | Indicates the transaction reference generated by the payment gateway. |
merchantReference | Indicates the transaction reference provided by you. |
transactionDate | Shows the date and time the transaction took place. |
There are quite a number of response codes that can be returned, the full list can be viewed here
To go live,
INTERSWITCH_ENV=LIVE
The MIT License (MIT). Please see License File for more information.