Official Python SDK for MarzPay - Mobile Money Payment Platform for Uganda
Project description
MarzPay Python SDK
Official Python SDK for MarzPay - Mobile Money Payment Platform for Uganda.
Features
- Complete API Coverage - Collections, Disbursements, Accounts, Balance, Transactions, Services, Webhooks, and Phone Verification
- Error Handling - Comprehensive error handling with custom exception classes
- Phone Number Utilities - Built-in phone number validation and formatting
- Webhook Support - Easy webhook handling and validation
- Testing - Full test coverage with pytest
- Documentation - Comprehensive documentation and examples
- Professional Grade - Production-ready SDK with comprehensive error handling
Installation
pip
pip install marzpay-python
Development
git clone https://github.com/Katznicho/marzpay-python.git
cd marzpay-python
pip install -e .
Quick Start
Basic Usage
from marzpay import MarzPay
# Initialize the client
client = MarzPay(
api_key="your_api_key",
api_secret="your_api_secret"
)
# Collect money from customer
result = client.collections.collect_money({
"phone_number": "256759983853",
"amount": 5000,
"description": "Payment for services"
})
print(f"Collection ID: {result['data']['collection_id']}")
Phone Verification
from marzpay import MarzPay
client = MarzPay(
api_key="your_api_key",
api_secret="your_api_secret"
)
# Verify phone number
result = client.phone_verification.verify_phone_number("256759983853")
if result["success"]:
print(f"User: {result['data']['full_name']}")
print(f"Phone: {result['data']['phone_number']}")
API Reference
Collections API
# Collect money
result = client.collections.collect_money({
"phone_number": "256759983853",
"amount": 10000,
"description": "Payment for services"
})
# Get collection details
collection = client.collections.get_collection_details("collection-uuid")
# Get available services
services = client.collections.get_services()
# Get all collections with filters
collections = client.collections.get_collections(
page=1,
limit=20,
status="completed"
)
Disbursements API
# Send money
result = client.disbursements.send_money({
"phone_number": "256759983853",
"amount": 5000,
"description": "Refund payment"
})
# Get disbursement details
disbursement = client.disbursements.get_send_money_details("disbursement-uuid")
Phone Verification API
# Verify phone number
result = client.phone_verification.verify_phone_number("256759983853")
# Get service information
service_info = client.phone_verification.get_service_info()
# Check subscription status
subscription = client.phone_verification.get_subscription_status()
Webhooks
# Handle webhook callback
result = client.callback_handler.handle_callback(webhook_data)
# Verify webhook signature
is_valid = client.callback_handler.verify_signature(payload, signature, secret)
Configuration
from marzpay import MarzPay
client = MarzPay(
api_key="your_api_key",
api_secret="your_api_secret",
base_url="https://wallet.wearemarz.com/api/v1", # optional
timeout=30, # optional, in seconds
)
Error Handling
from marzpay import MarzPay
from marzpay.errors import MarzPayError
try:
result = client.collections.collect_money(request_data)
except MarzPayError as e:
print(f"Error Code: {e.code}")
print(f"HTTP Status: {e.status}")
print(f"Message: {e.message}")
print(f"Details: {e.details}")
Environment Variables
import os
from marzpay import MarzPay
client = MarzPay(
api_key=os.getenv("MARZPAY_API_KEY"),
api_secret=os.getenv("MARZPAY_API_SECRET"),
)
Testing
# Run tests
pytest
# Run tests with coverage
pytest --cov=marzpay
# Run specific test file
pytest tests/test_collections.py
Development
# Install development dependencies
pip install -e ".[dev]"
# Format code
black marzpay tests
# Lint code
flake8 marzpay tests
# Type checking
mypy marzpay
License
MIT License. See LICENSE for details.
Official Documentation
For complete API documentation, visit: https://wallet.wearemarz.com/documentation
Support
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
marzpay_python-1.0.0.tar.gz
(32.0 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 marzpay_python-1.0.0.tar.gz.
File metadata
- Download URL: marzpay_python-1.0.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d94f0bb794b0a19bbd0b1c338aa18d459da96f412a0acbdfdc7b52b279e33c46
|
|
| MD5 |
09680725fe61291093b1044f8d7d17f3
|
|
| BLAKE2b-256 |
ea2eec55d604a2c31a78399eecfe2f3148cd8de93844b7fb3386dedad9f0748f
|
File details
Details for the file marzpay_python-1.0.0-py3-none-any.whl.
File metadata
- Download URL: marzpay_python-1.0.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7f5bf9f658ee03965d2a94748fc5b216cb833db4962de2caa8dd1cd767abf46
|
|
| MD5 |
9fe265883e223d9ca6db9657501c4926
|
|
| BLAKE2b-256 |
16fda7976d5acf896a08f3ded09f93b2cde91d965e40ff7d62f5284dfd5dd43e
|