Skip to main content

GeniusPay Django SDK

Un SDK Django robuste, sécurisé et "Plug-and-Play" pour intégrer facilement l'API GeniusPay dans vos projets.

Ce que ce SDK fait pour vous

  • Paiements : Création, récupération et listage avec gestion complète de l'autorouting et des gateways (Wave, Paystack, CinetPay, PawaPay...).
  • Webhooks Sécurisés : Réception automatique des webhooks avec vérification cryptographique (HMAC-SHA256) et protection anti-rejeu.
  • Base de Données Automatique : Sauvegarde transparente de chaque transaction et mise à jour de son statut dans votre base de données locale.
  • Signaux Django : Plus besoin de créer des vues pour traiter les paiements, connectez-vous simplement aux signaux natifs (payment_success, payment_failed).
  • Panneau d'Administration : Visualisez l'historique de vos paiements GeniusPay directement dans votre espace Django Admin.

1. Installation & Configuration

Installez le package et ajoutez 'geniuspay' à vos applications installées :

# settings.py
INSTALLED_APPS = [
    # ...
    'geniuspay',
]

# Configurez vos clés GeniusPay
GENIUSPAY = {
    "API_KEY": "pk_live_xxxx",
    "API_SECRET": "sk_live_xxxx",
    "WEBHOOK_SECRET": "whsec_xxxx", # Obligatoire pour sécuriser les webhooks
}

Appliquez les migrations pour créer la table de suivi des transactions :

python manage.py makemigrations geniuspay
python manage.py migrate

2. Recevoir des Webhooks (La magie des Signaux)

Le SDK s'occupe de la sécurité et de la mise à jour en base de données. Vous n'avez qu'à exposer la route et écouter le signal.

Dans votre urls.py principal :

from django.urls import path, include

urlpatterns = [
    # ...
    path('geniuspay/', include('geniuspay.urls')), 
    # Votre URL webhook sera : https://votre-site.com/geniuspay/webhook/
]

Dans n'importe quel fichier de votre projet (ex: signals.py ou views.py) :

from django.dispatch import receiver
from geniuspay.signals import payment_success, payment_failed

@receiver(payment_success)
def valider_commande(sender, transaction, raw_event, **kwargs):
    print(f"Le paiement {transaction.reference} de {transaction.amount} {transaction.currency} a réussi !")
    # Mettez à jour votre panier, envoyez un email au client, etc.

@receiver(payment_failed)
def annuler_commande(sender, transaction, raw_event, **kwargs):
    print(f"Le paiement {transaction.reference} a échoué.")

3. Initier un Paiement

C'est aussi simple que d'instancier le client.

from geniuspay.client import GeniusPayClient

def payer_commande(request):
    client = GeniusPayClient()
    
    payment = client.payments.create(
        amount=5000,
        description="Achat de chaussures",
        customer={"name": "Jean Dupont", "phone": "+22500000000"},
        success_url="https://monsite.com/merci",
        # gateway="wave"  # Optionnel : Laissez vide pour l'autorouting de GeniusPay !
    )
    
    # Redirigez l'utilisateur vers la page de paiement sécurisée
    return redirect(payment.checkout_url)

4. Lister les Opérateurs (Providers)

Si vous construisez votre propre interface, vous pouvez lister dynamiquement les opérateurs disponibles.

client = GeniusPayClient()
providers = client.providers.list(country="CI", gateway="pawapay")

for p in providers:
    print(p.name) # ex: Orange Money, MTN Mobile Money...

5. Gestion des Erreurs

Le SDK expose des exceptions propres pour vous faciliter la vie : GeniusPayNetworkError, GeniusPayAuthError, GeniusPayValidationError, GeniusPayWebhookError.

Metadata

Release files for django-geniuspaySDK 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-geniuspaySDK 1.2.1
File Size Uploaded Provenance Actions
django_geniuspaysdk-1.2.1.tar.gz 16.6 kB Without provenance Details for django_geniuspaysdk-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-geniuspaySDK 1.2.1
File Interpreter ABI Platform Actions
django_geniuspaysdk-1.2.1-py3-none-any.whl Python 3 none any Details for django_geniuspaysdk-1.2.1-py3-none-any.whl

Total release size: 35.3 kB

Release files / django_geniuspaysdk-1.2.1.tar.gz

Download URL django_geniuspaysdk-1.2.1.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c2a78b729db9c4bfdee79a89551dabdecd81aecadca88b433c8dce1de5ae018b
BLAKE2b-256 checksum
How to use checksums
73fa8a9f56ebe1fdcd686f0a3c0f517a52cdc3c3bfb881ae5f65d6bdedd484e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / django_geniuspaysdk-1.2.1-py3-none-any.whl

Download URL django_geniuspaysdk-1.2.1-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75d4ae68896fc5be30893406fcb3e935f0c61ec99b8b3502f281db9214fc250f
BLAKE2b-256 checksum
How to use checksums
6b677971a808075a61c7628544c2cedb561a92ca05bddb3918ccda66302d1d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for django-geniuspaySDK 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page