Skip to main content

Litestar framework adapter for getpaid payment processing

Project description

litestar-getpaid

PyPI version Python version Litestar version License

Async-native payment processing wrapper for Litestar.

litestar-getpaid is a thin but powerful wrapper around getpaid-core, designed specifically for the Litestar framework. It provides a ready-to-use REST API for creating payments, handling callbacks, and managing redirects, all while staying fully asynchronous.

v3.0.0a3 (Alpha) — This is a pre-release. The API follows the major v3 overhaul of the Getpaid ecosystem.

Features

  • Async-native: Built from the ground up to leverage Python's async/await and Litestar's high-performance architecture.
  • Multi-backend: Process payments through multiple providers (PayU, Paynow, Przelewy24, etc.) simultaneously.
  • Pluggable Persistence: Includes optional SQLAlchemy 2.0 async support out of the box.
  • Retry Mechanism: Robust webhook callback retry system with exponential backoff.
  • Typed Configuration: Configuration managed via Pydantic, supporting environment variables.
  • REST API: Standardized endpoints for payment lifecycle management.

Installation

pip install litestar-getpaid

If you want to use the built-in SQLAlchemy support:

pip install litestar-getpaid[sqlalchemy]

Quick Start

1. Define your Order Resolver

Litestar-getpaid needs to know how to find your orders. Implement the OrderResolver protocol:

from models import Order

class MyOrderResolver:
    async def resolve(self, order_id: str) -> Order:
        # Fetch your order from database
        async with session_factory() as session:
            order = await session.get(Order, order_id)
            if not order:
                raise KeyError(f"Order {order_id} not found")
            return order

2. Configure and Mount the Router

from litestar import Litestar
from litestar_getpaid.config import GetpaidConfig
from litestar_getpaid.plugin import create_payment_router
from litestar_getpaid.contrib.sqlalchemy.repository import SQLAlchemyPaymentRepository

config = GetpaidConfig(
    default_backend="dummy",
    backends={
        "dummy": {"module": "getpaid_core.backends.dummy"},
        "payu": {
            "module": "getpaid_payu",
            "pos_id": "12345",
            "second_key": "secret",
            # ... other PayU settings
        },
    },
)

payment_router = create_payment_router(
    config=config,
    repository=SQLAlchemyPaymentRepository(session_factory),
    order_resolver=MyOrderResolver(),
)

app = Litestar(route_handlers=[payment_router])

Async Patterns

Everything in litestar-getpaid is async. When you call the payment endpoints, the underlying getpaid-core processors are executed asynchronously.

The callback system uses a background task worker (compatible with Litestar's lifespan) to ensure that even if your payment provider's webhook fails, it will be retried without blocking your main application.

Example App

Check out the comprehensive example app in this repository. It demonstrates:

  • Multiple Backends: Simultaneous configuration of Dummy, PayU, and Paynow.
  • Sandbox Mode: Testing with real provider sandboxes.
  • Custom UI: A simple Jinja2-based dashboard for managing orders and payments.
  • Paywall Simulator: A built-in simulator for testing the full redirect flow without leaving your local environment.

To run it:

cd litestar-getpaid/example
uv sync
uv run python app.py

Getpaid Ecosystem

litestar-getpaid is part of a larger ecosystem:

License

This project is licensed under the MIT License.

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

litestar_getpaid-3.0.0a3.tar.gz (38.7 kB view details)

Uploaded Source

Built Distribution

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

litestar_getpaid-3.0.0a3-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file litestar_getpaid-3.0.0a3.tar.gz.

File metadata

  • Download URL: litestar_getpaid-3.0.0a3.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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 litestar_getpaid-3.0.0a3.tar.gz
Algorithm Hash digest
SHA256 3bd8686e4ac79b42afcd552e5dc58b7234d22faa18b6a5e6319ac8a5c3b6d9c0
MD5 8a35f0ea5cb2cd9aa7e83490ec831ea5
BLAKE2b-256 8df5005c34036d86e57e4f62a7d52b1a24218dbc5354af9f962c07f2dcb6a84a

See more details on using hashes here.

File details

Details for the file litestar_getpaid-3.0.0a3-py3-none-any.whl.

File metadata

  • Download URL: litestar_getpaid-3.0.0a3-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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 litestar_getpaid-3.0.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 8df6716bef65945f95dcab777500908a7f5ff0e678bf4d5f9946cae3bdef6b46
MD5 5f47335649cfe33d57b8614e925ecb6b
BLAKE2b-256 816cbaf3975cf1f1bee2d8d7ae01b90dc8349a9fdb441610cddf56bb5b9a36ee

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