Debian Codegraph @

stripe/issuing/_dispute.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._list_object import ListObject
6 from stripe._listable_api_resource import ListableAPIResource
7 from stripe._stripe_object import StripeObject
8 from stripe._updateable_api_resource import UpdateableAPIResource
9 from stripe._util import class_method_variant, sanitize_id
10 from typing import ClassVar, Dict, List, Optional, cast, overload
11 from typing_extensions import Literal, Unpack, TYPE_CHECKING
12
13 if TYPE_CHECKING:
14 from stripe._balance_transaction import BalanceTransaction
15 from stripe._file import File
16 from stripe.issuing._transaction import Transaction
17 from stripe.params.issuing._dispute_create_params import (
18 DisputeCreateParams,
19 )
20 from stripe.params.issuing._dispute_list_params import DisputeListParams
21 from stripe.params.issuing._dispute_modify_params import (
22 DisputeModifyParams,
23 )
24 from stripe.params.issuing._dispute_retrieve_params import (
25 DisputeRetrieveParams,
26 )
27 from stripe.params.issuing._dispute_submit_params import (
28 DisputeSubmitParams,
29 )
30
31
32 class Dispute(
33 CreateableAPIResource["Dispute"],
34 ListableAPIResource["Dispute"],
35 UpdateableAPIResource["Dispute"],
36 ):
37 """
38 As a [card issuer](https://docs.stripe.com/issuing), you can dispute transactions that the cardholder does not recognize, suspects to be fraudulent, or has other issues with.
39
40 Related guide: [Issuing disputes](https://docs.stripe.com/issuing/purchases/disputes)
41 """
42
43 OBJECT_NAME: ClassVar[Literal["issuing.dispute"]] = "issuing.dispute"
44
45 class Evidence(StripeObject):
46 class Canceled(StripeObject):
47 additional_documentation: Optional[ExpandableField["File"]]
48 """
49 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
50 """
51 canceled_at: Optional[int]
52 """
53 Date when order was canceled.
54 """
55 cancellation_policy_provided: Optional[bool]
56 """
57 Whether the cardholder was provided with a cancellation policy.
58 """
59 cancellation_reason: Optional[str]
60 """
61 Reason for canceling the order.
62 """
63 expected_at: Optional[int]
64 """
65 Date when the cardholder expected to receive the product.
66 """
67 explanation: Optional[str]
68 """
69 Explanation of why the cardholder is disputing this transaction.
70 """
71 product_description: Optional[str]
72 """
73 Description of the merchandise or service that was purchased.
74 """
75 product_type: Optional[Literal["merchandise", "service"]]
76 """
77 Whether the product was a merchandise or service.
78 """
79 return_status: Optional[Literal["merchant_rejected", "successful"]]
80 """
81 Result of cardholder's attempt to return the product.
82 """
83 returned_at: Optional[int]
84 """
85 Date when the product was returned or attempted to be returned.
86 """
87
88 class Duplicate(StripeObject):
89 additional_documentation: Optional[ExpandableField["File"]]
90 """
91 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
92 """
93 card_statement: Optional[ExpandableField["File"]]
94 """
95 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Copy of the card statement showing that the product had already been paid for.
96 """
97 cash_receipt: Optional[ExpandableField["File"]]
98 """
99 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Copy of the receipt showing that the product had been paid for in cash.
100 """
101 check_image: Optional[ExpandableField["File"]]
102 """
103 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Image of the front and back of the check that was used to pay for the product.
104 """
105 explanation: Optional[str]
106 """
107 Explanation of why the cardholder is disputing this transaction.
108 """
109 original_transaction: Optional[str]
110 """
111 Transaction (e.g., ipi_...) that the disputed transaction is a duplicate of. Of the two or more transactions that are copies of each other, this is original undisputed one.
112 """
113
114 class Fraudulent(StripeObject):
115 additional_documentation: Optional[ExpandableField["File"]]
116 """
117 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
118 """
119 explanation: Optional[str]
120 """
121 Explanation of why the cardholder is disputing this transaction.
122 """
123
124 class MerchandiseNotAsDescribed(StripeObject):
125 additional_documentation: Optional[ExpandableField["File"]]
126 """
127 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
128 """
129 explanation: Optional[str]
130 """
131 Explanation of why the cardholder is disputing this transaction.
132 """
133 received_at: Optional[int]
134 """
135 Date when the product was received.
136 """
137 return_description: Optional[str]
138 """
139 Description of the cardholder's attempt to return the product.
140 """
141 return_status: Optional[Literal["merchant_rejected", "successful"]]
142 """
143 Result of cardholder's attempt to return the product.
144 """
145 returned_at: Optional[int]
146 """
147 Date when the product was returned or attempted to be returned.
148 """
149
150 class NoValidAuthorization(StripeObject):
151 additional_documentation: Optional[ExpandableField["File"]]
152 """
153 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
154 """
155 explanation: Optional[str]
156 """
157 Explanation of why the cardholder is disputing this transaction.
158 """
159
160 class NotReceived(StripeObject):
161 additional_documentation: Optional[ExpandableField["File"]]
162 """
163 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
164 """
165 expected_at: Optional[int]
166 """
167 Date when the cardholder expected to receive the product.
168 """
169 explanation: Optional[str]
170 """
171 Explanation of why the cardholder is disputing this transaction.
172 """
173 product_description: Optional[str]
174 """
175 Description of the merchandise or service that was purchased.
176 """
177 product_type: Optional[Literal["merchandise", "service"]]
178 """
179 Whether the product was a merchandise or service.
180 """
181
182 class Other(StripeObject):
183 additional_documentation: Optional[ExpandableField["File"]]
184 """
185 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
186 """
187 explanation: Optional[str]
188 """
189 Explanation of why the cardholder is disputing this transaction.
190 """
191 product_description: Optional[str]
192 """
193 Description of the merchandise or service that was purchased.
194 """
195 product_type: Optional[Literal["merchandise", "service"]]
196 """
197 Whether the product was a merchandise or service.
198 """
199
200 class ServiceNotAsDescribed(StripeObject):
201 additional_documentation: Optional[ExpandableField["File"]]
202 """
203 (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
204 """
205 canceled_at: Optional[int]
206 """
207 Date when order was canceled.
208 """
209 cancellation_reason: Optional[str]
210 """
211 Reason for canceling the order.
212 """
213 explanation: Optional[str]
214 """
215 Explanation of why the cardholder is disputing this transaction.
216 """
217 received_at: Optional[int]
218 """
219 Date when the product was received.
220 """
221
222 canceled: Optional[Canceled]
223 duplicate: Optional[Duplicate]
224 fraudulent: Optional[Fraudulent]
225 merchandise_not_as_described: Optional[MerchandiseNotAsDescribed]
226 no_valid_authorization: Optional[NoValidAuthorization]
227 not_received: Optional[NotReceived]
228 other: Optional[Other]
229 reason: Literal[
230 "canceled",
231 "duplicate",
232 "fraudulent",
233 "merchandise_not_as_described",
234 "no_valid_authorization",
235 "not_received",
236 "other",
237 "service_not_as_described",
238 ]
239 """
240 The reason for filing the dispute. Its value will match the field containing the evidence.
241 """
242 service_not_as_described: Optional[ServiceNotAsDescribed]
243 _inner_class_types = {
244 "canceled": Canceled,
245 "duplicate": Duplicate,
246 "fraudulent": Fraudulent,
247 "merchandise_not_as_described": MerchandiseNotAsDescribed,
248 "no_valid_authorization": NoValidAuthorization,
249 "not_received": NotReceived,
250 "other": Other,
251 "service_not_as_described": ServiceNotAsDescribed,
252 }
253
254 class Treasury(StripeObject):
255 debit_reversal: Optional[str]
256 """
257 The Treasury [DebitReversal](https://docs.stripe.com/api/treasury/debit_reversals) representing this Issuing dispute
258 """
259 received_debit: str
260 """
261 The Treasury [ReceivedDebit](https://docs.stripe.com/api/treasury/received_debits) that is being disputed.
262 """
263
264 amount: int
265 """
266 Disputed amount in the card's currency and in the [smallest currency unit](https://docs.stripe.com/currencies#zero-decimal). Usually the amount of the `transaction`, but can differ (usually because of currency fluctuation).
267 """
268 balance_transactions: Optional[List["BalanceTransaction"]]
269 """
270 List of balance transactions associated with the dispute.
271 """
272 created: int
273 """
274 Time at which the object was created. Measured in seconds since the Unix epoch.
275 """
276 currency: str
277 """
278 The currency the `transaction` was made in.
279 """
280 evidence: Evidence
281 id: str
282 """
283 Unique identifier for the object.
284 """
285 livemode: bool
286 """
287 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
288 """
289 loss_reason: Optional[
290 Literal[
291 "cardholder_authentication_issuer_liability",
292 "eci5_token_transaction_with_tavv",
293 "excess_disputes_in_timeframe",
294 "has_not_met_the_minimum_dispute_amount_requirements",
295 "invalid_duplicate_dispute",
296 "invalid_incorrect_amount_dispute",
297 "invalid_no_authorization",
298 "invalid_use_of_disputes",
299 "merchandise_delivered_or_shipped",
300 "merchandise_or_service_as_described",
301 "not_cancelled",
302 "other",
303 "refund_issued",
304 "submitted_beyond_allowable_time_limit",
305 "transaction_3ds_required",
306 "transaction_approved_after_prior_fraud_dispute",
307 "transaction_authorized",
308 "transaction_electronically_read",
309 "transaction_qualifies_for_visa_easy_payment_service",
310 "transaction_unattended",
311 ]
312 ]
313 """
314 The enum that describes the dispute loss outcome. If the dispute is not lost, this field will be absent. New enum values may be added in the future, so be sure to handle unknown values.
315 """
316 metadata: Dict[str, str]
317 """
318 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.
319 """
320 object: Literal["issuing.dispute"]
321 """
322 String representing the object's type. Objects of the same type share the same value.
323 """
324 status: Literal["expired", "lost", "submitted", "unsubmitted", "won"]
325 """
326 Current status of the dispute.
327 """
328 transaction: ExpandableField["Transaction"]
329 """
330 The transaction being disputed.
331 """
332 treasury: Optional[Treasury]
333 """
334 [Treasury](https://docs.stripe.com/api/treasury) details related to this dispute if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts
335 """
336
337 @classmethod
338 def create(cls, **params: Unpack["DisputeCreateParams"]) -> "Dispute":
339 """
340 Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence) for more details about evidence requirements.
341 """
342 return cast(
343 "Dispute",
344 cls._static_request(
345 "post",
346 cls.class_url(),
347 params=params,
348 ),
349 )
350
351 @classmethod
352 async def create_async(
353 cls, **params: Unpack["DisputeCreateParams"]
354 ) -> "Dispute":
355 """
356 Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence) for more details about evidence requirements.
357 """
358 return cast(
359 "Dispute",
360 await cls._static_request_async(
361 "post",
362 cls.class_url(),
363 params=params,
364 ),
365 )
366
367 @classmethod
368 def list(
369 cls, **params: Unpack["DisputeListParams"]
370 ) -> ListObject["Dispute"]:
371 """
372 Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
373 """
374 result = cls._static_request(
375 "get",
376 cls.class_url(),
377 params=params,
378 )
379 if not isinstance(result, ListObject):
380 raise TypeError(
381 "Expected list object from API, got %s"
382 % (type(result).__name__)
383 )
384
385 return result
386
387 @classmethod
388 async def list_async(
389 cls, **params: Unpack["DisputeListParams"]
390 ) -> ListObject["Dispute"]:
391 """
392 Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
393 """
394 result = await cls._static_request_async(
395 "get",
396 cls.class_url(),
397 params=params,
398 )
399 if not isinstance(result, ListObject):
400 raise TypeError(
401 "Expected list object from API, got %s"
402 % (type(result).__name__)
403 )
404
405 return result
406
407 @classmethod
408 def modify(
409 cls, id: str, **params: Unpack["DisputeModifyParams"]
410 ) -> "Dispute":
411 """
412 Updates the specified Issuing Dispute object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Properties on the evidence object can be unset by passing in an empty string.
413 """
414 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
415 return cast(
416 "Dispute",
417 cls._static_request(
418 "post",
419 url,
420 params=params,
421 ),
422 )
423
424 @classmethod
425 async def modify_async(
426 cls, id: str, **params: Unpack["DisputeModifyParams"]
427 ) -> "Dispute":
428 """
429 Updates the specified Issuing Dispute object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Properties on the evidence object can be unset by passing in an empty string.
430 """
431 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
432 return cast(
433 "Dispute",
434 await cls._static_request_async(
435 "post",
436 url,
437 params=params,
438 ),
439 )
440
441 @classmethod
442 def retrieve(
443 cls, id: str, **params: Unpack["DisputeRetrieveParams"]
444 ) -> "Dispute":
445 """
446 Retrieves an Issuing Dispute object.
447 """
448 instance = cls(id, **params)
449 instance.refresh()
450 return instance
451
452 @classmethod
453 async def retrieve_async(
454 cls, id: str, **params: Unpack["DisputeRetrieveParams"]
455 ) -> "Dispute":
456 """
457 Retrieves an Issuing Dispute object.
458 """
459 instance = cls(id, **params)
460 await instance.refresh_async()
461 return instance
462
463 @classmethod
464 def _cls_submit(
465 cls, dispute: str, **params: Unpack["DisputeSubmitParams"]
466 ) -> "Dispute":
467 """
468 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
469 """
470 return cast(
471 "Dispute",
472 cls._static_request(
473 "post",
474 "/v1/issuing/disputes/{dispute}/submit".format(
475 dispute=sanitize_id(dispute)
476 ),
477 params=params,
478 ),
479 )
480
481 @overload
482 @staticmethod
483 def submit(
484 dispute: str, **params: Unpack["DisputeSubmitParams"]
485 ) -> "Dispute":
486 """
487 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
488 """
489 ...
490
491 @overload
492 def submit(self, **params: Unpack["DisputeSubmitParams"]) -> "Dispute":
493 """
494 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
495 """
496 ...
497
498 @class_method_variant("_cls_submit")
499 def submit( # pyright: ignore[reportGeneralTypeIssues]
500 self, **params: Unpack["DisputeSubmitParams"]
501 ) -> "Dispute":
502 """
503 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
504 """
505 return cast(
506 "Dispute",
507 self._request(
508 "post",
509 "/v1/issuing/disputes/{dispute}/submit".format(
510 dispute=sanitize_id(self.get("id"))
511 ),
512 params=params,
513 ),
514 )
515
516 @classmethod
517 async def _cls_submit_async(
518 cls, dispute: str, **params: Unpack["DisputeSubmitParams"]
519 ) -> "Dispute":
520 """
521 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
522 """
523 return cast(
524 "Dispute",
525 await cls._static_request_async(
526 "post",
527 "/v1/issuing/disputes/{dispute}/submit".format(
528 dispute=sanitize_id(dispute)
529 ),
530 params=params,
531 ),
532 )
533
534 @overload
535 @staticmethod
536 async def submit_async(
537 dispute: str, **params: Unpack["DisputeSubmitParams"]
538 ) -> "Dispute":
539 """
540 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
541 """
542 ...
543
544 @overload
545 async def submit_async(
546 self, **params: Unpack["DisputeSubmitParams"]
547 ) -> "Dispute":
548 """
549 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
550 """
551 ...
552
553 @class_method_variant("_cls_submit_async")
554 async def submit_async( # pyright: ignore[reportGeneralTypeIssues]
555 self, **params: Unpack["DisputeSubmitParams"]
556 ) -> "Dispute":
557 """
558 Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
559 """
560 return cast(
561 "Dispute",
562 await self._request_async(
563 "post",
564 "/v1/issuing/disputes/{dispute}/submit".format(
565 dispute=sanitize_id(self.get("id"))
566 ),
567 params=params,
568 ),
569 )
570
571 _inner_class_types = {"evidence": Evidence, "treasury": Treasury}