70 lines
2.7 KiB
Python
70 lines
2.7 KiB
Python
|
|
"""
|
||
|
|
Payment-related exceptions for the atomic payment architecture
|
||
|
|
"""
|
||
|
|
|
||
|
|
class PaymentException(Exception):
|
||
|
|
"""Base class for payment-related exceptions"""
|
||
|
|
pass
|
||
|
|
|
||
|
|
class PaymentVerificationRequired(PaymentException):
|
||
|
|
"""Exception raised when payment verification is required before proceeding"""
|
||
|
|
def __init__(self, message: str = "Payment verification required", setup_intent_id: str = None, client_secret: str = None):
|
||
|
|
self.message = message
|
||
|
|
self.setup_intent_id = setup_intent_id
|
||
|
|
self.client_secret = client_secret
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
class ThreeDSAuthenticationRequired(PaymentException):
|
||
|
|
"""Exception raised when 3DS authentication is required"""
|
||
|
|
def __init__(self, setup_intent_id: str, client_secret: str, action_type: str, **kwargs):
|
||
|
|
self.setup_intent_id = setup_intent_id
|
||
|
|
self.client_secret = client_secret
|
||
|
|
self.action_type = action_type
|
||
|
|
self.extra_data = kwargs
|
||
|
|
message = f"3DS authentication required (action: {action_type})"
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
class PaymentMethodInvalid(PaymentException):
|
||
|
|
"""Exception raised when payment method is invalid"""
|
||
|
|
def __init__(self, message: str = "Payment method is invalid"):
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
class PaymentFailed(PaymentException):
|
||
|
|
"""Exception raised when payment fails"""
|
||
|
|
def __init__(self, message: str = "Payment failed"):
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
class SubscriptionCreationFailed(PaymentException):
|
||
|
|
"""Exception raised when subscription creation fails"""
|
||
|
|
def __init__(self, message: str = "Subscription creation failed"):
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
class PaymentProviderError(PaymentException):
|
||
|
|
"""Exception raised when there's an error with the payment provider"""
|
||
|
|
def __init__(self, message: str = "Payment provider error"):
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
|
||
|
|
class PaymentVerificationError(PaymentException):
|
||
|
|
"""Exception raised when payment verification fails"""
|
||
|
|
def __init__(self, message: str = "Payment verification failed"):
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
|
||
|
|
class SetupIntentError(PaymentException):
|
||
|
|
"""Exception raised when SetupIntent operations fail"""
|
||
|
|
def __init__(self, message: str = "SetupIntent operation failed"):
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
class SubscriptionUpdateFailed(PaymentException):
|
||
|
|
"""Exception raised when subscription update fails"""
|
||
|
|
def __init__(self, message: str = "Subscription update failed"):
|
||
|
|
super().__init__(message)
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class PaymentServiceError(PaymentException):
|
||
|
|
"""General payment service error"""
|
||
|
|
def __init__(self, message: str = "Payment service error"):
|
||
|
|
super().__init__(message)
|