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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_getpaid-3.0.0a3.tar.gz
  • Upload date:
  • Size: 39.9 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 fastapi_getpaid-3.0.0a3.tar.gz
Algorithm Hash digest
SHA256 262cb02944cfae560c90076af6387560a8edbfeac6d23f39fc83bb4a3371a3a9
MD5 a0f7fc486be719efe184435eff400dd8
BLAKE2b-256 cf757bcfbcdf21cd14768f2e984763c4af48ae9f1ed24e10fc44ebf36e0509b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastapi_getpaid-3.0.0a3-py3-none-any.whl
  • Upload date:
  • Size: 17.8 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 fastapi_getpaid-3.0.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 467661f75ac54e288f53e2d48c9e6f97f2d081c42598d44a08e282ccae4286f6
MD5 8a986a352e080601617ca5cb2250653a
BLAKE2b-256 032d52316cad0dc3f8419ee5c12e67c34977d61a81b300979d0b4aca09d6ae38

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