Debian Codegraph @

stripe/treasury/_received_debit.py

raw
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 stripe._stripe_object import StripeObject
7 from stripe._test_helpers import APIResourceTestHelpers
8 from typing import ClassVar, Optional, cast
9 from typing_extensions import Literal, Type, Unpack, TYPE_CHECKING
10
11 if TYPE_CHECKING:
12 from stripe.params.treasury._received_debit_create_params import (
13 ReceivedDebitCreateParams,
14 )
15 from stripe.params.treasury._received_debit_list_params import (
16 ReceivedDebitListParams,
17 )
18 from stripe.params.treasury._received_debit_retrieve_params import (
19 ReceivedDebitRetrieveParams,
20 )
21 from stripe.treasury._transaction import Transaction
22
23
24 class ReceivedDebit(ListableAPIResource["ReceivedDebit"]):
25 """
26 ReceivedDebits represent funds pulled from a [FinancialAccount](https://api.stripe.com#financial_accounts). These are not initiated from the FinancialAccount.
27 """
28
29 OBJECT_NAME: ClassVar[Literal["treasury.received_debit"]] = (
30 "treasury.received_debit"
31 )
32
33 class InitiatingPaymentMethodDetails(StripeObject):
34 class BillingDetails(StripeObject):
35 class Address(StripeObject):
36 city: Optional[str]
37 """
38 City, district, suburb, town, or village.
39 """
40 country: Optional[str]
41 """
42 Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
43 """
44 line1: Optional[str]
45 """
46 Address line 1, such as the street, PO Box, or company name.
47 """
48 line2: Optional[str]
49 """
50 Address line 2, such as the apartment, suite, unit, or building.
51 """
52 postal_code: Optional[str]
53 """
54 ZIP or postal code.
55 """
56 state: Optional[str]
57 """
58 State, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
59 """
60
61 address: Address
62 email: Optional[str]
63 """
64 Email address.
65 """
66 name: Optional[str]
67 """
68 Full name.
69 """
70 _inner_class_types = {"address": Address}
71
72 class FinancialAccount(StripeObject):
73 id: str
74 """
75 The FinancialAccount ID.
76 """
77 network: Literal["stripe"]
78 """
79 The rails the ReceivedCredit was sent over. A FinancialAccount can only send funds over `stripe`.
80 """
81
82 class UsBankAccount(StripeObject):
83 bank_name: Optional[str]
84 """
85 Bank name.
86 """
87 last4: Optional[str]
88 """
89 The last four digits of the bank account number.
90 """
91 routing_number: Optional[str]
92 """
93 The routing number for the bank account.
94 """
95
96 balance: Optional[Literal["payments"]]
97 """
98 Set when `type` is `balance`.
99 """
100 billing_details: BillingDetails
101 financial_account: Optional[FinancialAccount]
102 issuing_card: Optional[str]
103 """
104 Set when `type` is `issuing_card`. This is an [Issuing Card](https://api.stripe.com#issuing_cards) ID.
105 """
106 type: Literal[
107 "balance",
108 "financial_account",
109 "issuing_card",
110 "stripe",
111 "us_bank_account",
112 ]
113 """
114 Polymorphic type matching the originating money movement's source. This can be an external account, a Stripe balance, or a FinancialAccount.
115 """
116 us_bank_account: Optional[UsBankAccount]
117 _inner_class_types = {
118 "billing_details": BillingDetails,
119 "financial_account": FinancialAccount,
120 "us_bank_account": UsBankAccount,
121 }
122
123 class LinkedFlows(StripeObject):
124 debit_reversal: Optional[str]
125 """
126 The DebitReversal created as a result of this ReceivedDebit being reversed.
127 """
128 inbound_transfer: Optional[str]
129 """
130 Set if the ReceivedDebit is associated with an InboundTransfer's return of funds.
131 """
132 issuing_authorization: Optional[str]
133 """
134 Set if the ReceivedDebit was created due to an [Issuing Authorization](https://api.stripe.com#issuing_authorizations) object.
135 """
136 issuing_transaction: Optional[str]
137 """
138 Set if the ReceivedDebit is also viewable as an [Issuing Dispute](https://api.stripe.com#issuing_disputes) object.
139 """
140 payout: Optional[str]
141 """
142 Set if the ReceivedDebit was created due to a [Payout](https://api.stripe.com#payouts) object.
143 """
144 topup: Optional[str]
145 """
146 Set if the ReceivedDebit was created due to a [Topup](https://api.stripe.com#topups) object.
147 """
148
149 class ReversalDetails(StripeObject):
150 deadline: Optional[int]
151 """
152 Time before which a ReceivedDebit can be reversed.
153 """
154 restricted_reason: Optional[
155 Literal[
156 "already_reversed",
157 "deadline_passed",
158 "network_restricted",
159 "other",
160 "source_flow_restricted",
161 ]
162 ]
163 """
164 Set if a ReceivedDebit can't be reversed.
165 """
166
167 amount: int
168 """
169 Amount (in cents) transferred.
170 """
171 created: int
172 """
173 Time at which the object was created. Measured in seconds since the Unix epoch.
174 """
175 currency: str
176 """
177 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).
178 """
179 description: str
180 """
181 An arbitrary string attached to the object. Often useful for displaying to users.
182 """
183 failure_code: Optional[
184 Literal[
185 "account_closed",
186 "account_frozen",
187 "insufficient_funds",
188 "international_transaction",
189 "other",
190 ]
191 ]
192 """
193 Reason for the failure. A ReceivedDebit might fail because the FinancialAccount doesn't have sufficient funds, is closed, or is frozen.
194 """
195 financial_account: Optional[str]
196 """
197 The FinancialAccount that funds were pulled from.
198 """
199 hosted_regulatory_receipt_url: Optional[str]
200 """
201 A [hosted transaction receipt](https://docs.stripe.com/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.
202 """
203 id: str
204 """
205 Unique identifier for the object.
206 """
207 initiating_payment_method_details: Optional[InitiatingPaymentMethodDetails]
208 linked_flows: LinkedFlows
209 livemode: bool
210 """
211 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
212 """
213 network: Literal["ach", "card", "stripe"]
214 """
215 The network used for the ReceivedDebit.
216 """
217 object: Literal["treasury.received_debit"]
218 """
219 String representing the object's type. Objects of the same type share the same value.
220 """
221 reversal_details: Optional[ReversalDetails]
222 """
223 Details describing when a ReceivedDebit might be reversed.
224 """
225 status: Literal["failed", "succeeded"]
226 """
227 Status of the ReceivedDebit. ReceivedDebits are created with a status of either `succeeded` (approved) or `failed` (declined). The failure reason can be found under the `failure_code`.
228 """
229 transaction: Optional[ExpandableField["Transaction"]]
230 """
231 The Transaction associated with this object.
232 """
233
234 @classmethod
235 def list(
236 cls, **params: Unpack["ReceivedDebitListParams"]
237 ) -> ListObject["ReceivedDebit"]:
238 """
239 Returns a list of ReceivedDebits.
240 """
241 result = cls._static_request(
242 "get",
243 cls.class_url(),
244 params=params,
245 )
246 if not isinstance(result, ListObject):
247 raise TypeError(
248 "Expected list object from API, got %s"
249 % (type(result).__name__)
250 )
251
252 return result
253
254 @classmethod
255 async def list_async(
256 cls, **params: Unpack["ReceivedDebitListParams"]
257 ) -> ListObject["ReceivedDebit"]:
258 """
259 Returns a list of ReceivedDebits.
260 """
261 result = await cls._static_request_async(
262 "get",
263 cls.class_url(),
264 params=params,
265 )
266 if not isinstance(result, ListObject):
267 raise TypeError(
268 "Expected list object from API, got %s"
269 % (type(result).__name__)
270 )
271
272 return result
273
274 @classmethod
275 def retrieve(
276 cls, id: str, **params: Unpack["ReceivedDebitRetrieveParams"]
277 ) -> "ReceivedDebit":
278 """
279 Retrieves the details of an existing ReceivedDebit by passing the unique ReceivedDebit ID from the ReceivedDebit list
280 """
281 instance = cls(id, **params)
282 instance.refresh()
283 return instance
284
285 @classmethod
286 async def retrieve_async(
287 cls, id: str, **params: Unpack["ReceivedDebitRetrieveParams"]
288 ) -> "ReceivedDebit":
289 """
290 Retrieves the details of an existing ReceivedDebit by passing the unique ReceivedDebit ID from the ReceivedDebit list
291 """
292 instance = cls(id, **params)
293 await instance.refresh_async()
294 return instance
295
296 class TestHelpers(APIResourceTestHelpers["ReceivedDebit"]):
297 _resource_cls: Type["ReceivedDebit"]
298
299 @classmethod
300 def create(
301 cls, **params: Unpack["ReceivedDebitCreateParams"]
302 ) -> "ReceivedDebit":
303 """
304 Use this endpoint to simulate a test mode ReceivedDebit initiated by a third party. In live mode, you can't directly create ReceivedDebits initiated by third parties.
305 """
306 return cast(
307 "ReceivedDebit",
308 cls._static_request(
309 "post",
310 "/v1/test_helpers/treasury/received_debits",
311 params=params,
312 ),
313 )
314
315 @classmethod
316 async def create_async(
317 cls, **params: Unpack["ReceivedDebitCreateParams"]
318 ) -> "ReceivedDebit":
319 """
320 Use this endpoint to simulate a test mode ReceivedDebit initiated by a third party. In live mode, you can't directly create ReceivedDebits initiated by third parties.
321 """
322 return cast(
323 "ReceivedDebit",
324 await cls._static_request_async(
325 "post",
326 "/v1/test_helpers/treasury/received_debits",
327 params=params,
328 ),
329 )
330
331 @property
332 def test_helpers(self):
333 return self.TestHelpers(self)
334
335 _inner_class_types = {
336 "initiating_payment_method_details": InitiatingPaymentMethodDetails,
337 "linked_flows": LinkedFlows,
338 "reversal_details": ReversalDetails,
339 }
340
341
342 ReceivedDebit.TestHelpers._resource_cls = ReceivedDebit