Skip to main content

Pytest CI codecov Maintainability

JengaAPIPythonWrapper

A simple python wrapper around the JengaAPI from Equity Bank

Setup

Installation

pip install python-jengaapi

A sample of the .env variables required include:

MERCHANT_CODE=1234567
CONSUMER_SECRET=XXXXXXXXXXXXX
API_KEY=123XXX222
ACCOUNT_NAME=John Doe
ACCOUNT_NUMBER=12345678
CURRENCY_CODE=KES
COUNTRY_CODE=KE
FOREIGN_CURRENCY_CODE=USD
PRIVATE_KEY_PATH=path_to_privatekey.pem

Authorization Service

Fetch Authorization token

# script.py
from jengaapi.configs.config import app_config
from jengaapi.services.authorization_service import AuthorizationService

uat_config = app_config.get('uat')

# Get the environment variables
MERCHANT_CODE = uat_config.MERCHANT_CODE
CONSUMER_SECRET = uat_config.CONSUMER_SECRET
COUNTRY_CODE = os.getenv('COUNTRY_CODE')
ACCOUNT_NUMBER = os.getenv('ACCOUNT_NUMBER')


auth = AuthorizationService(config=uat_config)
auth_token = auth.auth_token
print(auth_token)
$ python script.py
Bearer eexxxxx.xx.xxxxxx

Account Service

Fetch Account Balance

account_service = AccountServices(config=uat_config)
# Get account balance
signature = auth.signature((COUNTRY_CODE, ACCOUNT_NO))
account_balance = account_service.account_balance(signature, auth_token, COUNTRY_CODE, ACCOUNT_NO)
print(account_balance)
$ python script.py
{
   "status":true,
   "code":0,
   "message":"success",
   "data":{
      "balances":[
         {
            "amount":"485115080.54",
            "type":"Available"
         },
         {
            "amount":"485115080.54",
            "type":"Current"
         }
      ],
      "currency":"KES"
   }
}

Fetch Account Mini Statement

account_service = AccountServices(config=uat_config)
signature = auth.signature((COUNTRY_CODE, ACCOUNT_NO))
account_mini_statement = account_service.account_mini_statement(signature, auth_token, COUNTRY_CODE, ACCOUNT_NO)
print(account_mini_statement)
{
   "status":true,
   "code":0,
   "message":"success",
   "data":{
      "balance":484837600.0,
      "currency":"KES",
      "accountNumber":"1450160649886",
      "transactions":[
         {
            "date":"2023-01-12T00:00:00.000",
            "amount":"1",
            "description":"JENGA CHARGE CREDIT 673579628084879",
            "chequeNumber":"None",
            "type":"Credit"
         },
         {
            "date":"2023-01-12T00:00:00.000",
            "amount":"1",
            "description":"JENGA CHARGE DEBIT 673579628084879",
            "chequeNumber":"None",
            "type":"Debit"
         },
         {
            "date":"2023-01-12T00:00:00.000",
            "amount":"1",
            "description":"JENGA CHARGE CREDIT 673579623845546",
            "chequeNumber":"None",
            "type":"Credit"
         },
         {
            "date":"2023-01-12T00:00:00.000",
            "amount":"1",
            "description":"REV-(673540528125447)JENGA CHARGE DEBIT 6735405275",
            "chequeNumber":"None",
            "type":"Debit"
         }
      ]
   }
}

Fetch Account Opening and Closing Balance

ep_signature = auth.signature((ACCOUNT_NO, COUNTRY_CODE, "2023-01-01"))
payload = dict(
    countryCode=COUNTRY_CODE,
    accountId=ACCOUNT_NO,
    date="2023-01-01",
)
opening_closing = account_service.opening_closing_account_balance(ep_signature, auth_token, **payload)
print(opening_closing)
{
   "status":true,
   "code":0,
   "message":"success",
   "data":{
      "balances":[
         {
            "amount":"0",
            "type":"Closing Balance"
         },
         {
            "amount":"0",
            "type":"Opening Balance"
         }
      ]
   }
}

Send Money Service

Send within Equity

send_money_service = SendMoneyService(config=uat_config)
payload = {
    "source": {
        "countryCode": COUNTRY_CODE,
        "name": "CATHERINE MURANDITSI MUKABWA",
        "accountNumber": ACCOUNT_NO
    },
    "destination": {
        "type": "bank",
        "countryCode": "KE",
        "name": "Tom Doe",
        "accountNumber": "0250163591202"
    },
    "transfer": {
        "type": "InternalFundsTransfer",
        "amount": "1000.00",
        "currencyCode": "KES",
        "reference": "692494625798",
        "date": "2023-08-18",
        "description": "some remarks here"
    }
}
ep_signature = auth.signature((ACCOUNT_NO,"1000.00", "KES", "692494625798"))
send_money_within_equity = send_money_service.send_within_equity(ep_signature, auth_token, **payload)
print(send_money_within_equity)
{
  "status": true,
  "code": 0,
  "message": "success",
  "data": {
    "transactionId": "54154",
    "status": "SUCCESS"
  }
}

Send to mobile wallets

payload = {
    "source": {
        "countryCode": "KE",
        "name": "CATHERINE MURANDITSI MUKABWA",
        "accountNumber": ACCOUNT_NO
    },
    "destination": {
        "type": "mobile",
        "countryCode": "KE",
        "name": "A N.Other",
        "mobileNumber": "0722123456",
        "walletName": "Mpesa"
    },
    "transfer": {
        "type": "MobileWallet",
        "amount": "1000",
        "currencyCode": "KES",
        "date": "2023-01-13",
        "description": "some remarks here"
    }
}
ep_signature = auth.signature(("1000", "KES", "692494625799", ACCOUNT_NO))
send_money_within_equity = send_money_service.send_to_mobile_wallets(ep_signature, auth_token, **payload)
print(send_money_within_equity)
{
    "status": true,
    "code": 0,
    "message": "success",
    "data": {
      "transactionId": "",
      "status": "SUCCESS"
    }
}

Jenga API docs

For official documentatio the Equity bank api refer here

Metadata

Release files for python-jengaapi 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-jengaapi 2.0.1
File Size Uploaded
python-jengaapi-2.0.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-jengaapi 2.0.1
File Interpreter ABI Platform
python_jengaapi-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.5 kB

Release files / python-jengaapi-2.0.1.tar.gz

Download URL python-jengaapi-2.0.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ee15903c1d598622fbdfd58aa32b2caf23f0d8eaff6b9d08db6eac81b0c2d8e0
BLAKE2b-256 checksum
How to use checksums
b26429eb3428f0c2f01e39d391fa1df40a32b62bb63356b7e8f087721af83e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.6

Release files / python_jengaapi-2.0.1-py3-none-any.whl

Download URL python_jengaapi-2.0.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c983c767e01010fd53d5e9211fd05bc6f2a9690205f3a0b6e317f56e8b7b706
BLAKE2b-256 checksum
How to use checksums
de99178da604b8b1dc470b4e6c2b9fffe7164b4818cb7f80413a5e265136b978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.6

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page