Skip to main content

Abstraction unifiée des passerelles de paiement africaines (CinetPay, Kkiapay...) - Zéro dépendance externe.

Project description

paygate-africa

CI/CD Documentation PyPI version License: MIT

paygate-africa est une passerelle d'abstraction Python ultra-légère conçue pour unifier les paiements en Afrique. Intégrez CinetPay, Kkiapay et bien d'autres avec une seule interface, sans coupler votre code à des SDK tiers volumineux.


Pourquoi paygate-africa ?

Intégrer les paiements africains est souvent synonyme de dépendances lourdes (httpx, pydantic, requests) et de structures de données incompatibles. Nous avons créé ce module pour offrir une alternative indépendante et unifiée.

Caractéristique SDK Traditionnels paygate-africa
Dépendances 10MB+ (httpx, pydantic...) 0MB (Standard Lib)
Utilisation SDK spécifique par provider Interface Unique (Factory)
Poids Lourd Ultra-léger (< 50KB)
Couplage Fort (modèles dictés) Faible (Duck Typing / Protocol)

Fonctionnalités Clés

  • Unified Interface : Une seule méthode initiate_payment et verify_payment pour tous les providers.
  • Asynchrone par défaut : Conçu pour s'intégrer parfaitement avec FastAPI ou Django (avec sync_to_async).
  • Type Safety : Utilisation des Protocols Python (PEP 544) pour une validation stricte sans dépendance pydantic.
  • Extensible : Ajoutez un nouveau provider en créant seulement deux classes.
  • Zero Side-Effects : Aucun logger imposé, aucune surcharge mémoire.

Installation

pip install paygate-africa

Exemple : Intégrer un paiement en 30 secondes

1. Définissez votre objet Transaction (Duck Typing)

Pas besoin d'hériter d'une classe. N'importe quel objet avec ces attributs fera l'affaire.

class MyTransaction:
    id = "ORDER_123"
    amount = 5000.0
    currency = "XOF"
    user_email = "client@email.com"
    user_name = "Jean Dupont" # Optionnel
    description = "Achat Pack Pro" # Optionnel
    user_phone = "+22501020304" # Optionnel

2. Le code d'intégration

import asyncio
from paygate_africa import select_provider, PaymentProviderPath

async def main():
    # Sélection dynamique (CINETPAY ou KKIAPAY)
    provider = select_provider(PaymentProviderPath.CINETPAY)

    tx = MyTransaction()

    # Initiation (redirection URL)
    payment_url = await provider.initiate_payment(tx)
    print(f"Lien de paiement : {payment_url}")

    # Vérification normalisée
    res = await provider.verify_payment(tx.id)
    if res["status"] == "SUCCESS":
        print("Paiement validé !")

Providers Supportés

Provider Mécanique Statut
CinetPay Redirection sécurisée Stable
Kkiapay Widget Frontend (JS) Stable
PayDunya Redirection sécurisée En cours

Folder Structure

paygate-africa/
├── src/paygate_africa/
│   ├── base.py          # Interface commune (Protocol + ABC)
│   ├── factory.py       # Coeur dynamique
│   └── cinetpay/        # Implémentations spécifiques
└── tests/               # 100% de couverture mockée

Contribution

Nous accueillons les contributions avec plaisir ! Surtout pour ajouter de nouveaux providers africains (PayDunya, Fedapay, MonCash, etc.).

  1. Clonez le dépôt et installez les dépendances dev : poetry install
  2. Lancez les tests : poetry run pytest
  3. Vérifiez le linting : poetry run ruff check .

Gestion des Tags Git

Le projet utilise les tags Git pour déclencher les déploiements automatiques. Voici les commandes utiles :

  • Ajouter un tag : git tag v0.1.2
  • Pousser un tag (déclenche la release PyPI) : git push origin v0.1.2
  • Supprimer un tag local : git tag -d v0.1.2
  • Supprimer un tag distant : git push origin --delete v0.1.2

Licence

Ce projet est sous licence MIT. Libre pour usage commercial et personnel.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paygate_africa-0.1.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paygate_africa-0.1.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file paygate_africa-0.1.2.tar.gz.

File metadata

  • Download URL: paygate_africa-0.1.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for paygate_africa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e9ed40a010c2ef4e82094b5e14d7bd47caa3e08eb80baee65ddb42360253e50b
MD5 16e80c18a2998f82cc405e9a4d09fd94
BLAKE2b-256 6de899ad8a151ec530ebbf42134b921ce5fc3046941b7a16b37c2907531f699e

See more details on using hashes here.

File details

Details for the file paygate_africa-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: paygate_africa-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for paygate_africa-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 51d7feab8995635013f2a593c0deee7b2f82b003b5d310943d2fe1f7668ea2af
MD5 5b82a900fc02a458e5de574e07716791
BLAKE2b-256 03c10eee10996e70a25a489874834aba857734609c6eb2648190de9a93cbf2d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page