Python
No official Python backend SDK is published yet — call the REST API directly with requests or your HTTP client of choice.
No wajub package
There is no published wajub PyPI package and no github.com/wajub/wajub-python repository —
pip install wajub and import wajub do not work. Call the REST API directly, as
shown below.
Initialization
import os
import requests
WAJUB_BASE_URL = "https://api.wajub.com"
def wajub_request(method, path, json=None, idempotency_key=None):
headers = {"Authorization": os.environ["WAJUB_SECRET_KEY"]} # no "Bearer" prefix
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key
res = requests.request(method, f"{WAJUB_BASE_URL}{path}", json=json, headers=headers)
res.raise_for_status()
return res.json()Use cases
Collect a payment
res = wajub_request("POST", "/payments", json={
"amount": 5000,
"currency": "XAF",
"customer": {"email": "amina@example.com"},
"callback": "https://example.com/return",
})
return redirect(res["authorization_url"])Pay out
import uuid
res = wajub_request(
"POST",
"/transfers",
json={
"amount": 100000,
"currency": "XAF",
"beneficiary": {"phone": "+237670000000", "channel": "cm.mtn", "name": "Amina"},
},
idempotency_key=str(uuid.uuid4()),
)Verify a webhook (FastAPI)
Wajub signs webhooks with HMAC-SHA256 over "{timestamp}.{rawBody}", sent as
X-Wajub-Signature: v1={hex}. See Signature verification
for the full algorithm; a minimal check:
import hmac, hashlib, json, os
from fastapi import FastAPI, Request, HTTPException
app = FastAPI()
@app.post("/webhooks/wajub")
async def webhook(request: Request):
payload = await request.body()
header = request.headers.get("x-wajub-signature", "") # "v1=<hex>"
timestamp = request.headers.get("x-wajub-timestamp", "")
signature = header.split("=", 1)[-1]
expected = hmac.new(
os.environ["WAJUB_WEBHOOK_SECRET"].encode(),
f"{timestamp}.{payload.decode()}".encode(),
hashlib.sha256,
).hexdigest()
if not hmac.compare_digest(expected, signature):
raise HTTPException(status_code=400, detail="Invalid signature")
event = json.loads(payload)
if event["type"] == "payment.succeeded":
fulfill(event["data"])
return {"ok": True}Verify against the real algorithm
Double-check the exact header names and payload construction on Signature verification before shipping this to production — do not assume this snippet alone is complete.
Local development
Use the real, published Wajub CLI (npm install -g @wajub/cli) to forward
webhooks to localhost and trigger test events while you build — no SDK required:
wajub listen --forward-to localhost:8000/webhooks/wajub
wajub trigger payment.complete