Skip to main content

litestar-getpaid

PyPI Python Version Litestar License

Multi-broker payment processing framework for Litestar, 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
  • Litestar Controllers with Provide() dependency injection
  • REST endpoints for payment CRUD, callbacks, and redirects

Installation

pip install litestar-getpaid

With SQLAlchemy support:

pip install litestar-getpaid[sqlalchemy]

Or with uv:

uv add litestar-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 litestar import Litestar
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine

from litestar_getpaid.config import GetpaidConfig
from litestar_getpaid.contrib.sqlalchemy.repository import (
    SQLAlchemyPaymentRepository,
)
from litestar_getpaid.contrib.sqlalchemy.retry_store import SQLAlchemyRetryStore
from litestar_getpaid.plugin 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)


# An order resolver maps order IDs to Order objects.
# Your Order class must implement the getpaid-core Order protocol.
class MyOrderResolver:
    async def resolve(self, order_id: str) -> "YourOrderModel":
        async with session_factory() as session:
            order = await session.get(YourOrderModel, order_id)
            if order is None:
                raise KeyError(order_id)
            return order


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

app = Litestar(route_handlers=[payment_router])

Start the server:

litestar --app my_app:app run --reload

Replace my_app:app with the module path to your Litestar application instance.

The payment endpoints will be available under /payments/.

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

Supported Versions

  • Python: 3.12+
  • Litestar: 2.0+
  • 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

Metadata

Release files for litestar-getpaid 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for litestar-getpaid 0.1.0
File Size Uploaded
litestar_getpaid-0.1.0.tar.gz 35.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for litestar-getpaid 0.1.0
File Interpreter ABI Platform
litestar_getpaid-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.4 kB

Release files / litestar_getpaid-0.1.0.tar.gz

Download URL litestar_getpaid-0.1.0.tar.gz
Size 35.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ead9b5d404dd55a85cb022810dca4af652e3c8d00e7b8ed4e9798b7ba31ad65e
BLAKE2b-256 checksum
How to use checksums
b29bfc7808394284189030f4d43e870b15f5ade66a867226428ab44248c0f29d
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / litestar_getpaid-0.1.0-py3-none-any.whl

Download URL litestar_getpaid-0.1.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b1fc6c61c77a7cf4e47f104c36353e85288386889ffafa8b60aa4daeaf61cea
BLAKE2b-256 checksum
How to use checksums
22291c1cea8c09dbd094cc2d09b27e9c742827a504ec33879e1fafdf2367daf8
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page