Skip to main content

A flexible and extensible payment library for FastAPI

Project description

FastAPI Payments Library

A flexible and extensible payment library for FastAPI applications supporting multiple payment providers and pricing models.

Features

  • Multiple Payment Providers: Support for Stripe, PayPal, Adyen, and more
  • Flexible Pricing Models:
    • Subscription
    • Usage-based
    • Tiered pricing
    • Per-user/seat pricing
    • Freemium
    • Dynamic pricing
    • Hybrid models
  • Asynchronous Architecture: Built on FastAPI and SQLAlchemy 2.0 with async support
  • Event-Driven: RabbitMQ integration via FastStream for reliable payment event messaging
  • Highly Configurable: Extensive configuration options to customize for your needs
  • Extensible: Easy to add new payment providers or custom pricing models

Installation

pip install fastapi-payments

Quick Start

from fastapi import FastAPI
from fastapi_payments import FastAPIPayments, create_payment_module
import json

# Create FastAPI app
app = FastAPI()

# Load payment configuration
with open("config/payment_config.json") as f:
    config = json.load(f)

# Initialize payments module
payments = FastAPIPayments(config)

# Include payment routes
payments.include_router(app, prefix="/api")

# Start server
if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

Configuration

Create a payment_config.json file:

{
  "providers": {
    "stripe": {
      "api_key": "sk_test_your_stripe_key",
      "webhook_secret": "whsec_your_webhook_secret",
      "sandbox_mode": true
    }
  },
  "database": {
    "url": "postgresql+asyncpg://user:password@localhost/payments"
  },
  "rabbitmq": {
    "url": "amqp://guest:guest@localhost/"
  },
  "pricing": {
    "default_currency": "USD",
    "default_pricing_model": "subscription"
  },
  "default_provider": "stripe"
}

Documentation

For complete documentation, visit https://fastapi-payments.readthedocs.io/

License

MIT

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

fastapi_payments-0.1.0.tar.gz (49.9 kB view details)

Uploaded Source

Built Distribution

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

fastapi_payments-0.1.0-py3-none-any.whl (62.7 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_payments-0.1.0.tar.gz.

File metadata

  • Download URL: fastapi_payments-0.1.0.tar.gz
  • Upload date:
  • Size: 49.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for fastapi_payments-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4ad12883852fee83c9e52bb64e9d56a0aedfb862fc5e6d9159c26c436b28b7f
MD5 b52366a75d97bb29e87ef0eb30f3a76c
BLAKE2b-256 77b0f120ffb9f98762a25ed1c9b90486b48510e2a3dc56ddda283770b5c08c6e

See more details on using hashes here.

File details

Details for the file fastapi_payments-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_payments-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2085fa2e5639853caf1ee2efe0d9f59c24a11a3a0d5bc84f1ef73c9a57fbc058
MD5 f34a1615a84d87968776a109278ac594
BLAKE2b-256 011385ed9aa87489afcc346bc45bf81cdd5541a6cff9f67879f2151b0760afb9

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