PHP code example of akika / laravel-ncba

1. Go to this page and download the library: Download akika/laravel-ncba library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

akika / laravel-ncba example snippets


use Akika\LaravelNcba\Ncba;

$ncba = new Ncba();
$ncba = new Ncba($bankCode, $branchCode, $country, $currency);

$bankCode # Bank specific code
$branchCode # Branch specific code
$country # Country name in full e.g. Kenya
$currency # Currency code e.g. KES

$ncba = new Ncba();
$ncba->checkApiHealth();

$ncba = new Ncba();
$response = $ncba->checkTransactionStatus($referenceNumber);

{
    "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 = new Ncba();
$response = $ncba->mpesaNumberValidation($phoneNumber, $reference);

$ncba = new Ncba($bankCode, $branchCode, $country, $currency);

$response = $ncba->ift($account, $beneficiaryAccountName, $amount, $narration, $reference);

$ncba = new Ncba($bankCode, $branchCode, $country, $currency);

$response = $ncba->eft($account, $beneficiaryAccountName, $amount, $narration, $reference);

$ncba = new Ncba($bankCode, $branchCode, $country, $currency);

$response = $ncba->rtgs($account, $beneficiaryAccountName, $amount, $purposeCode, $narration, $reference);

$ncba = new Ncba($bankCode, $branchCode, $country, $currency);

$response = $ncba->pesalink($account, $beneficiaryAccountName, $amount, $narration, $reference);

$ncba = new Ncba($bankCode, $branchCode, $country, $currency);

$response = $ncba->mpesa($account, $beneficiaryAccountName, $amount, $transactionId, $narration, $reference);

{
    "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
    }
}
bash
php artisan ncba:install