Intuitive PHP SDK Co-operative Bank Kenya API
Create or login to your account at https://developer.co-opbank.co.ke:9443/store/
On the left panel, you can see a list of menus. Click on Applications to access the list of available applications in which case you can choose to use the default ones or create your own.
- Select the application or create your own application using steps described earlier.
- Click “Subscribe”. A pop up message appears as shown:
- Click on “Applications” on the left panel.
- Choose the application for which you want to generate keys
- Choose the appropriate environment from the tabs(production or sandbox ).
- Specify Callback URL and then click “Generate keys”. Leave other fields have default values;
Install via composer by typing in your terminal
composer require osenco/co-op
If you dont use composer you can just download this library from the releases, unzip it in your project and include the autoload.php file in your project.
require_once('path/to/autoload.php');
Use the coopSetup
helper function to configure and instantiate our object
$config = array(
"env" => "sandbox",
"consumerKey" => "ss0sD2ANhjvhx_rHU0a6Xf8ROdYa",
"consumerSecret" => "zOfReXCIwn1TfnEYJJJGNP6l3Tka",
"accountNumber" => "54321987654321",
"bankCode" => "011",
"branchCode" => "00011001",
"callbackURL" => "/coop/callback",
"transactionCurrency" => "KES",
);
coopSetup($config);
We recommend using the following helper functions
Account Balance Enquiry API will enable you to enquire about your own Co-operative Bank accounts' balance as at now for the specified account number
$response = coopAccountBalance(
$messageReference,
$accountNumber = null,
$callback = null
);
Account Transactions Enquiry API will enable you to enquire about your own Co-operative Bank accounts' latest transactions for the specified account number and number of transactions to be returned
$response = coopAccountTransactions(
$messageReference,
$accountNumber,
$NoOfTransactions = '1',
$callback = null
);
Exchange Rate Enquiry API will enable you to enquire about the current SPOT exchange rate for the specified currencies
$response = coopExchangeRate(
$messageReference,
$fromCurrencyCode = 'KES',
$toCurrencyCode = 'USD',
$callback = null
);
Internal Funds Transfer Account to Account API will enable you to transfer funds from your own Co-operative Bank account to other Co-operative Bank account(s)
$response = coopIFTAccountToAccount(
$messageReference,
$accountNumber,
$amount,
$transactionCurrency = 'KES',
$narration = 'Payment',
$destinations = array(),
$callback = null
);
PesaLink Send to Account Funds Transfer API will enable you to transfer funds from your own Co-operative Bank account to Bank account(s) in IPSL participating banks
$response = coopPesaLinkSendToAccount(
$messageReference,
$accountNumber,
$amount,
$transactionCurrency = 'KES',
$narration = 'Payment',
$destinations = array(),
$callback = null
);
This is a Transaction Status Enquiry Request interface called by an API consumer to APIM to enquire the status of an earlier requested transaction.
$response = coopTransactionStatus(
$messageReference,
$callback = null
);
The last OPTIONAL argument in the functions above ($callback
) allows you to add a callable function to process the API responses. You can either pass a defined function or a closure
function processCoopTransactionStatus($response) {
// Do something with $response
}
$response = coopTransactionStatus($messageReference, 'processCoopTransactionStatus');
$response = coopTransactionStatus($messageReference, function ($response) {
// Do something with $response
});
Use the coopReconcile()
helper function at your callback URL endpoint to process responses from the API, optionally passing a callable function to process the API responses. You can either pass a defined function or a closure
function processCoopTransactionStatusResponse($response) {
// Do something with $response
}
$response = coopReconcile('processCoopTransactionStatusResponse');
$response = coopReconcile(function ($response) {
// Do something with $response
});
As a developer, the test cases will be available to you for download as you are creating the sandbox app.
The test cases are in place to ensure that you have well understood the API structure for requests and responses for our different APIs. These test cases are in an excel spreadsheet that you should fill in with the results from each of the test scenarios that you want to consume.
As the Test cases will cover all the APIs available, you will only be required to carry out the test cases for the APIs you had initially selected.
Once you have already tried out the APIs on our platform and have tested these against our test cases provided, you can make a formal request to go to production.
You will need to have the test cases duly filled, then send an email request, together with these filled in test cases, to our support team who will guide you on the next steps to enable you to get to production.
Send the email request and the test cases to digitalbanking@co-opbank.co.ke