Problèmes — Paiements & Webhooks
KKiaPay — Webhook Non Reçu
bash
# Diagnostic : vérifier que le webhook est enregistré
curl -sf https://api-rgz.duckdns.org/api/v1/webhooks \
-H "Authorization: Bearer $JWT_TOKEN" | jq '.items[] | select(.provider=="kkiapay")'
# Test manuel d'un webhook
docker exec rgz-api curl -sf -X POST \
http://localhost:8000/api/v1/webhooks/kkiapay \
-H "Content-Type: application/json" \
-H "x-kkiapay-secret: $KKIAPAY_SECRET" \
-d '{"transaction_id": "test_123", "status": "completed", "amount": 10000}'Erreurs Courantes
| Erreur | Cause | Solution |
|---|---|---|
| Webhook "Unauthorized" | Secret invalide (LL#19) | Vérifier x-kkiapay-secret header vs KKIAPAY_SECRET env |
| Paiement dupliqué | Pas d'idempotency (LL#20) | Vérifier kkiapay_transaction_id unique en DB |
| 404 Not Found | Route webhook manquante | Vérifier /api/v1/webhooks/kkiapay existe |
| Timeout 30s | API trop lente | Vérifier perf DB + redis |
Webhook Validation
bash
# Vérifier que le header x-kkiapay-secret est reçu
docker exec rgz-api python3 -c "
import hmac
import hashlib
payload = '{\"transaction_id\": \"tx_123\", \"status\": \"completed\"}'
secret = open('/dev/env', 'r').read() # KKIAPAY_SECRET from env
expected = hmac.new(secret.encode(), payload.encode(), hashlib.sha256).hexdigest()
print(f'Expected signature: {expected}')
"Vouchers — Genération Bloquée
bash
# Vérifier que les codes vouchers sont générés
docker exec -i rgz-db psql -U rgz_admin rgz -c \
"SELECT COUNT(*) FROM vouchers WHERE status='active';"
# Si < 100 → déclencher la génération manuelle
docker exec rgz-api python3 -m app.services.voucher_generatorMomo Mobile Money — Réconciliation Échouée
bash
# Tâche quotidienne : #21 Reconciliation (00:15 UTC)
docker logs rgz-beat | grep -i reconciliation | tail -20
# Vérifier les transactions non rapprochées
docker exec -i rgz-db psql -U rgz_admin rgz -c \
"SELECT * FROM payments WHERE status='pending' AND created_at < NOW() - INTERVAL '24 hours';"Fair Use — Surfacturization Déclenchée
bash
# Vérifier les limites configurées
curl -sf https://api-rgz.duckdns.org/api/v1/fair-use/config \
-H "Authorization: Bearer $JWT_TOKEN" | jq .
# Vérifier les dépassements actifs
curl -sf https://api-rgz.duckdns.org/api/v1/fair-use/active \
-H "Authorization: Bearer $JWT_TOKEN" | jq '.items[] | {subscriber: .subscriber_id, overage: .overage_bytes}'Dernière mise à jour: 2026-02-21