|
| 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, Optional, cast |
| 7 | +from typing_extensions import Literal, Unpack, TYPE_CHECKING |
| 8 | + |
| 9 | +if TYPE_CHECKING: |
| 10 | + from stripe._balance_transaction import BalanceTransaction |
| 11 | + from stripe.params._balance_transfer_create_params import ( |
| 12 | + BalanceTransferCreateParams, |
| 13 | + ) |
| 14 | + |
| 15 | + |
| 16 | +class BalanceTransfer(CreateableAPIResource["BalanceTransfer"]): |
| 17 | + """ |
| 18 | + Balance transfers represent funds moving between balance types on your Stripe account. |
| 19 | + They currently support moving funds between your Stripe balance and your [Issuing](https://stripe.com/docs/issuing) balance and between your [Allocated Funds](https://stripe.com/docs/connect/funds-segregation) balance and your Stripe balance. |
| 20 | + """ |
| 21 | + |
| 22 | + OBJECT_NAME: ClassVar[Literal["balance_transfer"]] = "balance_transfer" |
| 23 | + |
| 24 | + class DestinationBalance(StripeObject): |
| 25 | + class Issuing(StripeObject): |
| 26 | + balance_transaction: Optional[ |
| 27 | + ExpandableField["BalanceTransaction"] |
| 28 | + ] |
| 29 | + """ |
| 30 | + Identifier for the balance_transaction that increased the destination balance. |
| 31 | + """ |
| 32 | + |
| 33 | + class Payments(StripeObject): |
| 34 | + balance_transaction: Optional[ |
| 35 | + ExpandableField["BalanceTransaction"] |
| 36 | + ] |
| 37 | + """ |
| 38 | + Identifier for the balance_transaction that increased the destination balance. |
| 39 | + """ |
| 40 | + |
| 41 | + issuing: Optional[Issuing] |
| 42 | + payments: Optional[Payments] |
| 43 | + type: str |
| 44 | + """ |
| 45 | + Destination balance type to adjust for the Balance Transfer. One of `payments`, `issuing`, or `allocated_funds`. |
| 46 | + """ |
| 47 | + _inner_class_types = {"issuing": Issuing, "payments": Payments} |
| 48 | + |
| 49 | + class SourceBalance(StripeObject): |
| 50 | + class Issuing(StripeObject): |
| 51 | + balance_transaction: Optional[ |
| 52 | + ExpandableField["BalanceTransaction"] |
| 53 | + ] |
| 54 | + """ |
| 55 | + Identifier for the balance_transaction that decreased the source balance. |
| 56 | + """ |
| 57 | + |
| 58 | + class Payments(StripeObject): |
| 59 | + balance_transaction: ExpandableField["BalanceTransaction"] |
| 60 | + """ |
| 61 | + Identifier for the balance_transaction that decreased the source balance. |
| 62 | + """ |
| 63 | + source_type: Optional[str] |
| 64 | + """ |
| 65 | + The payments balance type that this BalanceTransfer pulled funds from. One of `card`, `fpx`, or `bank_account`. |
| 66 | + """ |
| 67 | + |
| 68 | + issuing: Optional[Issuing] |
| 69 | + payments: Optional[Payments] |
| 70 | + type: str |
| 71 | + """ |
| 72 | + Source balance type to adjust for the Balance Transfer. One of `payments`, `issuing`, or `allocated_funds`. |
| 73 | + """ |
| 74 | + _inner_class_types = {"issuing": Issuing, "payments": Payments} |
| 75 | + |
| 76 | + amount: int |
| 77 | + """ |
| 78 | + A positive integer representing how much was transferred in the smallest currency unit. |
| 79 | + """ |
| 80 | + created: int |
| 81 | + """ |
| 82 | + Time at which the object was created. Measured in seconds since the Unix epoch. |
| 83 | + """ |
| 84 | + currency: str |
| 85 | + """ |
| 86 | + 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). |
| 87 | + """ |
| 88 | + destination_balance: Optional[DestinationBalance] |
| 89 | + """ |
| 90 | + The balance that funds were transferred to. |
| 91 | + """ |
| 92 | + hosted_regulatory_receipt_url: Optional[str] |
| 93 | + """ |
| 94 | + A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. |
| 95 | + """ |
| 96 | + id: str |
| 97 | + """ |
| 98 | + Unique identifier for the object. |
| 99 | + """ |
| 100 | + livemode: bool |
| 101 | + """ |
| 102 | + Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. |
| 103 | + """ |
| 104 | + metadata: Dict[str, str] |
| 105 | + """ |
| 106 | + Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. |
| 107 | + """ |
| 108 | + object: Literal["balance_transfer"] |
| 109 | + """ |
| 110 | + String representing the object's type. Objects of the same type share the same value. |
| 111 | + """ |
| 112 | + source_balance: Optional[SourceBalance] |
| 113 | + """ |
| 114 | + The balance that funds were transferred from. One of `card`, `fpx`, or `bank_account`. |
| 115 | + """ |
| 116 | + |
| 117 | + @classmethod |
| 118 | + def create( |
| 119 | + cls, **params: Unpack["BalanceTransferCreateParams"] |
| 120 | + ) -> "BalanceTransfer": |
| 121 | + """ |
| 122 | + Creates a balance transfer. For Issuing use cases, funds will be debited immediately from the source balance and credited to the destination balance immediately (if your account is based in the US) or next-business-day (if your account is based in the EU). For Segregated Separate Charges and Transfers use cases, funds will be debited immediately from the source balance and credited immediately to the destination balance. |
| 123 | + """ |
| 124 | + return cast( |
| 125 | + "BalanceTransfer", |
| 126 | + cls._static_request( |
| 127 | + "post", |
| 128 | + cls.class_url(), |
| 129 | + params=params, |
| 130 | + ), |
| 131 | + ) |
| 132 | + |
| 133 | + @classmethod |
| 134 | + async def create_async( |
| 135 | + cls, **params: Unpack["BalanceTransferCreateParams"] |
| 136 | + ) -> "BalanceTransfer": |
| 137 | + """ |
| 138 | + Creates a balance transfer. For Issuing use cases, funds will be debited immediately from the source balance and credited to the destination balance immediately (if your account is based in the US) or next-business-day (if your account is based in the EU). For Segregated Separate Charges and Transfers use cases, funds will be debited immediately from the source balance and credited immediately to the destination balance. |
| 139 | + """ |
| 140 | + return cast( |
| 141 | + "BalanceTransfer", |
| 142 | + await cls._static_request_async( |
| 143 | + "post", |
| 144 | + cls.class_url(), |
| 145 | + params=params, |
| 146 | + ), |
| 147 | + ) |
| 148 | + |
| 149 | + _inner_class_types = { |
| 150 | + "destination_balance": DestinationBalance, |
| 151 | + "source_balance": SourceBalance, |
| 152 | + } |
0 commit comments