Skip to main content

Unified payment gateway integration for Python

Project description

PayBridge

PyPI version
Unified, modular payment gateway integration for Python. Connect to Paystack, Flutterwave, Monnify, and more with a single, developer-friendly API.


Features

  • Unified API for multiple payment gateways
  • Modular, extensible provider system
  • Circuit breaker and idempotency support
  • Fallback and load-balancing between providers
  • Webhook and refund handling
  • FastAPI and Flask integration
  • Type-safe models (Pydantic)

Installation

pip install paybridge

Quick Start

from paybridge import PayBridge

paybridge = PayBridge(
    provider="paystack",
    secret_key="sk_test_xxxxxxxxx"
)

response = paybridge.initialize_payment(
    amount=5000,
    email="customer@example.com",
    currency="NGN",
    reference="TXN_001"
)
print(response)

Multi-Gateway Example

from paybridge import PayBridge

paystack = PayBridge(provider="paystack", secret_key="PAYSTACK_SECRET")
flutterwave = PayBridge(provider="flutterwave", secret_key="FLUTTERWAVE_SECRET")

try:
    response = paystack.initialize_payment(amount=5000, email="customer@example.com")
except Exception:
    response = flutterwave.initialize_payment(amount=5000, email="customer@example.com")
print(response)

Supported Providers

  • Paystack
  • Flutterwave
  • Monnify (in progress)
  • Stripe (planned)

Environment Variables

Never hardcode secret keys in production. Use a .env file:

PAYSTACK_SECRET_KEY=sk_test_xxxxx
FLUTTERWAVE_SECRET_KEY=FLWSECK_TEST_xxxxx

And load with python-dotenv:

from dotenv import load_dotenv
import os
load_dotenv()
secret_key = os.getenv("PAYSTACK_SECRET_KEY")

FastAPI Example

from fastapi import FastAPI
from paybridge import PayBridge

app = FastAPI()
paybridge = PayBridge(provider="paystack", secret_key="sk_test_xxxxxxxxx")

@app.post("/initialize-payment")
async def initialize_payment():
    response = paybridge.initialize_payment(
        amount=5000,
        email="customer@example.com",
        currency="NGN",
        reference="TXN_001"
    )
    return response

Error Handling Example

try:
    response = paybridge.initialize_payment(amount=5000, email="customer@example.com")
    print(response)
except Exception as e:
    print(f"Payment failed: {e}")

License

MIT License

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

paybridge-0.1.3.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

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

paybridge-0.1.3-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file paybridge-0.1.3.tar.gz.

File metadata

  • Download URL: paybridge-0.1.3.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for paybridge-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dd2671485b503eb56ca25016c66efe68002666f112e81bfc59c75be189c5e79e
MD5 cd19bf23ccd7ae15c55c07b7acffd742
BLAKE2b-256 29b840d6cb2c236c81e525fbbae37b050cdf5192bf897ddf0d56c8ec0f46c627

See more details on using hashes here.

File details

Details for the file paybridge-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: paybridge-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for paybridge-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 14df67b72060bb9fa06b501a044c2a3259d4806137c830ffcfca4c249bb58843
MD5 9648a991c1267935301f4ec7dd4c46ed
BLAKE2b-256 3ecddd01ac4e0e7a66314e8e2e4fc5c0a77d35034fb61f954cc9b88cd912d036

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