Debian Codegraph @

stripe/radar/_payment_evaluation.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._createable_api_resource import CreateableAPIResource
4 from stripe._expandable_field import ExpandableField
5 from stripe._stripe_object import StripeObject
6 from typing import ClassVar, Dict, List, Optional, cast
7 from typing_extensions import Literal, Unpack, TYPE_CHECKING
8
9 if TYPE_CHECKING:
10 from stripe._payment_method import PaymentMethod
11 from stripe.params.radar._payment_evaluation_create_params import (
12 PaymentEvaluationCreateParams,
13 )
14
15
16 class PaymentEvaluation(CreateableAPIResource["PaymentEvaluation"]):
17 """
18 Payment Evaluations represent the risk lifecycle of an externally processed payment. It includes the Radar risk score from Stripe, payment outcome taken by the merchant or processor, and any post transaction events, such as refunds or disputes. See the [Radar API guide](https://docs.stripe.com/radar/multiprocessor) for integration steps.
19 """
20
21 OBJECT_NAME: ClassVar[Literal["radar.payment_evaluation"]] = (
22 "radar.payment_evaluation"
23 )
24
25 class ClientDeviceMetadataDetails(StripeObject):
26 radar_session: str
27 """
28 ID for the Radar Session associated with the payment evaluation. A [Radar Session](https://docs.stripe.com/radar/radar-session) is a snapshot of the browser metadata and device details that help Radar make more accurate predictions on your payments.
29 """
30
31 class CustomerDetails(StripeObject):
32 customer: Optional[str]
33 """
34 The ID of the customer associated with the payment evaluation.
35 """
36 customer_account: Optional[str]
37 """
38 The ID of the Account representing the customer associated with the payment evaluation.
39 """
40 email: Optional[str]
41 """
42 The customer's email address.
43 """
44 name: Optional[str]
45 """
46 The customer's full name or business name.
47 """
48 phone: Optional[str]
49 """
50 The customer's phone number.
51 """
52
53 class Event(StripeObject):
54 class DisputeOpened(StripeObject):
55 amount: int
56 """
57 Amount to dispute for this payment. A positive integer representing how much to charge in [the smallest currency unit](https://docs.stripe.com/currencies#zero-decimal) (for example, 100 cents to charge 1.00 USD or 100 to charge 100 Yen, a zero-decimal currency).
58 """
59 currency: str
60 """
61 Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
62 """
63 reason: Literal[
64 "account_not_available",
65 "credit_not_processed",
66 "customer_initiated",
67 "duplicate",
68 "fraudulent",
69 "general",
70 "noncompliant",
71 "product_not_received",
72 "product_unacceptable",
73 "subscription_canceled",
74 "unrecognized",
75 ]
76 """
77 Reason given by cardholder for dispute.
78 """
79
80 class EarlyFraudWarningReceived(StripeObject):
81 fraud_type: Literal[
82 "made_with_lost_card",
83 "made_with_stolen_card",
84 "other",
85 "unauthorized_use_of_card",
86 ]
87 """
88 The type of fraud labeled by the issuer.
89 """
90
91 class Refunded(StripeObject):
92 amount: int
93 """
94 Amount refunded for this payment. A positive integer representing how much to charge in [the smallest currency unit](https://docs.stripe.com/currencies#zero-decimal) (for example, 100 cents to charge 1.00 USD or 100 to charge 100 Yen, a zero-decimal currency).
95 """
96 currency: str
97 """
98 Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
99 """
100 reason: Literal[
101 "duplicate", "fraudulent", "other", "requested_by_customer"
102 ]
103 """
104 Indicates the reason for the refund.
105 """
106
107 class UserInterventionRaised(StripeObject):
108 class Custom(StripeObject):
109 type: str
110 """
111 Custom type of user intervention raised. The string must use a snake case description for the type of intervention performed.
112 """
113
114 custom: Optional[Custom]
115 """
116 User intervention raised custom event details attached to this payment evaluation
117 """
118 key: str
119 """
120 Unique identifier for the user intervention event.
121 """
122 type: Literal["3ds", "captcha", "custom"]
123 """
124 Type of user intervention raised.
125 """
126 _inner_class_types = {"custom": Custom}
127
128 class UserInterventionResolved(StripeObject):
129 key: str
130 """
131 Unique ID of this intervention. Use this to provide the result.
132 """
133 outcome: Optional[Literal["abandoned", "failed", "passed"]]
134 """
135 Result of the intervention if it has been completed.
136 """
137
138 dispute_opened: Optional[DisputeOpened]
139 """
140 Dispute opened event details attached to this payment evaluation.
141 """
142 early_fraud_warning_received: Optional[EarlyFraudWarningReceived]
143 """
144 Early Fraud Warning Received event details attached to this payment evaluation.
145 """
146 occurred_at: int
147 """
148 Timestamp when the event occurred.
149 """
150 refunded: Optional[Refunded]
151 """
152 Refunded Event details attached to this payment evaluation.
153 """
154 type: Literal[
155 "dispute_opened",
156 "early_fraud_warning_received",
157 "refunded",
158 "user_intervention_raised",
159 "user_intervention_resolved",
160 ]
161 """
162 Indicates the type of event attached to the payment evaluation.
163 """
164 user_intervention_raised: Optional[UserInterventionRaised]
165 """
166 User intervention raised event details attached to this payment evaluation
167 """
168 user_intervention_resolved: Optional[UserInterventionResolved]
169 """
170 User Intervention Resolved Event details attached to this payment evaluation
171 """
172 _inner_class_types = {
173 "dispute_opened": DisputeOpened,
174 "early_fraud_warning_received": EarlyFraudWarningReceived,
175 "refunded": Refunded,
176 "user_intervention_raised": UserInterventionRaised,
177 "user_intervention_resolved": UserInterventionResolved,
178 }
179
180 class Insights(StripeObject):
181 class FraudulentDispute(StripeObject):
182 recommended_action: Literal["block", "continue"]
183 """
184 Recommended action based on the risk score. Possible values are `block` and `continue`.
185 """
186 risk_score: int
187 """
188 Stripe Radar's evaluation of the risk level of the payment. Possible values for evaluated payments are between 0 and 100, with higher scores indicating higher risk.
189 """
190
191 evaluated_at: int
192 """
193 The timestamp when the evaluation was performed.
194 """
195 fraudulent_dispute: FraudulentDispute
196 """
197 Scores, insights and recommended action for one scorer for this PaymentEvaluation.
198 """
199 _inner_class_types = {"fraudulent_dispute": FraudulentDispute}
200
201 class Outcome(StripeObject):
202 class MerchantBlocked(StripeObject):
203 reason: Literal[
204 "authentication_required",
205 "blocked_for_fraud",
206 "invalid_payment",
207 "other",
208 ]
209 """
210 The reason the payment was blocked by the merchant.
211 """
212
213 class Rejected(StripeObject):
214 class Card(StripeObject):
215 address_line1_check: Literal[
216 "fail", "pass", "unavailable", "unchecked"
217 ]
218 """
219 Result of the address line 1 check.
220 """
221 address_postal_code_check: Literal[
222 "fail", "pass", "unavailable", "unchecked"
223 ]
224 """
225 Indicates whether the cardholder provided a postal code and if it matched the cardholder's billing address.
226 """
227 cvc_check: Literal["fail", "pass", "unavailable", "unchecked"]
228 """
229 Result of the CVC check.
230 """
231 reason: Literal[
232 "authentication_failed",
233 "do_not_honor",
234 "expired",
235 "incorrect_cvc",
236 "incorrect_number",
237 "incorrect_postal_code",
238 "insufficient_funds",
239 "invalid_account",
240 "lost_card",
241 "other",
242 "processing_error",
243 "reported_stolen",
244 "try_again_later",
245 ]
246 """
247 Card issuer's reason for the network decline.
248 """
249
250 card: Optional[Card]
251 """
252 Details of an rejected card outcome attached to this payment evaluation.
253 """
254 _inner_class_types = {"card": Card}
255
256 class Succeeded(StripeObject):
257 class Card(StripeObject):
258 address_line1_check: Literal[
259 "fail", "pass", "unavailable", "unchecked"
260 ]
261 """
262 Result of the address line 1 check.
263 """
264 address_postal_code_check: Literal[
265 "fail", "pass", "unavailable", "unchecked"
266 ]
267 """
268 Indicates whether the cardholder provided a postal code and if it matched the cardholder's billing address.
269 """
270 cvc_check: Literal["fail", "pass", "unavailable", "unchecked"]
271 """
272 Result of the CVC check.
273 """
274
275 card: Optional[Card]
276 """
277 Details of an succeeded card outcome attached to this payment evaluation.
278 """
279 _inner_class_types = {"card": Card}
280
281 merchant_blocked: Optional[MerchantBlocked]
282 """
283 Details of a merchant_blocked outcome attached to this payment evaluation.
284 """
285 payment_intent_id: Optional[str]
286 """
287 The PaymentIntent ID associated with the payment evaluation.
288 """
289 rejected: Optional[Rejected]
290 """
291 Details of an rejected outcome attached to this payment evaluation.
292 """
293 succeeded: Optional[Succeeded]
294 """
295 Details of a succeeded outcome attached to this payment evaluation.
296 """
297 type: Literal["failed", "merchant_blocked", "rejected", "succeeded"]
298 """
299 Indicates the outcome of the payment evaluation.
300 """
301 _inner_class_types = {
302 "merchant_blocked": MerchantBlocked,
303 "rejected": Rejected,
304 "succeeded": Succeeded,
305 }
306
307 class PaymentDetails(StripeObject):
308 class MoneyMovementDetails(StripeObject):
309 class Card(StripeObject):
310 customer_presence: Optional[
311 Literal["off_session", "on_session"]
312 ]
313 """
314 Describes the presence of the customer during the payment.
315 """
316 payment_type: Optional[
317 Literal[
318 "one_off",
319 "recurring",
320 "setup_one_off",
321 "setup_recurring",
322 ]
323 ]
324 """
325 Describes the type of payment.
326 """
327
328 card: Optional[Card]
329 """
330 Describes card money movement details for the payment evaluation.
331 """
332 money_movement_type: Literal["card"]
333 """
334 Describes the type of money movement. Currently only `card` is supported.
335 """
336 _inner_class_types = {"card": Card}
337
338 class PaymentMethodDetails(StripeObject):
339 class BillingDetails(StripeObject):
340 class Address(StripeObject):
341 city: Optional[str]
342 """
343 City, district, suburb, town, or village.
344 """
345 country: Optional[str]
346 """
347 Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
348 """
349 line1: Optional[str]
350 """
351 Address line 1, such as the street, PO Box, or company name.
352 """
353 line2: Optional[str]
354 """
355 Address line 2, such as the apartment, suite, unit, or building.
356 """
357 postal_code: Optional[str]
358 """
359 ZIP or postal code.
360 """
361 state: Optional[str]
362 """
363 State, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
364 """
365
366 address: Address
367 """
368 Address data.
369 """
370 email: Optional[str]
371 """
372 Email address.
373 """
374 name: Optional[str]
375 """
376 Full name.
377 """
378 phone: Optional[str]
379 """
380 Billing phone number (including extension).
381 """
382 _inner_class_types = {"address": Address}
383
384 billing_details: Optional[BillingDetails]
385 """
386 Billing information associated with the payment evaluation.
387 """
388 payment_method: ExpandableField["PaymentMethod"]
389 """
390 The payment method used in this payment evaluation.
391 """
392 _inner_class_types = {"billing_details": BillingDetails}
393
394 class ShippingDetails(StripeObject):
395 class Address(StripeObject):
396 city: Optional[str]
397 """
398 City, district, suburb, town, or village.
399 """
400 country: Optional[str]
401 """
402 Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
403 """
404 line1: Optional[str]
405 """
406 Address line 1, such as the street, PO Box, or company name.
407 """
408 line2: Optional[str]
409 """
410 Address line 2, such as the apartment, suite, unit, or building.
411 """
412 postal_code: Optional[str]
413 """
414 ZIP or postal code.
415 """
416 state: Optional[str]
417 """
418 State, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
419 """
420
421 address: Address
422 """
423 Address data.
424 """
425 name: Optional[str]
426 """
427 Shipping name.
428 """
429 phone: Optional[str]
430 """
431 Shipping phone number.
432 """
433 _inner_class_types = {"address": Address}
434
435 amount: int
436 """
437 Amount intended to be collected by this payment. A positive integer representing how much to charge in the [smallest currency unit](https://docs.stripe.com/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or [equivalent in charge currency](https://docs.stripe.com/currencies#minimum-and-maximum-charge-amounts). The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
438 """
439 currency: str
440 """
441 Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
442 """
443 description: Optional[str]
444 """
445 An arbitrary string attached to the object. Often useful for displaying to users.
446 """
447 money_movement_details: Optional[MoneyMovementDetails]
448 """
449 Details about the payment's customer presence and type.
450 """
451 payment_method_details: Optional[PaymentMethodDetails]
452 """
453 Details about the payment method used for the payment.
454 """
455 shipping_details: Optional[ShippingDetails]
456 """
457 Shipping details for the payment evaluation.
458 """
459 statement_descriptor: Optional[str]
460 """
461 Payment statement descriptor.
462 """
463 _inner_class_types = {
464 "money_movement_details": MoneyMovementDetails,
465 "payment_method_details": PaymentMethodDetails,
466 "shipping_details": ShippingDetails,
467 }
468
469 client_device_metadata_details: Optional[ClientDeviceMetadataDetails]
470 """
471 Client device metadata attached to this payment evaluation.
472 """
473 created_at: int
474 """
475 Time at which the object was created. Measured in seconds since the Unix epoch.
476 """
477 customer_details: Optional[CustomerDetails]
478 """
479 Customer details attached to this payment evaluation.
480 """
481 events: Optional[List[Event]]
482 """
483 Event information associated with the payment evaluation, such as refunds, dispute, early fraud warnings, or user interventions.
484 """
485 id: str
486 """
487 Unique identifier for the object.
488 """
489 insights: Insights
490 """
491 Collection of scores and insights for this payment evaluation.
492 """
493 livemode: bool
494 """
495 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
496 """
497 metadata: Optional[Dict[str, str]]
498 """
499 Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
500 """
501 object: Literal["radar.payment_evaluation"]
502 """
503 String representing the object's type. Objects of the same type share the same value.
504 """
505 outcome: Optional[Outcome]
506 """
507 Indicates the final outcome for the payment evaluation.
508 """
509 payment_details: Optional[PaymentDetails]
510 """
511 Payment details attached to this payment evaluation.
512 """
513
514 @classmethod
515 def create(
516 cls, **params: Unpack["PaymentEvaluationCreateParams"]
517 ) -> "PaymentEvaluation":
518 """
519 Request a Radar API fraud risk score from Stripe for a payment before sending it for external processor authorization.
520 """
521 return cast(
522 "PaymentEvaluation",
523 cls._static_request(
524 "post",
525 cls.class_url(),
526 params=params,
527 ),
528 )
529
530 @classmethod
531 async def create_async(
532 cls, **params: Unpack["PaymentEvaluationCreateParams"]
533 ) -> "PaymentEvaluation":
534 """
535 Request a Radar API fraud risk score from Stripe for a payment before sending it for external processor authorization.
536 """
537 return cast(
538 "PaymentEvaluation",
539 await cls._static_request_async(
540 "post",
541 cls.class_url(),
542 params=params,
543 ),
544 )
545
546 _inner_class_types = {
547 "client_device_metadata_details": ClientDeviceMetadataDetails,
548 "customer_details": CustomerDetails,
549 "events": Event,
550 "insights": Insights,
551 "outcome": Outcome,
552 "payment_details": PaymentDetails,
553 }