# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata
from ...types.ach_holder_type import AchHolderType
from ...types.ach_sec_code import AchSecCode
from ...types.initiator import Initiator
from ...types.stored_method_usage_type import StoredMethodUsageType


class AuthorizePaymentMethod(UniversalBaseModel):
    """
    Payment method object for vendor payouts.
    - `{ method: "managed" }` - Managed payment method
    - `{ method: "vcard" }` - Virtual card payment method
    - `{ method: "check" }` - Check payment method
    - `{ method: "ach", achHolder: "...", achRouting: "...", achAccount: "...", achAccountType: "..." }` - ACH payment method with bank details
    - `{ method: "ach", storedMethodId: "..." }` - ACH payment method using stored method ID
    """

    method: str = pydantic.Field()
    """
    Payment method type - "managed", "vcard", "check", or "ach"
    """

    ach_holder: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="achHolder")] = pydantic.Field(
        default=None
    )
    """
    Account holder name for ACH payments. Required when method is "ach" and not using `storedMethodId`.
    """

    ach_routing: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="achRouting")] = pydantic.Field(
        default=None
    )
    """
    Bank routing number for ACH payments. Required when method is "ach" and not using `storedMethodId`.
    """

    ach_account: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="achAccount")] = pydantic.Field(
        default=None
    )
    """
    Bank account number for ACH payments. Required when method is "ach" and not using `storedMethodId`.
    """

    ach_account_type: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="achAccountType")] = (
        pydantic.Field(default=None)
    )
    """
    Account type for ACH payments ("checking" or "savings"). Required when method is "ach" and not using `storedMethodId`.
    """

    ach_code: typing_extensions.Annotated[typing.Optional[AchSecCode], FieldMetadata(alias="achCode")] = None
    ach_holder_type: typing_extensions.Annotated[
        typing.Optional[AchHolderType], FieldMetadata(alias="achHolderType")
    ] = None
    stored_method_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="storedMethodId")] = (
        pydantic.Field(default=None)
    )
    """
    ID of the stored ACH payment method. Only applicable when method is `ach`. Use this to reference a previously saved ACH method instead of providing bank details directly.
    """

    initiator: typing.Optional[Initiator] = None
    stored_method_usage_type: typing_extensions.Annotated[
        typing.Optional[StoredMethodUsageType], FieldMetadata(alias="storedMethodUsageType")
    ] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
