# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._stripe_object import StripeObject
from stripe.v2._amount import Amount
from typing import ClassVar, Optional
from typing_extensions import Literal


class ReceivedCredit(StripeObject):
    """
    Use ReceivedCredits API to retrieve information on when, where, and how funds are sent into your FinancialAccount.
    """

    OBJECT_NAME: ClassVar[Literal["v2.money_management.received_credit"]] = (
        "v2.money_management.received_credit"
    )

    class BalanceTransfer(StripeObject):
        from_account: Optional[str]
        """
        The ID of the account that owns the source object originated the ReceivedCredit.
        """
        outbound_payment: Optional[str]
        """
        The ID of the outbound payment object that originated the ReceivedCredit.
        """
        outbound_transfer: Optional[str]
        """
        The ID of the outbound transfer object that originated the ReceivedCredit.
        """
        payout_v1: Optional[str]
        """
        The ID of the payout object that originated the ReceivedCredit.
        """
        transfer: Optional[str]
        """
        The ID of the v1 transfer object that originated the ReceivedCredit.
        """
        type: Literal[
            "outbound_payment", "outbound_transfer", "transfer", "payout_v1"
        ]
        """
        Open Enum. The type of Stripe Money Movement that originated the ReceivedCredit.
        """

    class BankTransfer(StripeObject):
        class CaBankAccount(StripeObject):
            account_holder_name: Optional[str]
            """
            The account holder name of the bank account the transfer was received from.
            """
            bank_name: Optional[str]
            """
            The bank name the transfer was received from.
            """
            last4: Optional[str]
            """
            The last 4 digits of the account number that originated the transfer.
            Depending on the bank, this may instead be the last 4 digits of the return account number.
            """
            network: Literal["acss"]
            """
            Open Enum. The money transmission network used to send funds for this ReceivedCredit.
            """

        class EuBankAccount(StripeObject):
            account_holder_name: Optional[str]
            """
            The account holder name of the bank account the transfer was received from.
            """
            bank_name: Optional[str]
            """
            The bank name the transfer was received from.
            """
            bic: Optional[str]
            """
            The bic of the account that originated the transfer.
            """
            last4: Optional[str]
            """
            The last 4 digits of the account number that originated the transfer.
            """
            network: Literal["sepa"]
            """
            Open Enum. The money transmission network used to send funds for this ReceivedCredit.
            """

        class GbBankAccount(StripeObject):
            account_holder_name: Optional[str]
            """
            The bank name the transfer was received from.
            """
            bank_name: Optional[str]
            """
            The bank name the transfer was received from.
            """
            last4: Optional[str]
            """
            The last 4 digits of the account number that originated the transfer.
            """
            network: Literal["chaps", "fps"]
            """
            Open Enum. The money transmission network used to send funds for this ReceivedCredit.
            """
            sort_code: Optional[str]
            """
            The sort code of the account that originated the transfer.
            """

        class MxBankAccount(StripeObject):
            account_holder_name: Optional[str]
            """
            The account holder name of the bank account the transfer was received from.
            """
            bank_name: Optional[str]
            """
            The bank name the transfer was received from.
            """
            last4: Optional[str]
            """
            The last 4 digits of the account number that originated the transfer.
            """
            network: Literal["spei"]
            """
            Open Enum. The money transmission network used to send funds for this ReceivedCredit.
            """

        class SepaBankAccount(StripeObject):
            account_holder_name: Optional[str]
            """
            The account holder name of the bank account the transfer was received from.
            """
            bank_name: Optional[str]
            """
            The bank name the transfer was received from.
            """
            bic: Optional[str]
            """
            The BIC of the SEPA account.
            """
            country: Optional[str]
            """
            The origination country of the bank transfer.
            """
            iban: Optional[str]
            """
            The IBAN that originated the transfer.
            """
            network: Literal["sepa_credit_transfer"]
            """
            The money transmission network used to send funds for this ReceivedCredit.
            """

        class UsBankAccount(StripeObject):
            account_holder_name: Optional[str]
            """
            The name of the account holder that sent the payment.
            """
            bank_name: Optional[str]
            """
            The bank name the transfer was received from.
            """
            last4: Optional[str]
            """
            The last 4 digits of the account number that originated the transfer.
            """
            network: Literal["ach", "rtp", "us_domestic_wire"]
            """
            Open Enum. The money transmission network used to send funds for this ReceivedCredit.
            """
            routing_number: Optional[str]
            """
            The routing number of the account that originated the transfer.
            """

        ca_bank_account: Optional[CaBankAccount]
        """
        Hash containing the transaction bank details. Present if `origin_type` field value is `ca_bank_account`.
        """
        eu_bank_account: Optional[EuBankAccount]
        """
        Hash containing the transaction bank details. Present if `origin_type` field value is `eu_bank_account`.
        """
        financial_address: str
        """
        Financial Address on which funds for ReceivedCredit were received.
        """
        gb_bank_account: Optional[GbBankAccount]
        """
        Hash containing the transaction bank details. Present if `origin_type` field value is `gb_bank_account`.
        """
        mx_bank_account: Optional[MxBankAccount]
        """
        Hash containing the transaction bank details. Present if  `origin_type` field value is `mx_bank_account`.
        """
        origin_type: Literal[
            "ca_bank_account",
            "crypto_wallet",
            "eu_bank_account",
            "gb_bank_account",
            "mx_bank_account",
            "sepa_bank_account",
            "us_bank_account",
        ]
        """
        Open Enum. Indicates the origin of source from which external funds originated from.
        """
        sepa_bank_account: Optional[SepaBankAccount]
        """
        Hash containing the transaction bank details. Present if `origin_type` field value is `sepa_bank_account`.
        """
        statement_descriptor: Optional[str]
        """
        Freeform string set by originator of the external ReceivedCredit.
        """
        us_bank_account: Optional[UsBankAccount]
        """
        Hash containing the transaction bank details. Present if `origin_type` field value is `us_bank_account`.
        """
        _inner_class_types = {
            "ca_bank_account": CaBankAccount,
            "eu_bank_account": EuBankAccount,
            "gb_bank_account": GbBankAccount,
            "mx_bank_account": MxBankAccount,
            "sepa_bank_account": SepaBankAccount,
            "us_bank_account": UsBankAccount,
        }

    class CardSpend(StripeObject):
        class Dispute(StripeObject):
            issuing_dispute_v1: str
            """
            The reference to the v1 issuing dispute ID.
            """

        class Refund(StripeObject):
            issuing_transaction_v1: str
            """
            The reference to the v1 issuing transaction ID.
            """

        card_v1_id: str
        """
        The reference to the issuing card object.
        """
        dispute: Optional[Dispute]
        """
        Hash containing information about the Dispute that triggered this credit.
        """
        refund: Optional[Refund]
        """
        Hash containing information about the Refund that triggered this credit.
        """
        _inner_class_types = {"dispute": Dispute, "refund": Refund}

    class CryptoWalletTransfer(StripeObject):
        class CryptoWallet(StripeObject):
            address: str
            """
            The address of the wallet the crypto was received from.
            """
            memo: str
            """
            A memo also for identifying the recipient for memo-based blockchains (e.g., Stellar),.
            """
            network: Literal[
                "arbitrum",
                "avalanche_c_chain",
                "base",
                "ethereum",
                "optimism",
                "polygon",
                "solana",
                "stellar",
                "tempo",
            ]
            """
            The network the crypto was received from.
            """

        crypto_wallet: CryptoWallet
        """
        Hash containing the transaction crypto wallet details.
        """
        financial_address: str
        """
        Financial Address on which funds for ReceivedCredit were received.
        """
        origin_type: Literal[
            "ca_bank_account",
            "crypto_wallet",
            "eu_bank_account",
            "gb_bank_account",
            "mx_bank_account",
            "sepa_bank_account",
            "us_bank_account",
        ]
        """
        Open Enum. Indicates the origin of source from which external funds originated from.
        """
        statement_descriptor: Optional[str]
        """
        Freeform string set by originator of the external ReceivedCredit.
        """
        _inner_class_types = {"crypto_wallet": CryptoWallet}

    class StatusDetails(StripeObject):
        class Failed(StripeObject):
            reason: Literal[
                "capability_inactive",
                "currency_unsupported_on_financial_address",
                "financial_address_inactive",
                "stripe_rejected",
            ]
            """
            Open Enum. The `failed` status reason.
            """

        class Returned(StripeObject):
            reason: Literal["originator_initiated_reversal"]
            """
            Open Enum. The `returned` status reason.
            """

        failed: Optional[Failed]
        """
        Hash that provides additional information regarding the reason behind a `failed` ReceivedCredit status. It is only present when the ReceivedCredit status is `failed`.
        """
        returned: Optional[Returned]
        """
        Hash that provides additional information regarding the reason behind a `returned` ReceivedCredit status. It is only present when the ReceivedCredit status is `returned`.
        """
        _inner_class_types = {"failed": Failed, "returned": Returned}

    class StatusTransitions(StripeObject):
        failed_at: Optional[str]
        """
        Timestamp describing when the ReceivedCredit was marked as `failed`.
        Represented as a RFC 3339 date & time UTC value in millisecond precision, for example: 2022-09-18T13:22:18.123Z.
        """
        returned_at: Optional[str]
        """
        Timestamp describing when the ReceivedCredit changed status to `returned`.
        Represented as a RFC 3339 date & time UTC value in millisecond precision, for example: 2022-09-18T13:22:18.123Z.
        """
        succeeded_at: Optional[str]
        """
        Timestamp describing when the ReceivedCredit was marked as `succeeded`.
        Represented as a RFC 3339 date & time UTC value in millisecond precision, for example: 2022-09-18T13:22:18.123Z.
        """

    class StripeBalancePayment(StripeObject):
        debit_agreement: Optional[str]
        """
        ID of the debit agreement associated with this payment.
        """
        statement_descriptor: Optional[str]
        """
        Statement descriptor for the Stripe Balance Payment.
        """

    amount: Amount
    """
    The amount and currency of the ReceivedCredit.
    """
    balance_transfer: Optional[BalanceTransfer]
    """
    This object stores details about the originating Stripe transaction that resulted in the ReceivedCredit. Present if `type` field value is `balance_transfer`.
    """
    bank_transfer: Optional[BankTransfer]
    """
    This object stores details about the originating banking transaction that resulted in the ReceivedCredit. Present if `type` field value is `bank_transfer`.
    """
    card_spend: Optional[CardSpend]
    """
    This object stores details about the originating issuing card spend that resulted in the ReceivedCredit. Present if `type` field value is `card_spend`.
    """
    created: str
    """
    Time at which the ReceivedCredit was created.
    Represented as a RFC 3339 date & time UTC value in millisecond precision, for example: 2022-09-18T13:22:18.123Z.
    """
    crypto_wallet_transfer: Optional[CryptoWalletTransfer]
    """
    This object stores details about the originating crypto transaction that resulted in the ReceivedCredit. Present if `type` field value is `crypto_wallet_transfer`.
    """
    description: Optional[str]
    """
    Freeform string set by originator of the ReceivedCredit.
    """
    external_amount: Optional[Amount]
    """
    The amount and currency of the original/external credit request.
    """
    financial_account: str
    """
    Financial Account ID on which funds for ReceivedCredit were received.
    """
    id: str
    """
    Unique identifier for the ReceivedCredit.
    """
    livemode: bool
    """
    Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
    """
    object: Literal["v2.money_management.received_credit"]
    """
    String representing the object's type. Objects of the same type share the same value of the object field.
    """
    receipt_url: Optional[str]
    """
    A hosted transaction receipt URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.
    """
    status: Literal["failed", "pending", "returned", "succeeded"]
    """
    Open Enum. The status of the ReceivedCredit.
    """
    status_details: Optional[StatusDetails]
    """
    This hash contains detailed information that elaborates on the specific status of the ReceivedCredit. e.g the reason behind a failure if the status is marked as `failed`.
    """
    status_transitions: Optional[StatusTransitions]
    """
    Hash containing timestamps of when the object transitioned to a particular status.
    """
    stripe_balance_payment: Optional[StripeBalancePayment]
    """
    This object stores details about the stripe balance pay refund that resulted in the ReceivedCredit. Present if `type` field value is `stripe_balance_payment`.
    """
    type: Literal[
        "balance_transfer",
        "bank_transfer",
        "card_spend",
        "crypto_wallet_transfer",
        "external_credit",
        "stripe_balance_payment",
    ]
    """
    Open Enum. The type of flow that caused the ReceivedCredit.
    """
    _inner_class_types = {
        "balance_transfer": BalanceTransfer,
        "bank_transfer": BankTransfer,
        "card_spend": CardSpend,
        "crypto_wallet_transfer": CryptoWalletTransfer,
        "status_details": StatusDetails,
        "status_transitions": StatusTransitions,
        "stripe_balance_payment": StripeBalancePayment,
    }
