Skip to main content

FastAPI framework adapter for getpaid payment processing

Project description

fastapi-getpaid

PyPI Python Version FastAPI License

Multi-broker payment processing framework for FastAPI, built on getpaid-core.

v0.1.0 (Alpha) — This is a pre-release. The API may change before the stable v1.0 release.

Features

  • Async-native from routes to persistence
  • Multiple payment brokers at the same time
  • Flexible plugin architecture via getpaid-core
  • SQLAlchemy 2.0 async models and repository (optional)
  • Webhook callback retry with exponential backoff
  • Typed configuration via pydantic-settings with env var support
  • Plugin discovery and registration at startup
  • REST endpoints for payment CRUD, callbacks, and redirects

Installation

pip install fastapi-getpaid

With SQLAlchemy support:

pip install fastapi-getpaid[sqlalchemy]

Or with uv:

uv add fastapi-getpaid

Then install a payment backend plugin (check that the plugin supports getpaid-core v3 before installing):

pip install python-getpaid-payu

Quick Start

from fastapi import FastAPI
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine

from fastapi_getpaid.config import GetpaidConfig
from fastapi_getpaid.contrib.sqlalchemy.repository import (
    SQLAlchemyPaymentRepository,
)
from fastapi_getpaid.contrib.sqlalchemy.retry_store import SQLAlchemyRetryStore
from fastapi_getpaid.router import create_payment_router

config = GetpaidConfig(
    default_backend="dummy",
    success_url="https://example.com/thank-you",
    failure_url="https://example.com/payment-failed",
    backends={
        "dummy": {"module": "getpaid_core.backends.dummy"},
    },
)

engine = create_async_engine("sqlite+aiosqlite:///payments.db")
session_factory = async_sessionmaker(engine, expire_on_commit=False)

repository = SQLAlchemyPaymentRepository(session_factory)
retry_store = SQLAlchemyRetryStore(session_factory)

payment_router = create_payment_router(
    config=config,
    repository=repository,
    retry_store=retry_store,
)

app = FastAPI(title="My Payment Service")
app.include_router(payment_router, prefix="/api")

Start the server:

uvicorn myapp:app --reload

The payment endpoints will be available under /api/payments/.

See the example app for a fully working project with a built-in payment broker simulator.

Supported Versions

  • Python: 3.12+
  • FastAPI: 0.115+
  • SQLAlchemy: 2.0+ (optional)

Running Tests

uv sync
uv run pytest

Or with ruff for linting:

uv run ruff check src/ tests/

Part of the getpaid ecosystem

This package is part of the getpaid family of libraries:

Payment gateway plugins:

Credits

Created by Dominik Kozaczko.

Disclaimer

This project has nothing in common with the getpaid plone project.

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_getpaid-0.1.0.tar.gz (37.3 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-0.1.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_getpaid-0.1.0.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4122545168c84ace243f0107a91b083285f2d8364ecf9f45f9887b95ab59f5d9
MD5 def5e6ea8a1e6e8bca9ab689ea7a83c2
BLAKE2b-256 1d6b72367c2e16e8edcaa64a90a1c9c7dfdc3e8ef9a01764bf4df912c118f6d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastapi_getpaid-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","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-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13e540aedc896c0207417f6378fad300fa9d74ca00e9137f7532b628f3af9c22
MD5 19dfcce6e4c48ce3f9afea6b1bdf5cbd
BLAKE2b-256 364ba3949e84b05a852a1ffff68784a97c50345ed4bc40bd0df8c4e6d83692ed

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