Source code for derp.payments.exceptions

"""Custom exceptions for payments integration."""

from __future__ import annotations


[docs] class PaymentsError(Exception): """Base exception for all payments errors."""
[docs] def __init__(self, message: str, code: str | None = None): super().__init__(message) self.message = message self.code = code or "payments_error"
[docs] class PaymentsProviderError(PaymentsError): """Raised when Stripe returns an error."""
[docs] def __init__( self, message: str = "Payments provider request failed", code: str | None = None, ): super().__init__(message, code=code or "payments_provider_error")
[docs] class PaymentsNotConnectedError(PaymentsError): """Raised when payments client is used before connect()."""
[docs] def __init__(self, message: str = "Payments not connected. Call connect() first."): super().__init__(message, code="payments_not_connected")
[docs] class WebhookSignatureError(PaymentsError): """Raised when webhook verification fails."""
[docs] def __init__(self, message: str = "Invalid webhook signature"): super().__init__(message, code="webhook_signature_error")