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.4.tar.gz (23.5 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.4-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: paybridge-0.1.4.tar.gz
  • Upload date:
  • Size: 23.5 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.4.tar.gz
Algorithm Hash digest
SHA256 702570ad50ca7cf94562680f11162ecfe6bbfb60617960701b6f161062415967
MD5 6d5036fac8f24da6f841f451e43241eb
BLAKE2b-256 d6aef8a49837dcbd382760470bc39d5115d23f6da0fe916260765a5a3b8622bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: paybridge-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4d7ccbc77a1e17a6012a1b15f64dcbb5fc0a39457fceddc577c913bd20f83df0
MD5 65c108d3bd6ebff96c5d7e2b9d6e5bf8
BLAKE2b-256 0ee6b47031d7cfbe54dcd09a7d17eb6729c3995109fbeb1220f7a5bad7f2cc9e

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