Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Intuitive Python SDK for the Co-operative Bank of Kenya developer APIs.
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.
# In terminal do:
$ pip install pytekcoopbank
$ git clone https://github.com/TralahM/pytekcoopbank.git
$ cd pytekcoopbank
$ python setup.py install
import tekcoopbank
config=dict(
env = "sandbox",
consumerKey = "ss0sD2ANhjvhx_rHU0a6Xf8ROdYa",
consumerSecret = "zOfReXCIwn1TfnEYJJJGNP6l3Tka",
accountNumber = "54321987654321",
bankCode = "011",
branchCode = "00011001",
callbackURL = "/coop/callback",
transactionCurrency = "KES",
)
COOP=tekcoopbank.setup_coop(config)
By default all methods return a requests.HTTPResponse
object. To get a python
dict
you can pass a callback to the send functions.
callback=lambda x: x.json()
balance=COOP.balance.send(messageReference,accountNumber=None,callback=None)
{
"MessageReference": "wotfhPpsbxWY",
"MessageDateTime": "2020-10-05 06:20:01",
"MessageCode": "-8",
"MessageDescription": "ACCOUNT AUTHORIZATION FAILURE"
}
transactions=COOP.transactions.send(messageReference,accountNumber,NoOfTransactions=2,callback=None)
{
"MessageReference": "kRaiNxCTtgbV",
"MessageDateTime": "2020-10-05 06:20:09",
"MessageCode": "-8",
"MessageDescription": "ACCOUNT AUTHORIZATION FAILURE"
}
mini_statement=COOP.mini_statement.send(messageReference,accountNumber,callback=None)
{
"MessageReference": "xdpdBdEdCdYdAdOdudtdDdw",
"MessageDateTime": "2020-10-05 07:45:54",
"MessageCode": "-8",
"MessageDescription": "ACCOUNT AUTHORIZATION FAILURE"
}
full_statement=COOP.full_statement.send(messageReference,accountNumber,callback=None)
{
"MessageReference": "MdKdNdYdzdAdydQdtdpdedH",
"MessageDateTime": "2020-10-05 07:45:59",
"MessageCode": "-8",
"MessageDescription": "ACCOUNT AUTHORIZATION FAILURE"
}
validation=COOP.validation.send(messageReference,accountNumber,callback=None)
{
"MessageReference": "eDyClhTgirbw",
"MessageDateTime": "2020-10-05 06:33:04",
"MessageCode": "-1",
"MessageDescription": "INVALID ACCOUNT NUMBER"
}
exchange_rate=COOP.exchange_rate.send(messageReference,
fromCurrencyCode="KES",
toCurrencyCode="USD",
callback=None)
{
"MessageReference": "HdKdAdidLdtdGdadFdydxdS",
"MessageDateTime": "2020-10-05 07:33:16",
"MessageCode": "0",
"MessageDescription": "Success",
"FromCurrencyCode": "KES",
"ToCurrencyCode": "USD",
"RateType": "SPOT",
"Rate": "104.35",
"Tolerance": "23",
"MultiplyDivide": "D"
}
ift_to_account=COOP.ift_to_account.send(messageReference,
accountNumber,
amount,
transactionCurrency="KES",
narration="Payment",
destinations=[{},],
callback=None)
{
"MessageReference": "sdkdddIdUdndpdxdcdedodr",
"MessageDateTime": "2020-10-05T06:10:29",
"MessageCode": "-5",
"MessageDescription": "DEBIT AND CREDITS AMOUNTS NOT BALANCING"
}
pesalink_to_account=COOP.pesalink_to_account.send(messageReference,
accountNumber,
amount,
transactionCurrency="KES",
narration="Payment",
destinations=[{},],
callback=None)
{
"MessageReference": "rdhdjdvdYdKdidkdQdFdDdg",
"MessageDateTime": "2020-10-05T07:10:05",
"MessageCode": "-5",
"MessageDescription": "DEBIT AND CREDIT(S) AMOUNTS NOT BALANCING"
}
pesalink_to_phone=COOP.pesalink_to_phone.send(messageReference,
phoneNumber,
amount,
transactionCurrency="KES",
narration="Payment",
destinations=[{},],
callback=None)
{
"MessageReference": "tdUdXdOdJdVdgdsdNdddhdw",
"MessageDateTime": "2020-10-05T07:10:09",
"MessageCode": "-5",
"MessageDescription": "DEBIT AND CREDIT(S) AMOUNTS NOT BALANCING"
}
to_mpesa=COOP.to_mpesa.send(messageReference,
mobileNumber,
amount,
transactionCurrency="KES",
narration="Payment",
destinations=[{},],
callback=None)
{
"MessageReference": "gdBdJdPdudOdpdLdndidrdj",
"MessageDateTime": "2020-10-05T07:10:13",
"MessageCode": "-5",
"MessageDescription": "DEBIT AND CREDIT(S) AMOUNTS NOT BALANCING"
}
transaction_status=COOP.transaction_status.send(messageReference,callback=None)
{
"MessageReference": "XHJaVzZGOsjB",
"MessageDateTime": "2020-10-05 06:20:06",
"MessageCode": -13,
"MessageDescription": "MESSAGE REFERENCE DOES NOT EXIST",
"Source": {
"AccountNumber": null,
"Amount": null,
"TransactionCurrency": null,
"Narration": null,
"ResponseCode": null,
"ResponseDescription": null
},
"Destinations": null
}
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
FAQs
"Unofficial Co-operative Bank of Kenya API Python SDK."
We found that pytekcoopbank demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.