pesapal
Unofficial SDK wrapper for the pesapal v3 payments API.
Requirements
- python version >= 3.8
Installation
pip install pesapal-v3
Usage
from pesapal_v3 import Pesapal
client = Pesapal(consumer_key, consumer_secret)
Supported endpoints
Register IPN
ipn_url = "https://example.com/ipn/notifications"
ipn = client.register_ipn_url(ipn_url=ipn_url)
if ipn.status != "200":
# error occured registering your IPN
print(ipn.error)
else:
# IPN successfully registered
print(ipn)
List registered IPNs
ipns = client.get_registered_ipns()
print(ipns)
Submit order request
order_request = {
"id": "s945e4af-80a5-4ec1-8706-e03f8332fb04",
"currency": "KES",
"amount": 350.00,
"description": "Thank you for this SDK",
"callback_url": "https://example.com/cancellation",
"notification_id": "fe078e53-78da-4a83-aa89-e7ded5c456e6",
"billing_address": {
"email_address": "john.doe@example.com",
"phone_number": "0723xxxxxx",
"country_code": "KE",
"first_name": "John",
"middle_name": "",
"last_name": "Doe",
"line_1": "Pesapal Limited",
"line_2": "",
"city": "",
"state": "",
"postal_code": "",
"zip_code": ""
}
}
request = client.submit_order_request(order_request=order_request)
Transaction status
status = client.get_transaction_status(order_tracking_id="b945e4af-80a5-4ec1-8706-e03f8332fb04")
Subscriptions
order_request = {
"id": "s945e4af-80a5-4ec1-8706-e03f8332fb04",
"currency": "KES",
"amount": 350.00,
"description": "Thank you for this SDK",
"callback_url": "https://example.com/cancellation",
"notification_id": "fe078e53-78da-4a83-aa89-e7ded5c456e6",
"billing_address": {
"email_address": "john.doe@example.com",
"phone_number": "0723xxxxxx",
"country_code": "KE",
"first_name": "John",
"middle_name": "",
"last_name": "Doe",
"line_1": "Pesapal Limited",
"line_2": "",
"city": "",
"state": "",
"postal_code": "",
"zip_code": ""
},
"account_number": "555-678",
"subscription_details": {
"start_date": "24-01-2023",
"end_date": "31-12-2023",
"frequency": "DAILY"
}
}
request = client.submit_order_request(order_request=order_request, is_subscription=True)
print(request)
Refund
refund =
{
"confirmation_code": "AA11BB22",
"amount": "100.00",
"username": "John Doe",
"remarks": "Service not offered"
}
client.refund(refund)
Support
For any issues, bugs you can raise an issue on the project issues board.
For compliments and gigs you can reach out to the developer via email martinmshale@gmail.com.
For service level issues, reach out to Pesapal.
Lastly, I need the developer juice to produce more of these open source solutions. Be among the few who have supported these effort by buying me a coffee.
Metadata
Release files for pesapal-v3 1.0.0
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_v3-1.0.0.tar.gz | 7.0 kB | Without provenance | Details for pesapal_v3-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pesapal_v3-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pesapal_v3-1.0.0-py3-none-any.whl |
Total release size: 14.5 kB
Release files / pesapal_v3-1.0.0.tar.gz
| Download URL | pesapal_v3-1.0.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd77557f3dec5626cf2202136fb830c58c8e7118fd1118beae0b857f6d609f11
|
|
BLAKE2b-256 checksum How to use checksums |
cc94962d4a70c63be53b602d0225492a7b0d9661de597a3b26eafe40bf148e35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.17
|
Release files / pesapal_v3-1.0.0-py3-none-any.whl
| Download URL | pesapal_v3-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
286029f960478415d7c1c20473deee3921b9e97990cd61f0d9ab72fe045569e3
|
|
BLAKE2b-256 checksum How to use checksums |
8360289efdc3f91cd948da8bca186e50b4679dee5387e54c8624c31897fbae96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.17
|
Security for pesapal-v3 1.0.0
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.