2018-10-22 10:13:41 +02:00
|
|
|
from typing import Any, Dict, Optional
|
2018-08-06 23:07:26 +02:00
|
|
|
|
|
|
|
# List of StripeError's from https://stripe.com/docs/api/python#error_handling
|
2018-10-22 10:13:41 +02:00
|
|
|
# and https://github.com/stripe/stripe-python/blob/master/stripe/error.py
|
2018-08-06 23:07:26 +02:00
|
|
|
|
2018-07-24 15:16:50 +02:00
|
|
|
class StripeError(Exception):
|
2018-10-22 10:13:41 +02:00
|
|
|
def __init__(self, message: Optional[str]=None, http_body: Optional[str]=None,
|
|
|
|
http_status: Optional[int]=None, json_body: Optional[Dict[str, Any]]=None,
|
|
|
|
headers: Optional[Dict[str, Any]]=None, code: Optional[str]=None) -> None:
|
|
|
|
...
|
|
|
|
|
2018-07-24 15:16:50 +02:00
|
|
|
http_status: str
|
2018-08-06 23:07:26 +02:00
|
|
|
json_body: Dict[str, Any]
|
2018-07-24 15:16:50 +02:00
|
|
|
|
2018-08-06 23:07:26 +02:00
|
|
|
class CardError(StripeError):
|
2018-10-22 10:13:41 +02:00
|
|
|
def __init__(self, message: str, param: str, code: str, http_body: Optional[str]=None,
|
|
|
|
http_status: Optional[int]=None, json_body: Optional[Dict[str, Any]]=None,
|
|
|
|
headers: Optional[Dict[str, Any]]=None) -> None:
|
|
|
|
...
|
2018-08-06 23:07:26 +02:00
|
|
|
|
|
|
|
class RateLimitError(StripeError):
|
|
|
|
...
|
|
|
|
|
|
|
|
class InvalidRequestError(StripeError):
|
2018-10-22 10:13:41 +02:00
|
|
|
def __init__(self, message: str, param: str, code: str, http_body: Optional[str]=None,
|
|
|
|
http_status: Optional[int]=None, json_body: Optional[Dict[str, Any]]=None,
|
|
|
|
headers: Optional[Dict[str, Any]]=None) -> None:
|
|
|
|
...
|
2018-08-06 23:07:26 +02:00
|
|
|
|
|
|
|
class AuthenticationError(StripeError):
|
|
|
|
...
|
2018-07-24 15:16:50 +02:00
|
|
|
|
2018-08-06 23:07:26 +02:00
|
|
|
class APIConnectionError(StripeError):
|
2018-10-22 10:13:41 +02:00
|
|
|
def __init__(self, message: Optional[str]=None, http_body: Optional[str]=None,
|
|
|
|
http_status: Optional[int]=None, json_body: Optional[Dict[str, Any]]=None,
|
|
|
|
headers: Optional[Dict[str, Any]]=None, code: Optional[str]=None,
|
|
|
|
should_retry: bool=False) -> None:
|
|
|
|
...
|