akika / laravel-ncba
The Laravel NCBA package allows you to transfer money through the NCBA Open Banking APIs. The package supports Laravel version 5 and above.
Requires
- php: ^8.0|^8.1|^8.2
- guzzlehttp/guzzle: ^7.5
- illuminate/http: ^8.0 | ^9.0 | ^10.0 | ^11.0
- illuminate/support: ^8.0 | ^9.0 | ^10.0 | ^11.0
README
The Laravel NCBA package allows you to transfer money through the NCBA Open Banking APIs. The package supports Laravel version 5 and above.
Installation
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.
.env file Setup
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_API_KEY= # You will reveive this key after you are fully onboarded onto NCBA Online Banking API.
Package Upgrade
To upgrade Laravel NCBA Package to the latest version, run the following command
composer update akika/laravel-ncba
Usage
Initialize NCBA
use Akika\LaravelNcba\Ncba; $ncba = new Ncba($apiKey, $username, $password);
- The above variables will be provided by NCBA during onboarding.
Authentication
An AP token is required to authenticate and use NCBA API's. Below is how to authenticate.
$ncba->authenticate();
Account Details
Gets account details including account balance.
$ncba->accountDetails($apiToken, $countryCode, $accountNo);
Mini Statement
Gets a mini statement for the account
$ncba->miniStatement($apiToken, $countryCode, $accountNo);
Account Statement
Gets an account statement based on the the specified period of time. The date format is 'ddmmyyyy'
$ncba->accountStatement($apiToken, $countryCode, $accountNo, $fromDate, $toDate);
Check Transaction Status
$ncba = new Ncba(); $response = $ncba->checkTransactionStatus($apiToken, $countryCode, $transactionID);
Success Response
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" }
Send Money to Another NCBA Customer (Internal Transfer)
$ncba = new Ncba($apiKey, $username, $password); $response = $ncba->ift($apiToken, $country, $transactionID, $beneficiaryAccountNumber, $beneficiaryAccountName, $senderAccountNumber, $currency, $amount $narration);
IFT Payment rules
- The following rules apply when using the Laravel NCBA package
- Transaction can be settled in all major currencies, i.e. KES, UGX, TZS, RWF, EUR, GBP & USD.
- Settlement is immediate; real-time.
- Payments will be within country of origin, local b2b.
- Minimum payments of KES. 50 or its equivalent in other currency, no limit on Maximum payment.
- Transactions processing is 24/7 – 365, including weekends and public holidays.
Send Money to a Non-NCBA Customer (External Transfer)
$ncba = new Ncba($apiKey, $username, $password); $response = $ncba->eft($apiToken, $amount, $beneficiaryAccountNumber, $beneficiaryBankBic, $beneficiaryName, $currency, $senderAccountNumber, $narration, $senderCountry, $transactionID, $senderCIF);
EFT payment rules.
- Transaction can be settled in only in local currency, KES, UGX, TZS & RWF.
- Settlement is processed T+ 1 day.
- Payments will be within country of origin, local b2b.
- Minimum payments of KES. 50 or its equivalent in other currency and a maximum of KES. 999,999 or it’s equivalent in other local currency.
- Transactions processing is only on working days, Monday – Friday, excluding Weekends and Public Holidays.
Send Money via RTGS (External Transfer)
$ncba = new Ncba($apiKey, $username, $password); $response = $ncba->rtgsrtgs($apiToken, $beneficiaryAccountNumber, $beneficiaryBankBIC, $beneficiaryCountry, $beneficiaryName, $creditAmount, $creditCurrency, $debitCurrency, $narration, $senderAccountNumber, $senderCIF, $senderCountry, $purposeCode, $transactionID);
Payment Rules
- The following rules apply when using the Laravel NCBA package
- Transaction settled in KES, USD,GBP,EUR,TZS,UGX & RWF.
- Settlement is T+ 3hours on a working day, typically Monday – Friday before 15.00 HRS EAT.
- Payments will be within Country of Origin.
- Minimum payments of KES. 50 or its equivalent in any other acceptable currency with no maximum CAP.
- Purpose of Payment Code (POP) will be required for all outgoing payments - The list of POP codes to be maintained to be shared during onboarding.
Send Money via Pesalink (External Transfer)
$ncba = new Ncba($apiKey, $username, $password); $response = $ncba->pesalink($apiToken, $beneficiaryAccountNumber, $beneficiaryBankBIC, $beneficiaryName, $amount, $currency, $narration, $senderAccountNumber, $senderCIF, $senderCountry, $transactionID);
Pesalink payment rules
- Transaction settled in KES only.
- Settlement is processed immediately.
- Payments will be within Kenya only.
- Minimum payments of KES. 50 or its equivalent in other currency and a maximum of KES. 999,999 or it’s equivalent in other local currency.
- Payments are settled 24/7-365, including weekends and public holidays.
Sample Responses
Successful Transaction Sample Response
{ "Response Code":0, "Reference":"FTC250124JEQT", "Description":"Success" }
Unsuccessful Transaction Sample Response
{ "Response Code":11, "Reference":"DUPLICATE | FTC210920APDH", "Description":"ERROR" }
Transaction Status API Response
{ "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 } }
License
The Laravel NCBA package is open-sourced software licensed under the MIT license. See the LICENSE file for details.