# 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.batch_number import BatchNumber
from ...types.chargeback_id import ChargebackId
from ...types.dbaname import Dbaname
from ...types.device import Device
from ...types.entrypage_id import EntrypageId
from ...types.entrypointfield import Entrypointfield
from ...types.external_paypoint_id import ExternalPaypointId
from ...types.external_processor_information import ExternalProcessorInformation
from ...types.fee_amount import FeeAmount
from ...types.ip_address import IpAddress
from ...types.legalname import Legalname
from ...types.operation import Operation
from ...types.order_id import OrderId
from ...types.org_parent_name import OrgParentName
from ...types.orgid import Orgid
from ...types.payor_id import PayorId
from ...types.paypoint_id import PaypointId
from ...types.pending_fee_amount import PendingFeeAmount
from ...types.query_c_fee_transaction import QueryCFeeTransaction
from ...types.refund_id import RefundId
from ...types.retrieval_id import RetrievalId
from ...types.returned_id import ReturnedId
from ...types.risk_action import RiskAction
from ...types.risk_action_code import RiskActionCode
from ...types.risk_flagged import RiskFlagged
from ...types.risk_flagged_on import RiskFlaggedOn
from ...types.risk_reason import RiskReason
from ...types.risk_status import RiskStatus
from ...types.settlement_status import SettlementStatus
from ...types.source import Source
from ...types.split_funding import SplitFunding
from ...types.trans_status import TransStatus
from .transaction_detail_customer import TransactionDetailCustomer
from .transaction_detail_event import TransactionDetailEvent
from .transaction_detail_invoice_data import TransactionDetailInvoiceData
from .transaction_detail_payment_data import TransactionDetailPaymentData
from .transaction_detail_record_method import TransactionDetailRecordMethod
from .transaction_detail_response_data import TransactionDetailResponseData


class TransactionDetailRecord(UniversalBaseModel):
    """
    Complete transaction details including payment information, customer data, and processing metadata. This is returned when includeDetails=true.
    """

    parent_org_name: typing_extensions.Annotated[OrgParentName, FieldMetadata(alias="parentOrgName")]
    paypoint_dbaname: typing_extensions.Annotated[Dbaname, FieldMetadata(alias="paypointDbaname")]
    paypoint_legalname: typing_extensions.Annotated[Legalname, FieldMetadata(alias="paypointLegalname")]
    paypoint_entryname: typing_extensions.Annotated[Entrypointfield, FieldMetadata(alias="paypointEntryname")]
    payment_trans_id: typing_extensions.Annotated[str, FieldMetadata(alias="paymentTransId")]
    connector_name: typing_extensions.Annotated[str, FieldMetadata(alias="connectorName")]
    external_processor_information: typing_extensions.Annotated[
        ExternalProcessorInformation, FieldMetadata(alias="externalProcessorInformation")
    ]
    gateway_trans_id: typing_extensions.Annotated[str, FieldMetadata(alias="gatewayTransId")]
    order_id: typing_extensions.Annotated[typing.Optional[OrderId], FieldMetadata(alias="orderId")] = None
    method: TransactionDetailRecordMethod
    batch_number: typing_extensions.Annotated[BatchNumber, FieldMetadata(alias="batchNumber")]
    batch_amount: typing_extensions.Annotated[float, FieldMetadata(alias="batchAmount")]
    payor_id: typing_extensions.Annotated[PayorId, FieldMetadata(alias="payorId")]
    payment_data: typing_extensions.Annotated[TransactionDetailPaymentData, FieldMetadata(alias="paymentData")]
    trans_status: typing_extensions.Annotated[TransStatus, FieldMetadata(alias="transStatus")]
    paypoint_id: typing_extensions.Annotated[PaypointId, FieldMetadata(alias="paypointId")]
    total_amount: typing_extensions.Annotated[float, FieldMetadata(alias="totalAmount")]
    net_amount: typing_extensions.Annotated[float, FieldMetadata(alias="netAmount")]
    fee_amount: typing_extensions.Annotated[FeeAmount, FieldMetadata(alias="feeAmount")]
    settlement_status: typing_extensions.Annotated[SettlementStatus, FieldMetadata(alias="settlementStatus")]
    operation: Operation
    response_data: typing_extensions.Annotated[TransactionDetailResponseData, FieldMetadata(alias="responseData")]
    source: Source
    schedule_reference: typing_extensions.Annotated[int, FieldMetadata(alias="scheduleReference")]
    org_id: typing_extensions.Annotated[Orgid, FieldMetadata(alias="orgId")]
    refund_id: typing_extensions.Annotated[RefundId, FieldMetadata(alias="refundId")]
    returned_id: typing_extensions.Annotated[ReturnedId, FieldMetadata(alias="returnedId")]
    chargeback_id: typing_extensions.Annotated[ChargebackId, FieldMetadata(alias="chargebackId")]
    retrieval_id: typing_extensions.Annotated[RetrievalId, FieldMetadata(alias="retrievalId")]
    trans_additional_data: typing_extensions.Annotated[
        typing.Optional[typing.Any], FieldMetadata(alias="transAdditionalData")
    ] = None
    invoice_data: typing_extensions.Annotated[TransactionDetailInvoiceData, FieldMetadata(alias="invoiceData")]
    entrypage_id: typing_extensions.Annotated[EntrypageId, FieldMetadata(alias="entrypageId")]
    external_paypoint_id: typing_extensions.Annotated[ExternalPaypointId, FieldMetadata(alias="externalPaypointID")]
    is_validated_ach: typing_extensions.Annotated[bool, FieldMetadata(alias="isValidatedACH")]
    transaction_time: typing_extensions.Annotated[str, FieldMetadata(alias="transactionTime")]
    customer: TransactionDetailCustomer
    split_funding_instructions: typing_extensions.Annotated[
        typing.Optional[SplitFunding], FieldMetadata(alias="splitFundingInstructions")
    ] = None
    cfee_transactions: typing_extensions.Annotated[
        typing.List[QueryCFeeTransaction], FieldMetadata(alias="cfeeTransactions")
    ]
    transaction_events: typing_extensions.Annotated[
        typing.List[TransactionDetailEvent], FieldMetadata(alias="transactionEvents")
    ]
    pending_fee_amount: typing_extensions.Annotated[PendingFeeAmount, FieldMetadata(alias="pendingFeeAmount")]
    risk_flagged: typing_extensions.Annotated[RiskFlagged, FieldMetadata(alias="riskFlagged")]
    risk_flagged_on: typing_extensions.Annotated[RiskFlaggedOn, FieldMetadata(alias="riskFlaggedOn")]
    risk_status: typing_extensions.Annotated[RiskStatus, FieldMetadata(alias="riskStatus")]
    risk_reason: typing_extensions.Annotated[RiskReason, FieldMetadata(alias="riskReason")]
    risk_action: typing_extensions.Annotated[RiskAction, FieldMetadata(alias="riskAction")]
    risk_action_code: typing_extensions.Annotated[RiskActionCode, FieldMetadata(alias="riskActionCode")]
    device_id: typing_extensions.Annotated[Device, FieldMetadata(alias="deviceId")]
    ach_sec_code: typing_extensions.Annotated[AchSecCode, FieldMetadata(alias="achSecCode")]
    ach_holder_type: typing_extensions.Annotated[AchHolderType, FieldMetadata(alias="achHolderType")]
    ip_address: typing_extensions.Annotated[IpAddress, FieldMetadata(alias="ipAddress")]
    is_same_day_ach: typing_extensions.Annotated[bool, FieldMetadata(alias="isSameDayACH")]
    wallet_type: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="walletType")] = 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
