The Laravel NCBA package allows you to transfer money through the NCBA Open Banking APIs. The package supports Laravel version 5 and above.
akika/laravel-ncba is a Laravel package for the laravel ncba package allows you to transfer money through the ncba open banking apis. the package supports laravel version 5 and above..
It currently has 1 GitHub stars and 443 downloads on Packagist (latest version v0.2.1).
Install it with composer require akika/laravel-ncba.
Discover more Laravel packages by akika
or browse all Laravel packages to compare alternatives.
Last updated
The Laravel NCBA package allows you to transfer money through the NCBA Open Banking APIs. The package supports Laravel version 5 and above.
You can install the package via composer:
composer require akika/laravel-ncba
After installing the package, publish the configuration file using the following command:
php artisan ncba:install
This will import ncba.php config file in your project config directory where you can set your NCBA related parameters and other configuration options.
Add the following configurations into your .env file
NCBA_ENV= # This value is either sandbox or production. This config variable - This is required to enable Laravel NCBA pick the required variables.
NCBA_DEBUG= # This value is true or false. If true, the app will write debug logs.
NCBA_SANDBOX_API_KEY= # The provided sandbox API Key. Contact NCBA for this key.
NCBA_SANDBOX_USERNAME= # Sandbox username
NCBA_SANDBOX_PASSWORD= # Sandbox password
NCBA_SANDBOX_URL= # Sandbox API URL
NCBA_PRODUCTION_API_KEY= # You will reveive this key after you are fully onboarded onto NCBA Online Banking API.
NCBA_PRODUCTION_USERNAME= # Production username
NCBA_PRODUCTION_PASSWORD= # Production password
NCBA_PRODUCTION_URL= # Production API URL
To upgrade Laravel NCBA Package to the latest version, run the following command
composer update akika/laravel-ncba
use Akika\LaravelNcba\Ncba;
// You can initialize the class without passing any parameters. In this case, you must ensure the credentials are in the .env file
$ncba = new Ncba();
// or
// You can also override the variables as shown below. In this case, the package will ignore the variables in the config file.
$ncba = new Ncba($apiKey, $username, $password);
An AP token is required to authenticate and use NCBA API's. Below is how to authenticate.
$ncba->authenticate();
Gets account details including account balance.
$ncba->accountDetails($apiToken, $countryCode, $accountNo);
Gets a mini statement for the account
$ncba->miniStatement($apiToken, $countryCode, $accountNo);
Gets an account statement based on the the specified period of time. The date format is 'ddmmyyyy'
$ncba->accountStatement($apiToken, $countryCode, $accountNo, $fromDate, $toDate);
$ncba = new Ncba();
$response = $ncba->checkTransactionStatus($apiToken, $countryCode, $transactionID);
Below is a sample result for a successful transaction.
{
"ErrorCode": "000",
"ErrorMessage": "Success",
"TransactionId": "String",
"CoreReference": "String",
}
Below is a transaction successful result
{
"resultCode": "000",
"statusDescription": "SUCCESS",
"cbxReferenceNumber": "IFT123454-3",
"txnReferenceNo": "FTX24211TAACS"
}
$ncba = new Ncba();
$response = $ncba->ift($apiToken, $country, $transactionID, $beneficiaryAccountNumber, $beneficiaryAccountName, $senderAccountNumber, $currency, $amount $narration);
$ncba = new Ncba();
$response = $ncba->eft($apiToken, $amount, $beneficiaryAccountNumber, $beneficiaryBankBic, $beneficiaryName, $currency, $senderAccountNumber, $narration, $senderCountry, $transactionID, $senderCIF);
$ncba = new Ncba();
$response = $ncba->rtgs($apiToken, $beneficiaryAccountNumber, $beneficiaryBankBIC, $beneficiaryCountry, $beneficiaryName, $creditAmount, $creditCurrency, $debitCurrency, $narration, $senderAccountNumber, $senderCIF, $senderCountry, $purposeCode, $transactionID);
$ncba = new Ncba();
$response = $ncba->pesalink($apiToken, $beneficiaryAccountNumber, $beneficiaryBankBIC, $beneficiaryName, $amount, $currency, $narration, $senderAccountNumber, $senderCIF, $senderCountry, $transactionID);
{
"Response Code":0,
"Reference":"FTC250124JEQT",
"Description":"Success"
}
{
"Response Code":11,
"Reference":"DUPLICATE | FTC210920APDH",
"Description":"ERROR"
}
{
"Code": "000",
"Description": "Success",
"Transaction": {
"Currency": "KES",
"Amount": "100",
"Date": "1/24/2025 12:37:21 PM",
"AccountNumber": "7810710012",
"Narrative": "Other",
"CustomerReference": "250124093719",
"CBSReference": "FTC250124JEQS",
"ThirdPartyReference": null,
"Status": "PASSED",
"ThirdPartyStatus": null
}
}
NCBA offers a two-step API request as follows:
/**
* ...
* @param $msisdn - the mobile number attached to the meter
*/
$ncba->kplcPostpaidValidation($apiToken, $meterNumber, $msisdn);
$ncba->kplcPostpaid($apiToken, $validationId, $customerName, $meterNumber, $msisdn, $channelRef, $amount, $callbackUrl, $accountNumber, $reason = '');
The Laravel NCBA package is open-sourced software licensed under the MIT license. See the LICENSE file for details.