35 lines
771 B
Python
35 lines
771 B
Python
"""Dummy payment provider — always approves."""
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from core.di import register_service
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class PaymentProvider:
|
|
name = "DummyPayment"
|
|
|
|
def charge(self, amount: float, currency: str, method: str = "dummy") -> dict:
|
|
return {
|
|
"status": "paid",
|
|
"transaction_id": f"DUM-{uuid.uuid4().hex[:12]}",
|
|
"amount": amount,
|
|
"currency": currency,
|
|
"method": method,
|
|
}
|
|
|
|
|
|
def on_load() -> None:
|
|
register_service("PaymentProvider", PaymentProvider())
|
|
|
|
|
|
@router.get("/methods")
|
|
def available_methods():
|
|
return [
|
|
{"id": "dummy", "label_de": "Testzahlung", "label_en": "Test payment"},
|
|
]
|