Official Money-Pulse Python SDK — Accept payments and process payouts across Africa.
Project description
moneypulse
Official Python SDK for Money-Pulse.
Installation
pip install moneypulse
Quick start
import moneypulse
client = moneypulse.Client("mp_live_xxx")
payment = client.payments.create(
amount=10000, currency="XOF", country="CI",
customer={"email": "client@email.com", "phone": "+22507000000"},
callback_url="https://your-site.com/webhook",
)
print(payment["checkout_url"])
Payouts
payout = client.payouts.create(
amount=50000, currency="XOF", country="CI",
recipient={"type": "mobile_money", "phone": "+22507000000", "name": "Jean Kouassi"},
)
Webhook verification (HMAC SHA-256)
Django
import hmac, hashlib, json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def mp_webhook(request):
signature = request.headers.get("X-MoneyPulse-Signature", "")
expected = hmac.new(
settings.MP_WEBHOOK_SECRET.encode(),
request.body, hashlib.sha256
).hexdigest()
if not hmac.compare_digest(signature, expected):
return HttpResponse(status=401)
event = json.loads(request.body)
if event["type"] == "payment.success":
# fulfill order
pass
return HttpResponse(status=200)
FastAPI
from fastapi import FastAPI, Request, HTTPException
import hmac, hashlib
app = FastAPI()
@app.post("/webhook")
async def webhook(req: Request):
body = await req.body()
signature = req.headers.get("x-moneypulse-signature", "")
expected = hmac.new(SECRET.encode(), body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(signature, expected):
raise HTTPException(401)
return {"received": True}
Simulation mode
result = client.payments.create(
amount=1000, currency="XOF", country="CI",
customer={"email": "t@t.com"},
simulate=True, # no funds, no webhook, no billing
)
Error handling
from moneypulse.client import MoneyPulseError
try:
client.payments.create(...)
except MoneyPulseError as e:
print(e.code, e.status_code, e)
License
MIT © NOCYL-PULSE
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
moneypulse-2.0.3.tar.gz
(4.2 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 moneypulse-2.0.3.tar.gz.
File metadata
- Download URL: moneypulse-2.0.3.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27bc91211579b9f99f1e3a9db9c3f178b42152fdaf46405ed3ecce2fdd71bec3
|
|
| MD5 |
10b1a7be7ddb057d2cc83d5e9450ace7
|
|
| BLAKE2b-256 |
daacd0e2d09ea5f3ea77f58f19e9af2804698cf1e782e760d513dcc16f5cd51c
|
File details
Details for the file moneypulse-2.0.3-py3-none-any.whl.
File metadata
- Download URL: moneypulse-2.0.3-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d52124210f599e127a1b0afeb1340922cac9584ead6c1a529d203598cddcf12b
|
|
| MD5 |
1692f1a49fb2c2f2538b98853437fbd2
|
|
| BLAKE2b-256 |
7b0bcd319313701d07bbfcb5fb040c86bc945a291a60e5a44e1df0bc1943e759
|