A python package to easy push payment integration with Tola Payments with Mpesa, TigoPesa, and AirtelMoney Tanzania
Project description
Tola Payments Python Package
A python package to easy push payment integration with Tola Payments with Mpesa, TigoPesa, and AirtelMoney Tanzania. You can easily charge a customer's phone number with a specified amount, and the package will handle the necessary details to make the payment using the Tola Mobile API. No need to integrate each MNO individualy.
Installation
Use the package manager pip to install Tola Payments package.
Installation To install the Tola Payments package, run the following command:
pip install tola_payments
Configuration
To use the package, you need to set up your Tola Mobile API credentials in a .env file. Add the following variables to your .env file: To use the Tola Payments package, you first need to import it into your Python code. Here's an example:
TOLA_USERNAME = "my_username"
TOLA_PASSWORD = "my_password"
VODA_TARGET = "my_voda_target"
TIGO_TARGET = "my_tigo_target"
AIRTEL_TARGET = "my_airtel_target"
TOLA_LIVE_URL = "my_tola_live_url"
Next, create an instance of the TolaPayments class, providing your Tola Mobile API credentials:
from tolapyments import TolaPayments
tolapayments = TolaPayments(is_sandbox=True)
Note that the is_sandbox parameter specifies whether you're using the Tola Mobile sandbox environment or the live environment. If you're using the sandbox environment, set is_sandbox to True. Otherwise, set it to False and provide the live API URL via the TOLA_LIVE_URL environment variable.
To charge a customer, call the charge_customer method on your TolaPayments instance, passing in the customer's phone number, the amount to charge, and a source reference
response =tolapayments.charge_costomer(amount="1000",phone_number="+25561189850", sourcereference='4546f56543poF66')
print(response.text)
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tola_payments-1.0.1.tar.gz
.
File metadata
- Download URL: tola_payments-1.0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb3168f39d024c638d73f01e1a4ea1ed2d15d0a134ca9ad13de1a75eb74b3a0b |
|
MD5 | a7ba30bb54c1a8bd9e1a4ad3ac9c332c |
|
BLAKE2b-256 | 87650ae251bcf2dbd0be4e6593db66a101ac1d7bf61a619d4c22b0d290f7040e |
File details
Details for the file tola_payments-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: tola_payments-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 969613fe91d1cb46beb72d9d0a2f3d21cf62271b3c2c12fbc3cd34039fa63c4a |
|
MD5 | b6f3786ebc237639463cf2700cc6dcc2 |
|
BLAKE2b-256 | e416c7db536ab77269effd2b518db51261326da825073ad07c4c93a594a9c6df |