A flexible and extensible payment library for FastAPI
Project description
Work in Progress (Not ready for usage)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_payments-0.1.1.tar.gz.
File metadata
- Download URL: fastapi_payments-0.1.1.tar.gz
- Upload date:
- Size: 50.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d47cb2562912fb478a5b735885a375e34aa3b297399bc0d3072f7fbafa33b5ac
|
|
| MD5 |
b3d927b3497f76bd5bcf0983b1bb3216
|
|
| BLAKE2b-256 |
7870716b6af3417c65065b540175f022d810993de12aea8f15df03ec295ea7a2
|
File details
Details for the file fastapi_payments-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_payments-0.1.1-py3-none-any.whl
- Upload date:
- Size: 62.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d336b8d76475c43a615e7c57d450c84eef8cb66f03a5b7009424abc00c1395c0
|
|
| MD5 |
1ff19c678ad6f55d9c605013c3a2383f
|
|
| BLAKE2b-256 |
a8de3db3721ed8a3468ea41eead198c35a671ec53a954685186696679303b575
|