Skip to main content

FastAPI framework adapter for getpaid payment processing

Project description

fastapi-getpaid

PyPI version Python versions FastAPI versions License

FastAPI framework adapter for getpaid-core payment processing ecosystem.

Features

  • Standardized API: Unified REST endpoints for creating and managing payments across different backends.
  • OpenAPI Integration: Automatically generated interactive documentation for all payment endpoints.
  • Dependency Injection: Seamlessly integrates with FastAPI's dependency injection system.
  • Backend Agnostic: Supports all getpaid processors (PayU, Paynow, Bitpay, Przelewy24, etc.).
  • Async First: Fully asynchronous implementation for high performance.
  • Pluggable Persistence: Support for SQLAlchemy (built-in) or custom repositories.
  • Semantic Updates: Reliable payment status management via explicit payment events and provider metadata.

Installation

pip install fastapi-getpaid

To use with SQLAlchemy:

pip install "fastapi-getpaid[sqlalchemy]"

Quick Start

1. Configure Backends

Define your backends and general settings using GetpaidConfig:

from fastapi_getpaid import GetpaidConfig

config = GetpaidConfig(
    default_backend="dummy",
    success_url="https://example.com/payment/success",
    failure_url="https://example.com/payment/failure",
    backends={
        "dummy": {
            "module": "getpaid_core.backends.dummy",
            "gateway": "https://example.com/paywall",
        },
        # Add real backends here
    }
)

2. Implement Order Resolver

The wrapper needs to know how to resolve your domain's order IDs:

from fastapi_getpaid import OrderResolver

class MyOrderResolver(OrderResolver):
    async def resolve(self, order_id: str):
        # Fetch order from your database
        return await my_db.get_order(order_id)

3. Mount Payment Router

from fastapi import FastAPI
from fastapi_getpaid import create_payment_router
from fastapi_getpaid.contrib.sqlalchemy.repository import SQLAlchemyPaymentRepository

app = FastAPI()

# Setup repository (SQLAlchemy example)
repository = SQLAlchemyPaymentRepository(session_factory)

# Create and include the router
payment_router = create_payment_router(
    config=config,
    repository=repository,
    order_resolver=MyOrderResolver(),
)

app.include_router(payment_router, prefix="/api/payments", tags=["payments"])

OpenAPI Integration

Once mounted, fastapi-getpaid automatically adds documented endpoints to your FastAPI app. Visit /docs or /redoc to see the full API specification, including:

  • POST /api/payments/: Initiate a new payment.
  • GET /api/payments/{payment_id}: Check payment status.
  • POST /api/payments/callback/{payment_id}: Standardized callback handler.

Example Application

A comprehensive example showing multiple backends (Dummy, PayU, Paynow), SQLAlchemy integration, and a fake payment gateway simulator is available in the example/ directory.

To run it:

cd example
pip install -r requirements.txt
uvicorn app:app --reload

Ecosystem

fastapi-getpaid is part of the getpaid ecosystem:

License

This project is licensed under the MIT License - see the LICENSE file for details.

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_getpaid-3.0.0a4.tar.gz (42.2 kB view details)

Uploaded Source

Built Distribution

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

fastapi_getpaid-3.0.0a4-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_getpaid-3.0.0a4.tar.gz.

File metadata

  • Download URL: fastapi_getpaid-3.0.0a4.tar.gz
  • Upload date:
  • Size: 42.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_getpaid-3.0.0a4.tar.gz
Algorithm Hash digest
SHA256 5e09b5a689e707840fad1caa14fc886f483fa94d6192d52b0914c732c874e155
MD5 5f984c6f2ae728c930fcf97866e2d3e6
BLAKE2b-256 8fd0c0554a9d9337a938ad4cd5d1a0c5e4b3c12a692870fda7727b0e9ec7e76d

See more details on using hashes here.

File details

Details for the file fastapi_getpaid-3.0.0a4-py3-none-any.whl.

File metadata

  • Download URL: fastapi_getpaid-3.0.0a4-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_getpaid-3.0.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 a2e689d97646fda123346993e703536426b907b92ecf9ae41a64a4adf315d65e
MD5 10921f7dbb1944705b97fd3fa08cf918
BLAKE2b-256 5db93ea6b03e1e069dd98f370152479338c70ee0d8018fd0d5f73e6be083c315

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