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.0a4 (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.0a4.tar.gz (40.9 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.0a4-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litestar_getpaid-3.0.0a4.tar.gz
  • Upload date:
  • Size: 40.9 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 litestar_getpaid-3.0.0a4.tar.gz
Algorithm Hash digest
SHA256 8f20ff719cee77fd6c5951ce099143da1eeff7e5fb641267e87734b99097450f
MD5 4ea52cc400bba245cd087af2f1c4f9f0
BLAKE2b-256 15dccc75efe3c0cc3caef763af923bfe6ca58396dc51116d3a0db49aa8f3a29d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: litestar_getpaid-3.0.0a4-py3-none-any.whl
  • Upload date:
  • Size: 17.8 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 litestar_getpaid-3.0.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 e9362e21c1c6d2666ec7c9fa441a08c7eee876f018cb11943dd1f8eb5b2e6202
MD5 2799244145fe9b57cc79af8533c51aa8
BLAKE2b-256 0fe3900adb6b77b4f143f5a1b63fbfd96dcb74a607260f02320a094020032717

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