| 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 typing import ClassVar, Optional |
| 8 |
from typing_extensions import Literal, Unpack, TYPE_CHECKING |
| 9 |
|
| 10 |
if TYPE_CHECKING: |
| 11 |
from stripe.issuing._authorization import Authorization |
| 12 |
from stripe.params.treasury._transaction_entry_list_params import ( |
| 13 |
TransactionEntryListParams, |
| 14 |
) |
| 15 |
from stripe.params.treasury._transaction_entry_retrieve_params import ( |
| 16 |
TransactionEntryRetrieveParams, |
| 17 |
) |
| 18 |
from stripe.treasury._credit_reversal import CreditReversal |
| 19 |
from stripe.treasury._debit_reversal import DebitReversal |
| 20 |
from stripe.treasury._inbound_transfer import InboundTransfer |
| 21 |
from stripe.treasury._outbound_payment import OutboundPayment |
| 22 |
from stripe.treasury._outbound_transfer import OutboundTransfer |
| 23 |
from stripe.treasury._received_credit import ReceivedCredit |
| 24 |
from stripe.treasury._received_debit import ReceivedDebit |
| 25 |
from stripe.treasury._transaction import Transaction |
| 26 |
|
| 27 |
|
| 28 |
class TransactionEntry(ListableAPIResource["TransactionEntry"]): |
| 29 |
""" |
| 30 |
TransactionEntries represent individual units of money movements within a single [Transaction](https://api.stripe.com#transactions). |
| 31 |
""" |
| 32 |
|
| 33 |
OBJECT_NAME: ClassVar[Literal["treasury.transaction_entry"]] = ( |
| 34 |
"treasury.transaction_entry" |
| 35 |
) |
| 36 |
|
| 37 |
class BalanceImpact(StripeObject): |
| 38 |
cash: int |
| 39 |
""" |
| 40 |
The change made to funds the user can spend right now. |
| 41 |
""" |
| 42 |
inbound_pending: int |
| 43 |
""" |
| 44 |
The change made to funds that are not spendable yet, but will become available at a later time. |
| 45 |
""" |
| 46 |
outbound_pending: int |
| 47 |
""" |
| 48 |
The change made to funds in the account, but not spendable because they are being held for pending outbound flows. |
| 49 |
""" |
| 50 |
|
| 51 |
class FlowDetails(StripeObject): |
| 52 |
credit_reversal: Optional["CreditReversal"] |
| 53 |
""" |
| 54 |
You can reverse some [ReceivedCredits](https://api.stripe.com#received_credits) depending on their network and source flow. Reversing a ReceivedCredit leads to the creation of a new object known as a CreditReversal. |
| 55 |
""" |
| 56 |
debit_reversal: Optional["DebitReversal"] |
| 57 |
""" |
| 58 |
You can reverse some [ReceivedDebits](https://api.stripe.com#received_debits) depending on their network and source flow. Reversing a ReceivedDebit leads to the creation of a new object known as a DebitReversal. |
| 59 |
""" |
| 60 |
inbound_transfer: Optional["InboundTransfer"] |
| 61 |
""" |
| 62 |
Use [InboundTransfers](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers) to add funds to your [FinancialAccount](https://api.stripe.com#financial_accounts) via a PaymentMethod that is owned by you. The funds will be transferred via an ACH debit. |
| 63 |
|
| 64 |
Related guide: [Moving money with Treasury using InboundTransfer objects](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers) |
| 65 |
""" |
| 66 |
issuing_authorization: Optional["Authorization"] |
| 67 |
""" |
| 68 |
When an [issued card](https://docs.stripe.com/issuing) is used to make a purchase, an Issuing `Authorization` |
| 69 |
object is created. [Authorizations](https://docs.stripe.com/issuing/purchases/authorizations) must be approved for the |
| 70 |
purchase to be completed successfully. |
| 71 |
|
| 72 |
Related guide: [Issued card authorizations](https://docs.stripe.com/issuing/purchases/authorizations) |
| 73 |
""" |
| 74 |
outbound_payment: Optional["OutboundPayment"] |
| 75 |
""" |
| 76 |
Use [OutboundPayments](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/out-of/outbound-payments) to send funds to another party's external bank account or [FinancialAccount](https://api.stripe.com#financial_accounts). To send money to an account belonging to the same user, use an [OutboundTransfer](https://api.stripe.com#outbound_transfers). |
| 77 |
|
| 78 |
Simulate OutboundPayment state changes with the `/v1/test_helpers/treasury/outbound_payments` endpoints. These methods can only be called on test mode objects. |
| 79 |
|
| 80 |
Related guide: [Moving money with Treasury using OutboundPayment objects](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/out-of/outbound-payments) |
| 81 |
""" |
| 82 |
outbound_transfer: Optional["OutboundTransfer"] |
| 83 |
""" |
| 84 |
Use [OutboundTransfers](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/out-of/outbound-transfers) to transfer funds from a [FinancialAccount](https://api.stripe.com#financial_accounts) to a PaymentMethod belonging to the same entity. To send funds to a different party, use [OutboundPayments](https://api.stripe.com#outbound_payments) instead. You can send funds over ACH rails or through a domestic wire transfer to a user's own external bank account. |
| 85 |
|
| 86 |
Simulate OutboundTransfer state changes with the `/v1/test_helpers/treasury/outbound_transfers` endpoints. These methods can only be called on test mode objects. |
| 87 |
|
| 88 |
Related guide: [Moving money with Treasury using OutboundTransfer objects](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/out-of/outbound-transfers) |
| 89 |
""" |
| 90 |
received_credit: Optional["ReceivedCredit"] |
| 91 |
""" |
| 92 |
ReceivedCredits represent funds sent to a [FinancialAccount](https://api.stripe.com#financial_accounts) (for example, via ACH or wire). These money movements are not initiated from the FinancialAccount. |
| 93 |
""" |
| 94 |
received_debit: Optional["ReceivedDebit"] |
| 95 |
""" |
| 96 |
ReceivedDebits represent funds pulled from a [FinancialAccount](https://api.stripe.com#financial_accounts). These are not initiated from the FinancialAccount. |
| 97 |
""" |
| 98 |
type: Literal[ |
| 99 |
"credit_reversal", |
| 100 |
"debit_reversal", |
| 101 |
"inbound_transfer", |
| 102 |
"issuing_authorization", |
| 103 |
"other", |
| 104 |
"outbound_payment", |
| 105 |
"outbound_transfer", |
| 106 |
"received_credit", |
| 107 |
"received_debit", |
| 108 |
] |
| 109 |
""" |
| 110 |
Type of the flow that created the Transaction. Set to the same value as `flow_type`. |
| 111 |
""" |
| 112 |
|
| 113 |
balance_impact: BalanceImpact |
| 114 |
""" |
| 115 |
Change to a FinancialAccount's balance |
| 116 |
""" |
| 117 |
created: int |
| 118 |
""" |
| 119 |
Time at which the object was created. Measured in seconds since the Unix epoch. |
| 120 |
""" |
| 121 |
currency: str |
| 122 |
""" |
| 123 |
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). |
| 124 |
""" |
| 125 |
effective_at: int |
| 126 |
""" |
| 127 |
When the TransactionEntry will impact the FinancialAccount's balance. |
| 128 |
""" |
| 129 |
financial_account: str |
| 130 |
""" |
| 131 |
The FinancialAccount associated with this object. |
| 132 |
""" |
| 133 |
flow: Optional[str] |
| 134 |
""" |
| 135 |
Token of the flow associated with the TransactionEntry. |
| 136 |
""" |
| 137 |
flow_details: Optional[FlowDetails] |
| 138 |
""" |
| 139 |
Details of the flow associated with the TransactionEntry. |
| 140 |
""" |
| 141 |
flow_type: Literal[ |
| 142 |
"credit_reversal", |
| 143 |
"debit_reversal", |
| 144 |
"inbound_transfer", |
| 145 |
"issuing_authorization", |
| 146 |
"other", |
| 147 |
"outbound_payment", |
| 148 |
"outbound_transfer", |
| 149 |
"received_credit", |
| 150 |
"received_debit", |
| 151 |
] |
| 152 |
""" |
| 153 |
Type of the flow associated with the TransactionEntry. |
| 154 |
""" |
| 155 |
id: str |
| 156 |
""" |
| 157 |
Unique identifier for the object. |
| 158 |
""" |
| 159 |
livemode: bool |
| 160 |
""" |
| 161 |
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. |
| 162 |
""" |
| 163 |
object: Literal["treasury.transaction_entry"] |
| 164 |
""" |
| 165 |
String representing the object's type. Objects of the same type share the same value. |
| 166 |
""" |
| 167 |
transaction: ExpandableField["Transaction"] |
| 168 |
""" |
| 169 |
The Transaction associated with this object. |
| 170 |
""" |
| 171 |
type: Literal[ |
| 172 |
"credit_reversal", |
| 173 |
"credit_reversal_posting", |
| 174 |
"debit_reversal", |
| 175 |
"inbound_transfer", |
| 176 |
"inbound_transfer_return", |
| 177 |
"issuing_authorization_hold", |
| 178 |
"issuing_authorization_release", |
| 179 |
"other", |
| 180 |
"outbound_payment", |
| 181 |
"outbound_payment_cancellation", |
| 182 |
"outbound_payment_failure", |
| 183 |
"outbound_payment_posting", |
| 184 |
"outbound_payment_return", |
| 185 |
"outbound_transfer", |
| 186 |
"outbound_transfer_cancellation", |
| 187 |
"outbound_transfer_failure", |
| 188 |
"outbound_transfer_posting", |
| 189 |
"outbound_transfer_return", |
| 190 |
"received_credit", |
| 191 |
"received_debit", |
| 192 |
] |
| 193 |
""" |
| 194 |
The specific money movement that generated the TransactionEntry. |
| 195 |
""" |
| 196 |
|
| 197 |
@classmethod |
| 198 |
def list( |
| 199 |
cls, **params: Unpack["TransactionEntryListParams"] |
| 200 |
) -> ListObject["TransactionEntry"]: |
| 201 |
""" |
| 202 |
Retrieves a list of TransactionEntry objects. |
| 203 |
""" |
| 204 |
result = cls._static_request( |
| 205 |
"get", |
| 206 |
cls.class_url(), |
| 207 |
params=params, |
| 208 |
) |
| 209 |
if not isinstance(result, ListObject): |
| 210 |
raise TypeError( |
| 211 |
"Expected list object from API, got %s" |
| 212 |
% (type(result).__name__) |
| 213 |
) |
| 214 |
|
| 215 |
return result |
| 216 |
|
| 217 |
@classmethod |
| 218 |
async def list_async( |
| 219 |
cls, **params: Unpack["TransactionEntryListParams"] |
| 220 |
) -> ListObject["TransactionEntry"]: |
| 221 |
""" |
| 222 |
Retrieves a list of TransactionEntry objects. |
| 223 |
""" |
| 224 |
result = await cls._static_request_async( |
| 225 |
"get", |
| 226 |
cls.class_url(), |
| 227 |
params=params, |
| 228 |
) |
| 229 |
if not isinstance(result, ListObject): |
| 230 |
raise TypeError( |
| 231 |
"Expected list object from API, got %s" |
| 232 |
% (type(result).__name__) |
| 233 |
) |
| 234 |
|
| 235 |
return result |
| 236 |
|
| 237 |
@classmethod |
| 238 |
def retrieve( |
| 239 |
cls, id: str, **params: Unpack["TransactionEntryRetrieveParams"] |
| 240 |
) -> "TransactionEntry": |
| 241 |
""" |
| 242 |
Retrieves a TransactionEntry object. |
| 243 |
""" |
| 244 |
instance = cls(id, **params) |
| 245 |
instance.refresh() |
| 246 |
return instance |
| 247 |
|
| 248 |
@classmethod |
| 249 |
async def retrieve_async( |
| 250 |
cls, id: str, **params: Unpack["TransactionEntryRetrieveParams"] |
| 251 |
) -> "TransactionEntry": |
| 252 |
""" |
| 253 |
Retrieves a TransactionEntry object. |
| 254 |
""" |
| 255 |
instance = cls(id, **params) |
| 256 |
await instance.refresh_async() |
| 257 |
return instance |
| 258 |
|
| 259 |
@classmethod |
| 260 |
def class_url(cls): |
| 261 |
return "/v1/treasury/transaction_entries" |
| 262 |
|
| 263 |
_inner_class_types = { |
| 264 |
"balance_impact": BalanceImpact, |
| 265 |
"flow_details": FlowDetails, |
| 266 |
} |