Close the gaps between the documented contract (API-STANDARD, TENANCY, ENTITLEMENTS) and the implementation, and remove committed build artifacts. Security: - verify + process inbound webhooks (HMAC/handler verify, size limit, timestamp tolerance, idempotency via InboundEvent.external_id) - real 2FA login flow (pre-auth challenge; tokens only after verify/recovery) - wire HybridPermission into security/audit views; add API-key rotate and users/<id>/permissions|roles endpoints - tenant-scoped throttling on by default; webhook replay protection - verify MercadoPago webhook signatures - login brute-force guard, configurable password policy, real ALTCHA PoW Correctness: - apply verified billing webhooks idempotently (subscription/entitlement/ invoice/PaymentTransaction); scheduled payment lifecycle jobs - capture audit update diffs automatically; add audit retention purge - working notification retries, per-channel rate limits, log retention - pluggable virus scanner, upload-size limit, pipeline toggle - feature rollout %/environment targeting; settings-driven registrations - workflow guards (instance cap, route depth, self-assignment, clone on re-entry) - wire every previously-dead INFRASYNTH_* setting; drop truly dead ones Delivery: - README + CHANGELOG; CI format check + coverage gate - keep test media out of the tree; untrack .coverage, __pycache__, egg-info, docs/ and invoice artifacts
36 lines
813 B
Python
36 lines
813 B
Python
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: ...
|