Tigo Push Pay API wrapper
Project description
tigopesasdk
TigoPesa API wrapper written in python
status
This library supports only push pay API at the moment
installation
pip install tigopesasdk
usage
import tigopesasdk as tigo
# stating the configurations
config = tigo.Config(
account_name="",
brand_id="",
token_url="",
password="",
biller_payment_url="",
biller_code="",
grant_type="password",
username="",
account_msisdn=""
)
# create a callback handler
class CustomCallbackHandler(tigo.CallbackHandler):
def __init__(self):
pass
def respond(self, request: tigo.CallbackRequest) -> tigo.CallbackResponse:
response = tigo.CallbackResponse(
response_code="",
reference_id="",
response_status=True,
response_description="",
)
return response
callback_handler = CustomCallbackHandler()
# creating a tigo client
client = tigo.TigoClient(
config,
callback_handler,
True
)
# form a bill request
bill_request = tigo.BillPayRequest(
reference_id="PYWWTWTW15151718191",
amount=10000,
remarks="mt first ever payment from command line tool",
customer_msisdn="0712XXXXXX",
)
# generate token from tigo
token_response = client.generate_token()
if token_response is not None:
print("access token: " + token_response.access_token)
print("token type: " + token_response.token_type)
print("expires date: " + token_response.expires_in)
bill_response = client.bill_with_token(token_response.access_token, bill_request)
print("response code " + bill_response.response_code)
print("response status" + str(bill_response.response_status))
print("response description " + bill_response.response_description)
print("reference id " + bill_response.reference_id)
# bill_with_token uses a pre generated token to initiate push pay request
# bill on the other hand request for token internally and use the response to
# initiate the push pay
bill_response = client.bill(bill_request)
if bill_response is not None:
print("response code " + bill_response.response_code)
print("response status" + str(bill_response.response_status))
print("response description " + bill_response.response_description)
print("reference id " + bill_response.reference_id)
LICENCE
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tigopesasdk-0.1.0.tar.gz
(4.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tigopesasdk-0.1.0.tar.gz.
File metadata
- Download URL: tigopesasdk-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
659bdbdfb1462743fd1bb77b964997376565c0333fb1c720f7494ec062d9f554
|
|
| MD5 |
61520bd3da55d58a0ca6ed8b584baee2
|
|
| BLAKE2b-256 |
610375c62d6dedff67c3bb0515ee6a71064a5a3dd9a265cc057bdc6cdaff0df3
|
File details
Details for the file tigopesasdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tigopesasdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c157ca524f94246c399e74373cef17b2cc9230cd9aa56f28acf93012e538989
|
|
| MD5 |
3410940f121b9e18da5069010a2a9221
|
|
| BLAKE2b-256 |
9edc51a7f2508b6fa1165a9d884e3f79bea298aa001c2db6531926662c75ee36
|