RohoPay Python SDK
Official Python SDK for RohoPay — mobile-money (MTN, Airtel, M-Pesa) and card (Visa, Mastercard) payments across East Africa.
Install
pip install rohopay
Quick start
import os
import uuid
from rohopay import RohoPay
client = RohoPay(api_key=os.environ["ROHOPAY_API_KEY"])
tx = client.collect(
phone="256700123456",
amount=50000,
currency="UGX",
description="Order #1001",
callback_url="https://your-app.com/webhooks/rohopay",
idempotency_key=str(uuid.uuid4()), # optional; auto-generated if omitted
)
print(tx.internal_reference, tx.status)
card = client.checkout(
amount=75000,
customer_name="Jane Mukasa",
customer_email="jane@example.com",
return_url="https://your-app.com/checkout/return",
card_number="4111111111111111",
card_expiry="10/26",
card_cvv="123",
)
# redirect the user to card.payment_url (card is a CheckoutResult)
Methods
| Method | Endpoint |
|---|---|
collect(...) |
POST /api/v1/collect |
disburse(...) (live mode only) |
POST /api/v1/disburse |
checkout(...) |
POST /api/v1/checkout |
get_transaction(reference) |
GET /api/v1/transactions/:reference |
list_transactions(**params) |
GET /api/v1/transactions |
iter_transactions(**params) |
generator, auto-paginates list_transactions |
get_balance() |
GET /api/v1/wallet/balance → Balance |
verify_webhook(body, sig, secret) |
— |
construct_event(body, sig, secret, tolerance_seconds=300) |
— |
Errors
All errors subclass rohopay.RohoPayError and carry status, code, and
request_id:
AuthenticationError (401), InvalidRequestError (400/404/422),
IdempotencyError (409), RateLimitError (429), APIError (>=500),
APIConnectionError (network/timeout), SignatureVerificationError (webhooks).
from rohopay import RohoPay, APIError
try:
client.collect(phone="...", amount=1000)
except APIError as e:
print(e.status, e.code, e.request_id)
Verify webhooks
import os
raw_body = request.get_data(as_text=True)
signature = request.headers.get("X-RohoPay-Signature", "")
if not client.verify_webhook(raw_body, signature, os.environ["ROHOPAY_WEBHOOK_SECRET"]):
return "invalid signature", 401
# Or parse + verify in one step (raises SignatureVerificationError):
event = client.construct_event(raw_body, signature, os.environ["ROHOPAY_WEBHOOK_SECRET"])
The gateway signs outgoing webhooks automatically with the
X-RohoPay-Signatureheader (sha256=<HMAC-SHA256 of raw body>). Your webhook secret isHMAC(APP_SECRET, "webhook:<userID>")— fetch it from Dashboard → Webhooks (thewebhook_secretfield) and pass it as thesecretargument.
Constants
TransactionStatus, PaymentMethod, TransactionType, Environment enums,
CURRENCIES, LIVE_BASE_URL, SANDBOX_BASE_URL, WEBHOOK_SIGNATURE_HEADER,
and rohopay.__version__ (1.1.3).
Metadata
Release files for rohopay 1.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 |
|---|---|---|---|---|
| rohopay-1.1.3.tar.gz | 10.5 kB | Without provenance | Details for rohopay-1.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rohopay-1.1.3-py3-none-any.whl | Python 3 | none | any | Details for rohopay-1.1.3-py3-none-any.whl |
Total release size: 17.9 kB
Release files / rohopay-1.1.3.tar.gz
| Download URL | rohopay-1.1.3.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d210388b7f6b532aa0c99196eda47f493c6672d86732a2c35baf0ab6574cac6
|
|
BLAKE2b-256 checksum How to use checksums |
db62c7705d0c97795769f78db46ab51b397c14a94644a8ede9225b19723a08c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / rohopay-1.1.3-py3-none-any.whl
| Download URL | rohopay-1.1.3-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2af46d183cd11964d0ff515e9f1240a1ecc249c0be5b62706357f56e21d8711c
|
|
BLAKE2b-256 checksum How to use checksums |
4e54609df34278ba7bb02ec417e8fa38c40597a4df3e7a3fe238706f87da1fa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for rohopay 1.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.