pesapal-py
A minimalist python library that integrates with PesaPal's API 3.0 - JSON APIs (https://developer.pesapal.com/how-to-integrate/e-commerce/api-30-json/api-reference).
This library abstracts PesaPals API 3.0 into four main methods, authenticate, register_ipn, transact and get_transaction_status
Getting started
Register as a merchant
- Register as a PesaPal merchant at https://www.pesapal.com/
- On successfull registration, you will receive a consumer key and consumer secret via email - keep these safe as they are your API credentials
Install pesapal-py
pip install pesapal-py
Authenticating
from pesapal_py.payments import PesaPal
pesapal = PesaPal("test_consumer_key", "test_consumer_secret")
auth = pesapal.authenticate()
print(auth)
This step returns a bearer token that is used with all the other methods below. The token expires after every 5 minutes. To prevent calling this method every time you need to transact, I recommend that you store it in an in-memory data store (e.g. redis) and expire it before 5 minutes.
Register IPN
register_ipn = pesapal.register_ipn("sample_token", "https://www.sample-url.com/ipn")
print(register_ipn)
Transact
transact = pesapal.transact(
token="sample_token",
description="sample_description",
transaction_id="sample_transaction_id",
amount=1000,
callback_url="https://www.callback-url.com/status",
ipn_id="sample_ipn_id",
email_address="sample@email-address.com",
phone_number="254722001122",
country_code="KE",
first_name="first",
last_name="last",
currency="KES",
)
print(transact)
Validate Transaction
transaction_status = pesapal.get_transaction_status(
token="sample_token", order_tracking_id="sample_order_tracking_id"
)
print(transaction_status)
Metadata
Release files for pesapal-py 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pesapal-py-0.1.3.tar.gz | 5.0 kB | Without provenance | Details for pesapal-py-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pesapal_py-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for pesapal_py-0.1.3-py3-none-any.whl |
Total release size: 10.4 kB
Release files / pesapal-py-0.1.3.tar.gz
| Download URL | pesapal-py-0.1.3.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6bcbc90f8cfa4400c892f48905c9dcc7d62d342212fe4f847d21b2da9f628961
|
|
BLAKE2b-256 checksum How to use checksums |
acd0d0d26172c3a0842ed4f25f4715b57761a70a40c58bb956b57eb05c0471ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Release files / pesapal_py-0.1.3-py3-none-any.whl
| Download URL | pesapal_py-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47bdbefcab1ecd2055ff8e2760b73e27aba4b9a54c13988d0041340f71c8f8f2
|
|
BLAKE2b-256 checksum How to use checksums |
20f0a40beb8a21469a6a090418cdf55a6197b8b4413ee77d656405d82083f6a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Security for pesapal-py 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.