PHPackages                             frog/cooperative-bank-sdk - 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. frog/cooperative-bank-sdk

ActiveLibrary

frog/cooperative-bank-sdk
=========================

This SDK makes requests to the cooperative bank API to enable easy integration

11PHP

Since Feb 26Pushed 5y agoCompare

[ Source](https://github.com/frogtechnologies/cooperative-bank-sdk)[ Packagist](https://packagist.org/packages/frog/cooperative-bank-sdk)[ RSS](/packages/frog-cooperative-bank-sdk/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Description
===========

[](#description)

[![Latest Version on Packagist](https://camo.githubusercontent.com/296f70175421c0b05669d2afc622d76cbc6a59f0f76461bc4fbf97edd8abe5cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66726f672f636f6f70657261746976652d62616e6b2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/frog/cooperative-bank-sdk)[![Build Status](https://camo.githubusercontent.com/50f03ab319a5161600460885627e03b849381ab487ada6e29678e883fbc147a1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f66726f672f636f6f70657261746976652d62616e6b2d73646b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/github/frogtechnologies/cooperative-bank-sdk)[![Total Downloads](https://camo.githubusercontent.com/7a008b976b01c1e34502d89628187b4b74b5beed712d4e241d4ac62f137a624c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66726f672f636f6f70657261746976652d62616e6b2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/frog/cooperative-bank-sdk)

An SDK to aid interaction with the Cooperative Bank API

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

[](#installation)

You can install the package via composer:

```
composer require frog/cooperative-bank-sdk
```

### Setup environment variables

[](#setup-environment-variables)

```
COOP_CONSUMER_KEY=
COOP_CONSUMER_SECRET=
COOP_API_BASE_URL=http://developer.co-opbank.co.ke:8280#Testing
# COOP_API_BASE_URL=https://developer.co-opbank.co.ke:8243 # Production
```

Usage
-----

[](#usage)

```
use FROG\CooperativeBankSdk\CooperativeBankSdk;
use FROG\CooperativeBankSdk\CoopUtils;

$coop_sdk = new CooperativeBankSDK();

/**
 * Generate an access token
 * NB: Not necessarily used anywhere as the SDK uses it internally to send requests
 *
 */
$access_token = $coop_sdk->generate_access_token();
print_r($access_token);
// {
//   "access_token": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
//   "scope": "am_application_scope default",
//   "token_type": "Bearer",
//   "expires_in": 3600
// }

/**
 * Check for the account balance
 *
 * The message reference is optional in the case the client has an internal unique referencing system
 * The SDK implements the php random_bytes function internally to generate a unique number
 * @param string $account_number the cooperative bank account number
 * @param void|string $message_reference an optional message reference
 */
// Option 1: Pass in your unique internal message reference (UUID's don't work though)
$balance = $coop_sdk->check_account_balance(
    "account-number",
    "message-reference",
);

// Or you could use the utility from the package to get a unique message reference before the request is made
$balance = $coop_sdk->check_account_balance(
    "account-number",
    CoopUtils::generate_message_reference(),
);

// Or let the sdk generate one internally and access the message reference from the response.
// All responses usually have message references
$balance = $coop_sdk->check_account_balance(
    "account-number",
);
print_r($balance);
// {
//   "MessageReference": "MESSAGE_REFERENCE_WILL_APPEAR_HERE",
//   "MessageDateTime": "2021-02-26 15:18:58",
//   "MessageCode": "0",
//   "MessageDescription": "Success",
//   "AccountNumber": "36001873000",
//   "AccountName": "JOE K. DOE",
//   "Currency": "USD",
//   "ProductName": "CURRENT ACCOUNT",
//   "ClearedBalance": "13706.07",
//   "BookedBalance": "75391.31",
//   "BlockedBalance": "27066.64",
//   "AvailableBalance": "21962.96",
//   "ArrearsAmount": "12645.56",
//   "BranchName": "GIGIRI MALL",
//   "BranchSortCode": "11151",
//   "AverageBalance": "27339.95",
//   "UnclearedBalance": "26658.48",
//   "ODLimit": "17614.28",
//   "CreditLimit": "23181.53"
// }

/**
 * Get the full & mini statement of an account
 * @param string $account_number an account number from a cooperative bank branch
 * @param string $start_date the date at which the earliest transaction is to be fetched
 * @param string $end_date the date at which the latest transction is to be fetched
 * @param string $message_reference a unique client generated string to be a reference when a request is sent
 * The message reference is optional in the case the client has an internal unique referencing system
 * The SDK implements the php random_bytes function internally to generate a unique number
*/
$statement = $coop_sdk->get_account_full_statement(
    "account-number",
    "start-date",
    "end-date",
    "message-reference",
);
$statement = $coop_sdk->get_account_mini_statement(
    "account-number",
    "start-date",
    "end-date",
    "message-reference",
);
print_r($statement);
// {
//   "MessageReference": "40ca18c6765086089a1",
//   "MessageDateTime": "2021-02-26 10:27:16",
//   "MessageCode": "0",
//   "MessageDescription": "Success",
//   "AccountNumber": "36001873000",
//   "AccountName": "JOE K. DOE",
//   "Transactions": [
//     {
//       "TransactionID": "50a603a3-2",
//       "TransactionDate": "2021-03-07 23:52:28",
//       "ValueDate": "2021-03-07 23:52:28",
//       "Narration": "Electricity payment",
//       "TransactionType": "D",
//       "ServicePoint": "POS-P0917",
//       "TransactionReference": "8be9b10d-4",
//       "CreditAmount": "0.00",
//       "DebitAmount": "72869.62",
//       "RunningClearedBalance": "22749.45",
//       "RunningBookBalance": "22749.45",
//       "DebitLimit": "0.00",
//       "LimitExpiryDate": "2021-03-07 00:00:00"
//     },
//     ...
//   ]
// }

/**
 * Retrieves the transactions of the specified account
 *
 * @param string $message_reference a unique client generated string to be a reference when a request is sent
 * @param string $account_number an account number from a cooperative bank branch
 * @param string $no_of_transactions a number of transactions to be retrieved (1 - 500)
 */
$transactions = $coop_sdk->get_account_transactions(
    "account-number",
    "no-of-transactions",
    "message-reference",
);
print_r($transactions);
// {
//   "MessageReference": "40ca18c6765086089a1",
//   "MessageDateTime": "2021-02-26 15:18:04",
//   "MessageCode": "0",
//   "MessageDescription": "Success",
//   "AccountNumber": "36001873000",
//   "AccountName": "JOE K. DOE",
//   "Transactions": [
//     {
//       "TransactionID": "fa24e510-c",
//       "TransactionDate": "2021-02-28 20:28:45",
//       "ValueDate": "2021-02-28 20:28:45",
//       "Narration": "Cash Deposit",
//       "TransactionType": "C",
//       "ServicePoint": "AGENT-10001",
//       "TransactionReference": "37e4a38d-9",
//       "CreditAmount": "97705.30",
//       "DebitAmount": "0.00",
//       "RunningClearedBalance": "172774.05",
//       "RunningBookBalance": "172774.05",
//       "DebitLimit": "0.00",
//       "LimitExpiryDate": "2021-02-27 00:00:00"
//     },
//     ...
//   ]
// }

/**
     * Retrieves the status of the specified transaction fetched by a message id
     * @param string $message_reference a unique client generated string to be a reference when a request is sent
     */
$status = $coop_sdk->check_transaction_status("message-reference");
print_r($status);
// {
//     "messageReference": "40ca18c6765086089a1",
//     "messageDateTime": "2021-02-26 15:23:32",
//     "messageCode": "0",
//     "messageDescription": "Full Success",
//     "source": {
//         "accountNumber": "36001873000",
//         "amount": "777",
//         "transactionCurrency": "KES",
//         "narration": "Supplier Payment",
//         "responseCode": "0",
//         "responseDescription": "Success"
//     },
//     "destination": {
//         "referenceNumber": "40ca18c6765086089a1_1",
//         "accountNumber": "54321987654321",
//         "amount": "777",
//         "transactionCurrency": "KES",
//         "narration": "Electricity Payment",
//         "transactionID": "cfea0f9d-c",
//         "responseCode": "0",
//         "responseDescription": "Success"
//     }
// }

/**
 * Retrieves the validity of the specified account
 *
 * @param string $account_number an account number from a cooperative bank branch
 * @param string $message_reference a unique client generated string to be a reference when a request is sent
 */
$status = $coop_sdk->validate_account("account-number", "message-reference");
print_r($status);
// {
//   "MessageReference": "BTVd6xr7vEX97hWgNqM",
//   "MessageDateTime": "2021-02-26 16:36:39",
//   "MessageCode": "0",
//   "MessageDescription": "VALID ACCOUNT NUMBER"
// }

/**
 * Retrieves the exhange rate for the day for a specific account
 *
 * @param string $from_currency a valid international currency
 * @param string $to_currency a valid international currency
 * @param string $message_reference a unique client generated string to be a reference when a request is sent
 */
$rate = $coop_sdk->exchange_rate("from-currency", "to-currency", "message-reference");
print_r($rate);
// {
//   "MessageReference": "40ca18c6765086089a1",
//   "MessageDateTime": "2021-02-26 20:31:31",
//   "MessageCode": "0",
//   "MessageDescription": "Success",
//   "FromCurrencyCode": "KES",
//   "ToCurrencyCode": "USD",
//   "RateType": "SPOT",
//   "Rate": "104.35",
//   "Tolerance": "6",
//   "MultiplyDivide": "D"
// }
```

### Testing

[](#testing)

`NB`: The primary development machine is windows, ensure to change the path in the composer.json script section to conform to the operating system

Tests are powered by [PestPHP](https://pestphp.com/)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Miller Adulu](https://github.com/milleradulu)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

PHP Package Boilerplate
-----------------------

[](#php-package-boilerplate)

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

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://www.gravatar.com/avatar/1e9627541639d5e64562039587a54aa9a0d35fcd13a7595a119012b20daae690?d=identicon)[FROG](/maintainers/FROG)

---

Top Contributors

[![MillerAdulu](https://avatars.githubusercontent.com/u/21357409?v=4)](https://github.com/MillerAdulu "MillerAdulu (55 commits)")

### Embed Badge

![Health badge](/badges/frog-cooperative-bank-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/frog-cooperative-bank-sdk/health.svg)](https://phpackages.com/packages/frog-cooperative-bank-sdk)
```

PHPackages © 2026

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