from abc import ABC, abstractmethod from dataclasses import dataclass @dataclass class CheckoutSessionResult: session_id: str checkout_url: str client_secret: str @dataclass class WebhookResult: event_type: str is_handled: bool data: dict class BasePaymentGateway(ABC): @abstractmethod def create_checkout_session(self, plan, user=None, *, tenant=None, **kwargs) -> CheckoutSessionResult: ... @abstractmethod def handle_webhook(self, payload, headers) -> WebhookResult: ... @abstractmethod def cancel_subscription(self, subscription) -> bool: ... @abstractmethod def sync_subscription(self, subscription) -> dict: ... @abstractmethod def get_invoice(self, invoice) -> dict: ... @abstractmethod def health_check(self) -> bool: ...