HOW TO USE THE COOPERATIVE BANK KENYA API USING JAVA

Isaac Sichangi
3 min readApr 13, 2021

--

cooperative bank Kenya

This is a Java wrapper for the cooperative bank coop connect api

Installation

clone or download from github using the link https://github.com/IsaacSichangi/cooperativebank-kenya-java-sdk

Requirements

  • Java 1.8 or later

Others

-Create an account at the coop connect developer portal and create an application in order to get your CONSUMER KEY and CONSUMER SECRET credentials also remember to subscribe to the APIS you would wish to use in the developer portal

Usage

Initialization

Bank bank = new Bank("CONSUMER KEY", "CONSUMER_SECRET", Constants.sandbox );

NB remember to change to Constants.live when going live

Account Balance

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

EXAMPLE

AccountBalance response = bank.getAccountBalance("MESSAGE REFERENCE", "ACCOUNT NUMBER");

Account Full Statement

Account Full Statement Enquiry API will enable you to enquire about your own Co-operative Bank accounts’ full statement for the specified account number, start date and end date

EXAMPLE

AccountFullStatement response = bank.getAccountFullStatement("MESSAGE REFERENCE", "ACCOUNT NUMBER", "STARTDATE", "ENDDATE");

Account Mini Statement

Account Mini Statement Enquiry API will enable you to enquire about your own Co-operative Bank accounts’ Mini statement for the specified account number

EXAMPLE

AccountMiniStatement response = bank.getAccountMiniStatement("MESSAGE REFERENCE", "ACCOUNT NUMBER");

Account Transactions

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

EXAMPLE

AccountTransactions response = bank.getAccountTransactions("MESSAGE REFERENCE", "ACCOUNT NUMBER", NUMBER OF TRANSACTIONS);

Account Validation

Account Validation Enquiry API will enable you to validate a Co-operative Bank account number

EXAMPLE

AccountValidation response = bank.validateAccount("MESSAGE REFERENCE", "ACCOUNT NUMBER" );

Exchange rate

Exchange Rate Enquiry API will enable you to enquire about the current SPOT exchange rate for the specified currencies

EXAMPLE

ExchangeRate response = bank.getExchangeRate("MESSAGE REFERENCE", "FROM CURRENCY CODE", "TO CURRENCY CODE" );

Internal Funds Transfer Account ToAccount

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)

EXAMPLE

ArrayList<DestinationIftAccountToAccount> list = new ArrayList<>();
list.add(new DestinationIftAccountToAccount("REFERENCE NUMBER", "ACCOUNT NUMBER","AMOUNT" , "TRANSACTION CURRENCY", "NARRATION"));
IftAccountToAccount response = bank.transferIftAccountToAccount("MESSAGE REFERENCE", "CALLBACK URL", new Source("ACCOUNT NUMBER", "AMOUNT", "TRANSACTION CURRENCY", "NARRATION"), list);

PesaLink To Account

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

EXAMPLE

ArrayList<DestinationPesaLinkToAccount> list = new ArrayList<>();
list.add(new DestinationPesaLinkToAccount("REFERENCE NUMBER", "ACCOUNT NUMBER","AMOUNT" , "TRANSACTION CURRENCY", "NARRATION"));
PesaLinkToAccount response = bank.transferFromPesaLinkToAccount("MESSAGE REFERENCE", "CALLBACK URL", new Source("ACCOUNT NUMBER", "AMOUNT", "TRANSACTION CURRENCY", "NARRATION"), list);

PesaLink To Phone

PesaLink Send to Phone Funds Transfer API will enable you to transfer funds from your own Co-operative Bank account to a Phone Number(s) linked to a Bank account in an IPSL participating bank

EXAMPLE

ArrayList<DestinationPesaLinkSendToPhone> list = new ArrayList<>();
list.add(new DestinationPesaLinkSendToPhone("REFERENCE NUMBER", "PHONENUMBER","AMOUNT" , "TRANSACTION CURRENCY", "NARRATION"));
PesaLinkSendToPhone response = bank.transferFromPesaLinkToPhone("MESSAGE REFERENCE", "CALLBACK URL", new Source("ACCOUNT NUMBER", "AMOUNT", "TRANSACTION CURRENCY", "NARRATION"), list);

Send To Mpesa

Send to M-Pesa Funds Transfer API will enable you to transfer funds from your own Co-operative Bank account to an M-Pesa account recipient

EXAMPLE

ArrayList<DestinationMpesa> list = new ArrayList<>();
list.add(new DestinationMpesa("REFERENCE NUMBER", "PHONENUMBER","AMOUNT" , "TRANSACTION CURRENCY", "NARRATION"));
SendToMpesa response = bank.sendToMpesa("MESSAGE REFERENCE", "CALLBACK URL", new Source("ACCOUNT NUMBER", "AMOUNT", "TRANSACTION CURRENCY", "NARRATION"), list);

Transaction Status

Transaction Status Enquiry API will enable you to enquire about the status of a previously requested transaction for the specified transaction message reference

EXAMPLE

TransactionStatus response = bank.checkTransactionStatus("MESSAGE REFERENCE");

Going Live

When ready to go live with your app/service send an email to E-ChannelsandE-commerce@co-opbank.co.ke indicating the intention to go live. A representative will send you test cases for your application to test out and a merchant form which you will have to fill out in corder to comply with KYC requirements. In addition they will whitelist your ip in order to enable you to receive call back requests for reconcilliation with your system.

Other SDKS

php

Help & Support

For any queries, help with integration or just general feedback 👍

-Email isaacsichangi@gmail.com

--

--