| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# File generated from our OpenAPI spec |
| 3 |
from stripe._expandable_field import ExpandableField |
| 4 |
from stripe._list_object import ListObject |
| 5 |
from stripe._listable_api_resource import ListableAPIResource |
| 6 |
from typing import ClassVar, Optional |
| 7 |
from typing_extensions import Literal, Unpack, TYPE_CHECKING |
| 8 |
|
| 9 |
if TYPE_CHECKING: |
| 10 |
from stripe._charge import Charge |
| 11 |
from stripe._payment_intent import PaymentIntent |
| 12 |
from stripe.params.radar._early_fraud_warning_list_params import ( |
| 13 |
EarlyFraudWarningListParams, |
| 14 |
) |
| 15 |
from stripe.params.radar._early_fraud_warning_retrieve_params import ( |
| 16 |
EarlyFraudWarningRetrieveParams, |
| 17 |
) |
| 18 |
|
| 19 |
|
| 20 |
class EarlyFraudWarning(ListableAPIResource["EarlyFraudWarning"]): |
| 21 |
""" |
| 22 |
An early fraud warning indicates that the card issuer has notified us that a |
| 23 |
charge may be fraudulent. |
| 24 |
|
| 25 |
Related guide: [Early fraud warnings](https://docs.stripe.com/disputes/measuring#early-fraud-warnings) |
| 26 |
""" |
| 27 |
|
| 28 |
OBJECT_NAME: ClassVar[Literal["radar.early_fraud_warning"]] = ( |
| 29 |
"radar.early_fraud_warning" |
| 30 |
) |
| 31 |
actionable: bool |
| 32 |
""" |
| 33 |
An EFW is actionable if it has not received a dispute and has not been fully refunded. You may wish to proactively refund a charge that receives an EFW, in order to avoid receiving a dispute later. |
| 34 |
""" |
| 35 |
charge: ExpandableField["Charge"] |
| 36 |
""" |
| 37 |
ID of the charge this early fraud warning is for, optionally expanded. |
| 38 |
""" |
| 39 |
created: int |
| 40 |
""" |
| 41 |
Time at which the object was created. Measured in seconds since the Unix epoch. |
| 42 |
""" |
| 43 |
fraud_type: str |
| 44 |
""" |
| 45 |
The type of fraud labelled by the issuer. One of `card_never_received`, `fraudulent_card_application`, `made_with_counterfeit_card`, `made_with_lost_card`, `made_with_stolen_card`, `misc`, `unauthorized_use_of_card`. |
| 46 |
""" |
| 47 |
id: str |
| 48 |
""" |
| 49 |
Unique identifier for the object. |
| 50 |
""" |
| 51 |
livemode: bool |
| 52 |
""" |
| 53 |
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. |
| 54 |
""" |
| 55 |
object: Literal["radar.early_fraud_warning"] |
| 56 |
""" |
| 57 |
String representing the object's type. Objects of the same type share the same value. |
| 58 |
""" |
| 59 |
payment_intent: Optional[ExpandableField["PaymentIntent"]] |
| 60 |
""" |
| 61 |
ID of the Payment Intent this early fraud warning is for, optionally expanded. |
| 62 |
""" |
| 63 |
|
| 64 |
@classmethod |
| 65 |
def list( |
| 66 |
cls, **params: Unpack["EarlyFraudWarningListParams"] |
| 67 |
) -> ListObject["EarlyFraudWarning"]: |
| 68 |
""" |
| 69 |
Returns a list of early fraud warnings. |
| 70 |
""" |
| 71 |
result = cls._static_request( |
| 72 |
"get", |
| 73 |
cls.class_url(), |
| 74 |
params=params, |
| 75 |
) |
| 76 |
if not isinstance(result, ListObject): |
| 77 |
raise TypeError( |
| 78 |
"Expected list object from API, got %s" |
| 79 |
% (type(result).__name__) |
| 80 |
) |
| 81 |
|
| 82 |
return result |
| 83 |
|
| 84 |
@classmethod |
| 85 |
async def list_async( |
| 86 |
cls, **params: Unpack["EarlyFraudWarningListParams"] |
| 87 |
) -> ListObject["EarlyFraudWarning"]: |
| 88 |
""" |
| 89 |
Returns a list of early fraud warnings. |
| 90 |
""" |
| 91 |
result = await cls._static_request_async( |
| 92 |
"get", |
| 93 |
cls.class_url(), |
| 94 |
params=params, |
| 95 |
) |
| 96 |
if not isinstance(result, ListObject): |
| 97 |
raise TypeError( |
| 98 |
"Expected list object from API, got %s" |
| 99 |
% (type(result).__name__) |
| 100 |
) |
| 101 |
|
| 102 |
return result |
| 103 |
|
| 104 |
@classmethod |
| 105 |
def retrieve( |
| 106 |
cls, id: str, **params: Unpack["EarlyFraudWarningRetrieveParams"] |
| 107 |
) -> "EarlyFraudWarning": |
| 108 |
""" |
| 109 |
Retrieves the details of an early fraud warning that has previously been created. |
| 110 |
|
| 111 |
Please refer to the [early fraud warning](https://docs.stripe.com/api#early_fraud_warning_object) object reference for more details. |
| 112 |
""" |
| 113 |
instance = cls(id, **params) |
| 114 |
instance.refresh() |
| 115 |
return instance |
| 116 |
|
| 117 |
@classmethod |
| 118 |
async def retrieve_async( |
| 119 |
cls, id: str, **params: Unpack["EarlyFraudWarningRetrieveParams"] |
| 120 |
) -> "EarlyFraudWarning": |
| 121 |
""" |
| 122 |
Retrieves the details of an early fraud warning that has previously been created. |
| 123 |
|
| 124 |
Please refer to the [early fraud warning](https://docs.stripe.com/api#early_fraud_warning_object) object reference for more details. |
| 125 |
""" |
| 126 |
instance = cls(id, **params) |
| 127 |
await instance.refresh_async() |
| 128 |
return instance |