Official Python SDK for the Mavunta Pay API.
Project description
mavunta
Official Python SDK for the Mavunta Pay API. Standard library only (no dependencies), Python 3.8+.
pip install mavunta
Quickstart
Create an intent, redirect the customer to its hosted checkout, and fulfil the
order on the signed payment_intent.paid webhook.
import os
from mavunta import Mavunta
mavunta = Mavunta(api_key=os.environ["MAVUNTA_SECRET_KEY"])
intent = mavunta.payment_intents.create(
amount="2500",
currency="KES",
settlement_currency="USDT",
payment_methods=["mpesa", "card", "mavunta_balance"],
merchant_reference="ORDER-1001",
)
# Redirect the customer to:
print(intent["checkout_url"])
A cwk_test_… key runs in sandbox (no real money); a cwk_live_… key is live.
Every create call sends an Idempotency-Key automatically, so an automatic
retry (on 429/5xx) never double-charges.
Resources
mavunta.auth.verify()
mavunta.rates.retrieve()
mavunta.quotes.create(source_currency="KES", target_asset="USDT", amount="2500")
mavunta.payment_intents.create(amount="2500", currency="KES", idempotency_key="order-1001")
mavunta.payment_intents.retrieve("pi_...")
mavunta.payment_intents.list(limit=20, status="paid")
mavunta.payment_intents.cancel("pi_...")
mavunta.payment_intents.refund_request("pi_...", reason="Customer returned item")
mavunta.payment_links.create(title="Deposit", amount="15000", currency="KES")
mavunta.payment_links.retrieve("pl_...")
Verify webhooks
Pass the raw request body (str or bytes).
event = mavunta.webhooks.verify(
payload=raw_body,
signature=headers["Mavunta-Signature"],
timestamp=headers["Mavunta-Timestamp"],
secret=os.environ["MAVUNTA_WEBHOOK_SECRET"],
)
if event["type"] == "payment_intent.paid":
... # fulfil the order, dedupe on event["id"]
Errors
from mavunta import MavuntaError
try:
mavunta.payment_intents.create(amount="0", currency="KES")
except MavuntaError as err:
print(err.type, err.code, err, err.request_id)
The full contract is published as OpenAPI at https://www.mavunta.com/openapi.yaml.
License
MIT
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
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 mavunta-1.0.0.tar.gz.
File metadata
- Download URL: mavunta-1.0.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fa55af2807b8c505e73e80b75b713b01a408a93ed289cc19a1ef7f67110e737
|
|
| MD5 |
b3f200bf2fe2a9c6f0c7303d5f852822
|
|
| BLAKE2b-256 |
7d553231cc103ff53e25ca69a2ba79ca5137298da0d6d260794fba5ca518612e
|
File details
Details for the file mavunta-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mavunta-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fa130c6cf9a24b98baea09fc1c5451c188d93efc58f0aef7d45d4230dca32ac
|
|
| MD5 |
a4c0697a2e815a0b27f6d52fac9f3903
|
|
| BLAKE2b-256 |
2a657a0993b1085ceb9f1297b0f5f12c5cdc204ab96798539c9c435010308d3f
|