Skip to main content

A thin async wrapper of MPESA daraja API.

Project description

aiompesa

A package for accessing the MPESA Daraja API from asyncio.

Usage

import asyncio
from aiompesa import Mpesa

CONSUMER_KEY = "nF4OwB2XiuYZwmdMz3bovnzw2qMls1b7"
CONSUMER_SECRET = "biIImmaAX9dYD4Pw"

loop = asyncio.get_event_loop()
mpesa = Mpesa(True, CONSUMER_KEY, CONSUMER_SECRET)

token_response = loop.run_until_complete(mpesa.generate_token())

access_token = token_response.get("access_token", None)
expires_in = token_response.get("expires_in", None)
if access_token is None:
    print("Error: Wrong credentials used to get the access_token")
else:
    print(f"access_token = {access_token}, expires_in = {expires_in} secs")

Requirements

  • Python 3.6+

Installation

$ pip install aiompesa

Motivation

  • To learn a little more about asyncio and put it to some practise.
  • To develop an async wrapper for the Safaricom daraja api.

Contribution

Follow the contribution guidelines

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aiompesa, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size aiompesa-0.0.4-py2-none-any.whl (8.2 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size aiompesa-0.0.4.tar.gz (7.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page