// Branded ID types for type safety
export type CustomerId = string & { __brand: 'CustomerId' };
export type PaymentIntentId = string & { __brand: 'PaymentIntentId' };
export type PaymentMethodId = string & { __brand: 'PaymentMethodId' };
export type SetupIntentId = string & { __brand: 'SetupIntentId' };
export type ChargeId = string & { __brand: 'ChargeId' };
export type RefundId = string & { __brand: 'RefundId' };
export type DisputeId = string & { __brand: 'DisputeId' };
export type BalanceTransactionId = string & { __brand: 'BalanceTransactionId' };
export type SubscriptionId = string & { __brand: 'SubscriptionId' };
export type SubscriptionItemId = string & { __brand: 'SubscriptionItemId' };
export type SubscriptionScheduleId = string & { __brand: 'SubscriptionScheduleId' };
export type InvoiceId = string & { __brand: 'InvoiceId' };
export type InvoiceItemId = string & { __brand: 'InvoiceItemId' };
export type ProductId = string & { __brand: 'ProductId' };
export type PriceId = string & { __brand: 'PriceId' };
export type CouponId = string & { __brand: 'CouponId' };
export type PromotionCodeId = string & { __brand: 'PromotionCodeId' };
export type PaymentLinkId = string & { __brand: 'PaymentLinkId' };
export type CheckoutSessionId = string & { __brand: 'CheckoutSessionId' };
export type PayoutId = string & { __brand: 'PayoutId' };
export type TransferId = string & { __brand: 'TransferId' };
export type AccountId = string & { __brand: 'AccountId' };
export type EventId = string & { __brand: 'EventId' };
export type WebhookEndpointId = string & { __brand: 'WebhookEndpointId' };
export type TaxRateId = string & { __brand: 'TaxRateId' };
export type TaxIdId = string & { __brand: 'TaxIdId' };
export type FileId = string & { __brand: 'FileId' };
export type FileLinkId = string & { __brand: 'FileLinkId' };

// Common Stripe response structure
export interface StripeList<T> {
  object: 'list';
  data: T[];
  has_more: boolean;
  url: string;
}

// Address
export interface Address {
  line1?: string | null;
  line2?: string | null;
  city?: string | null;
  state?: string | null;
  postal_code?: string | null;
  country?: string | null;
}

// Customer
export interface Customer {
  id: CustomerId;
  object: 'customer';
  address?: Address | null;
  balance?: number;
  created: number;
  currency?: string | null;
  default_source?: string | null;
  delinquent?: boolean | null;
  description?: string | null;
  discount?: any | null;
  email?: string | null;
  invoice_prefix?: string | null;
  invoice_settings?: {
    custom_fields?: any | null;
    default_payment_method?: string | null;
    footer?: string | null;
  };
  livemode: boolean;
  metadata: Record<string, string>;
  name?: string | null;
  phone?: string | null;
  preferred_locales?: string[];
  shipping?: {
    address?: Address;
    name?: string;
    phone?: string;
  } | null;
  tax_exempt?: 'none' | 'exempt' | 'reverse';
  test_clock?: string | null;
}

// Payment Intent
export type PaymentIntentStatus = 
  | 'requires_payment_method'
  | 'requires_confirmation'
  | 'requires_action'
  | 'processing'
  | 'requires_capture'
  | 'canceled'
  | 'succeeded';

export interface PaymentIntent {
  id: PaymentIntentId;
  object: 'payment_intent';
  amount: number;
  amount_capturable?: number;
  amount_details?: {
    tip?: { amount?: number };
  };
  amount_received?: number;
  application?: string | null;
  application_fee_amount?: number | null;
  automatic_payment_methods?: {
    enabled?: boolean;
  } | null;
  canceled_at?: number | null;
  cancellation_reason?: string | null;
  capture_method: 'automatic' | 'manual';
  client_secret?: string | null;
  confirmation_method: 'automatic' | 'manual';
  created: number;
  currency: string;
  customer?: CustomerId | null;
  description?: string | null;
  invoice?: InvoiceId | null;
  last_payment_error?: any | null;
  livemode: boolean;
  metadata: Record<string, string>;
  next_action?: any | null;
  on_behalf_of?: string | null;
  payment_method?: PaymentMethodId | null;
  payment_method_options?: any;
  payment_method_types: string[];
  processing?: any | null;
  receipt_email?: string | null;
  setup_future_usage?: 'on_session' | 'off_session' | null;
  shipping?: any | null;
  statement_descriptor?: string | null;
  statement_descriptor_suffix?: string | null;
  status: PaymentIntentStatus;
  transfer_data?: any | null;
  transfer_group?: string | null;
}

// Payment Method
export type PaymentMethodType = 
  | 'card'
  | 'card_present'
  | 'us_bank_account'
  | 'sepa_debit'
  | 'acss_debit'
  | 'link'
  | 'affirm'
  | 'afterpay_clearpay'
  | 'klarna';

export interface PaymentMethod {
  id: PaymentMethodId;
  object: 'payment_method';
  billing_details: {
    address?: Address | null;
    email?: string | null;
    name?: string | null;
    phone?: string | null;
  };
  card?: {
    brand: string;
    checks?: {
      address_line1_check?: string | null;
      address_postal_code_check?: string | null;
      cvc_check?: string | null;
    };
    country?: string;
    exp_month: number;
    exp_year: number;
    fingerprint?: string;
    funding: 'credit' | 'debit' | 'prepaid' | 'unknown';
    last4: string;
    networks?: {
      available: string[];
      preferred?: string | null;
    };
    three_d_secure_usage?: {
      supported: boolean;
    };
    wallet?: any | null;
  };
  created: number;
  customer?: CustomerId | null;
  livemode: boolean;
  metadata: Record<string, string>;
  type: PaymentMethodType;
  us_bank_account?: any;
}

// Setup Intent
export type SetupIntentStatus = 
  | 'requires_payment_method'
  | 'requires_confirmation'
  | 'requires_action'
  | 'processing'
  | 'canceled'
  | 'succeeded';

export interface SetupIntent {
  id: SetupIntentId;
  object: 'setup_intent';
  application?: string | null;
  cancellation_reason?: string | null;
  client_secret?: string | null;
  created: number;
  customer?: CustomerId | null;
  description?: string | null;
  last_setup_error?: any | null;
  livemode: boolean;
  mandate?: string | null;
  metadata: Record<string, string>;
  next_action?: any | null;
  on_behalf_of?: string | null;
  payment_method?: PaymentMethodId | null;
  payment_method_options?: any;
  payment_method_types: string[];
  single_use_mandate?: string | null;
  status: SetupIntentStatus;
  usage: string;
}

// Charge
export interface Charge {
  id: ChargeId;
  object: 'charge';
  amount: number;
  amount_captured: number;
  amount_refunded: number;
  application?: string | null;
  application_fee?: string | null;
  application_fee_amount?: number | null;
  balance_transaction?: BalanceTransactionId | null;
  billing_details: {
    address?: Address | null;
    email?: string | null;
    name?: string | null;
    phone?: string | null;
  };
  calculated_statement_descriptor?: string | null;
  captured: boolean;
  created: number;
  currency: string;
  customer?: CustomerId | null;
  description?: string | null;
  disputed: boolean;
  failure_balance_transaction?: string | null;
  failure_code?: string | null;
  failure_message?: string | null;
  fraud_details?: any;
  invoice?: InvoiceId | null;
  livemode: boolean;
  metadata: Record<string, string>;
  on_behalf_of?: string | null;
  outcome?: any;
  paid: boolean;
  payment_intent?: PaymentIntentId | null;
  payment_method?: PaymentMethodId | null;
  payment_method_details?: any;
  receipt_email?: string | null;
  receipt_number?: string | null;
  receipt_url?: string;
  refunded: boolean;
  refunds?: StripeList<Refund>;
  review?: string | null;
  shipping?: any | null;
  source_transfer?: string | null;
  statement_descriptor?: string | null;
  statement_descriptor_suffix?: string | null;
  status: 'succeeded' | 'pending' | 'failed';
  transfer_data?: any | null;
  transfer_group?: string | null;
}

// Refund
export type RefundStatus = 'pending' | 'succeeded' | 'failed' | 'canceled';
export type RefundReason = 'duplicate' | 'fraudulent' | 'requested_by_customer' | null;

export interface Refund {
  id: RefundId;
  object: 'refund';
  amount: number;
  balance_transaction?: BalanceTransactionId | null;
  charge?: ChargeId | null;
  created: number;
  currency: string;
  metadata: Record<string, string>;
  payment_intent?: PaymentIntentId | null;
  reason?: RefundReason;
  receipt_number?: string | null;
  source_transfer_reversal?: string | null;
  status: RefundStatus;
  transfer_reversal?: string | null;
}

// Dispute
export type DisputeStatus = 
  | 'warning_needs_response'
  | 'warning_under_review'
  | 'warning_closed'
  | 'needs_response'
  | 'under_review'
  | 'charge_refunded'
  | 'won'
  | 'lost';

export interface Dispute {
  id: DisputeId;
  object: 'dispute';
  amount: number;
  balance_transactions: BalanceTransaction[];
  charge: ChargeId;
  created: number;
  currency: string;
  evidence: any;
  evidence_details: {
    due_by?: number | null;
    has_evidence: boolean;
    past_due: boolean;
    submission_count: number;
  };
  is_charge_refundable: boolean;
  livemode: boolean;
  metadata: Record<string, string>;
  network_reason_code?: string | null;
  payment_intent?: PaymentIntentId | null;
  reason: string;
  status: DisputeStatus;
}

// Balance Transaction
export type BalanceTransactionType = 
  | 'charge'
  | 'refund'
  | 'adjustment'
  | 'application_fee'
  | 'application_fee_refund'
  | 'transfer'
  | 'payment'
  | 'payout'
  | 'payout_cancel'
  | 'payout_failure'
  | 'stripe_fee'
  | 'tax';

export interface BalanceTransaction {
  id: BalanceTransactionId;
  object: 'balance_transaction';
  amount: number;
  available_on: number;
  created: number;
  currency: string;
  description?: string | null;
  exchange_rate?: number | null;
  fee: number;
  fee_details: Array<{
    amount: number;
    application?: string | null;
    currency: string;
    description?: string | null;
    type: string;
  }>;
  net: number;
  reporting_category: string;
  source?: string | null;
  status: 'available' | 'pending';
  type: BalanceTransactionType;
}

// Subscription
export type SubscriptionStatus = 
  | 'incomplete'
  | 'incomplete_expired'
  | 'trialing'
  | 'active'
  | 'past_due'
  | 'canceled'
  | 'unpaid'
  | 'paused';

export interface Subscription {
  id: SubscriptionId;
  object: 'subscription';
  application?: string | null;
  application_fee_percent?: number | null;
  automatic_tax: {
    enabled: boolean;
  };
  billing_cycle_anchor: number;
  billing_thresholds?: any | null;
  cancel_at?: number | null;
  cancel_at_period_end: boolean;
  canceled_at?: number | null;
  collection_method: 'charge_automatically' | 'send_invoice';
  created: number;
  currency: string;
  current_period_end: number;
  current_period_start: number;
  customer: CustomerId;
  days_until_due?: number | null;
  default_payment_method?: PaymentMethodId | null;
  default_source?: string | null;
  default_tax_rates?: TaxRate[];
  description?: string | null;
  discount?: any | null;
  ended_at?: number | null;
  items: StripeList<SubscriptionItem>;
  latest_invoice?: InvoiceId | null;
  livemode: boolean;
  metadata: Record<string, string>;
  next_pending_invoice_item_invoice?: number | null;
  on_behalf_of?: string | null;
  pause_collection?: any | null;
  payment_settings?: {
    payment_method_options?: any;
    payment_method_types?: string[] | null;
    save_default_payment_method?: 'on_subscription' | 'off' | null;
  };
  pending_invoice_item_interval?: any | null;
  pending_setup_intent?: SetupIntentId | null;
  pending_update?: any | null;
  schedule?: SubscriptionScheduleId | null;
  start_date: number;
  status: SubscriptionStatus;
  test_clock?: string | null;
  transfer_data?: any | null;
  trial_end?: number | null;
  trial_settings?: {
    end_behavior: {
      missing_payment_method: 'create_invoice' | 'pause' | 'cancel';
    };
  };
  trial_start?: number | null;
}

// Subscription Item
export interface SubscriptionItem {
  id: SubscriptionItemId;
  object: 'subscription_item';
  billing_thresholds?: any | null;
  created: number;
  metadata: Record<string, string>;
  price: Price;
  quantity?: number;
  subscription: SubscriptionId;
  tax_rates?: TaxRate[];
}

// Subscription Schedule
export type SubscriptionScheduleStatus = 
  | 'not_started'
  | 'active'
  | 'completed'
  | 'released'
  | 'canceled';

export interface SubscriptionSchedule {
  id: SubscriptionScheduleId;
  object: 'subscription_schedule';
  application?: string | null;
  canceled_at?: number | null;
  completed_at?: number | null;
  created: number;
  current_phase?: any | null;
  customer: CustomerId;
  default_settings: any;
  end_behavior: 'release' | 'cancel';
  livemode: boolean;
  metadata: Record<string, string>;
  phases: any[];
  released_at?: number | null;
  released_subscription?: SubscriptionId | null;
  status: SubscriptionScheduleStatus;
  subscription?: SubscriptionId | null;
  test_clock?: string | null;
}

// Invoice
export type InvoiceStatus = 
  | 'draft'
  | 'open'
  | 'paid'
  | 'uncollectible'
  | 'void';

export interface Invoice {
  id: InvoiceId;
  object: 'invoice';
  account_country?: string | null;
  account_name?: string | null;
  account_tax_ids?: string[] | null;
  amount_due: number;
  amount_paid: number;
  amount_remaining: number;
  application?: string | null;
  application_fee_amount?: number | null;
  attempt_count: number;
  attempted: boolean;
  auto_advance?: boolean;
  automatic_tax: {
    enabled: boolean;
    status?: 'complete' | 'failed' | 'requires_location_inputs' | null;
  };
  billing_reason?: 
    | 'subscription_cycle'
    | 'subscription_create'
    | 'subscription_update'
    | 'subscription'
    | 'manual'
    | 'upcoming'
    | 'subscription_threshold'
    | null;
  charge?: ChargeId | null;
  collection_method: 'charge_automatically' | 'send_invoice';
  created: number;
  currency: string;
  custom_fields?: any[] | null;
  customer?: CustomerId | null;
  customer_address?: Address | null;
  customer_email?: string | null;
  customer_name?: string | null;
  customer_phone?: string | null;
  customer_shipping?: any | null;
  customer_tax_exempt?: 'none' | 'exempt' | 'reverse';
  customer_tax_ids?: any[];
  default_payment_method?: PaymentMethodId | null;
  default_source?: string | null;
  default_tax_rates: TaxRate[];
  description?: string | null;
  discount?: any | null;
  discounts?: any[];
  due_date?: number | null;
  ending_balance?: number | null;
  footer?: string | null;
  from_invoice?: any | null;
  hosted_invoice_url?: string | null;
  invoice_pdf?: string | null;
  last_finalization_error?: any | null;
  latest_revision?: string | null;
  lines: StripeList<InvoiceLineItem>;
  livemode: boolean;
  metadata: Record<string, string>;
  next_payment_attempt?: number | null;
  number?: string | null;
  on_behalf_of?: string | null;
  paid: boolean;
  paid_out_of_band: boolean;
  payment_intent?: PaymentIntentId | null;
  payment_settings?: {
    default_mandate?: string | null;
    payment_method_options?: any;
    payment_method_types?: string[] | null;
  };
  period_end: number;
  period_start: number;
  post_payment_credit_notes_amount: number;
  pre_payment_credit_notes_amount: number;
  quote?: string | null;
  receipt_number?: string | null;
  rendering_options?: any | null;
  starting_balance: number;
  statement_descriptor?: string | null;
  status: InvoiceStatus;
  status_transitions: {
    finalized_at?: number | null;
    marked_uncollectible_at?: number | null;
    paid_at?: number | null;
    voided_at?: number | null;
  };
  subscription?: SubscriptionId | null;
  subscription_proration_date?: number;
  subtotal: number;
  subtotal_excluding_tax?: number | null;
  tax?: number | null;
  test_clock?: string | null;
  total: number;
  total_discount_amounts?: any[];
  total_excluding_tax?: number | null;
  total_tax_amounts: any[];
  transfer_data?: any | null;
  webhooks_delivered_at?: number | null;
}

// Invoice Item
export interface InvoiceItem {
  id: InvoiceItemId;
  object: 'invoiceitem';
  amount: number;
  currency: string;
  customer: CustomerId;
  date: number;
  description?: string | null;
  discountable: boolean;
  discounts?: any[];
  invoice?: InvoiceId | null;
  livemode: boolean;
  metadata: Record<string, string>;
  period: {
    end: number;
    start: number;
  };
  price?: Price | null;
  proration: boolean;
  quantity: number;
  subscription?: SubscriptionId | null;
  tax_rates?: TaxRate[];
  test_clock?: string | null;
  unit_amount?: number | null;
  unit_amount_decimal?: string | null;
}

// Invoice Line Item
export interface InvoiceLineItem {
  id: string;
  object: 'line_item';
  amount: number;
  amount_excluding_tax?: number | null;
  currency: string;
  description?: string | null;
  discount_amounts?: any[];
  discountable: boolean;
  discounts?: any[];
  invoice_item?: InvoiceItemId;
  livemode: boolean;
  metadata: Record<string, string>;
  period: {
    end: number;
    start: number;
  };
  price?: Price;
  proration: boolean;
  proration_details?: any;
  quantity?: number;
  subscription?: SubscriptionId | null;
  subscription_item?: SubscriptionItemId;
  tax_amounts?: any[];
  tax_rates?: TaxRate[];
  type: 'invoiceitem' | 'subscription';
  unit_amount_excluding_tax?: string | null;
}

// Product
export interface Product {
  id: ProductId;
  object: 'product';
  active: boolean;
  attributes?: string[] | null;
  created: number;
  default_price?: PriceId | null;
  description?: string | null;
  images: string[];
  livemode: boolean;
  metadata: Record<string, string>;
  name: string;
  package_dimensions?: {
    height: number;
    length: number;
    weight: number;
    width: number;
  } | null;
  shippable?: boolean | null;
  statement_descriptor?: string | null;
  tax_code?: string | null;
  type: 'service' | 'good';
  unit_label?: string | null;
  updated: number;
  url?: string | null;
}

// Price
export type PriceType = 'one_time' | 'recurring';
export type PriceBillingScheme = 'per_unit' | 'tiered';

export interface Price {
  id: PriceId;
  object: 'price';
  active: boolean;
  billing_scheme: PriceBillingScheme;
  created: number;
  currency: string;
  custom_unit_amount?: {
    maximum?: number | null;
    minimum?: number | null;
    preset?: number | null;
  } | null;
  livemode: boolean;
  lookup_key?: string | null;
  metadata: Record<string, string>;
  nickname?: string | null;
  product: ProductId | Product;
  recurring?: {
    aggregate_usage?: 'sum' | 'last_during_period' | 'last_ever' | 'max' | null;
    interval: 'day' | 'week' | 'month' | 'year';
    interval_count: number;
    trial_period_days?: number | null;
    usage_type: 'metered' | 'licensed';
  } | null;
  tax_behavior?: 'inclusive' | 'exclusive' | 'unspecified' | null;
  tiers?: any[] | null;
  tiers_mode?: 'graduated' | 'volume' | null;
  transform_quantity?: any | null;
  type: PriceType;
  unit_amount?: number | null;
  unit_amount_decimal?: string | null;
}

// Coupon
export interface Coupon {
  id: CouponId;
  object: 'coupon';
  amount_off?: number | null;
  applies_to?: {
    products: ProductId[];
  };
  created: number;
  currency?: string | null;
  duration: 'forever' | 'once' | 'repeating';
  duration_in_months?: number | null;
  livemode: boolean;
  max_redemptions?: number | null;
  metadata: Record<string, string>;
  name?: string | null;
  percent_off?: number | null;
  redeem_by?: number | null;
  times_redeemed: number;
  valid: boolean;
}

// Promotion Code
export interface PromotionCode {
  id: PromotionCodeId;
  object: 'promotion_code';
  active: boolean;
  code: string;
  coupon: Coupon;
  created: number;
  customer?: CustomerId | null;
  expires_at?: number | null;
  livemode: boolean;
  max_redemptions?: number | null;
  metadata: Record<string, string>;
  restrictions: {
    first_time_transaction: boolean;
    minimum_amount?: number | null;
    minimum_amount_currency?: string | null;
  };
  times_redeemed: number;
}

// Payment Link
export interface PaymentLink {
  id: PaymentLinkId;
  object: 'payment_link';
  active: boolean;
  after_completion: any;
  allow_promotion_codes: boolean;
  application?: string | null;
  application_fee_amount?: number | null;
  application_fee_percent?: number | null;
  automatic_tax: {
    enabled: boolean;
  };
  billing_address_collection: 'auto' | 'required';
  consent_collection?: any | null;
  currency: string;
  custom_fields: any[];
  custom_text: any;
  customer_creation: 'if_required' | 'always';
  inactive_message?: string | null;
  invoice_creation?: any;
  livemode: boolean;
  metadata: Record<string, string>;
  on_behalf_of?: string | null;
  payment_intent_data?: any | null;
  payment_method_collection: 'always' | 'if_required';
  payment_method_types?: string[] | null;
  phone_number_collection: {
    enabled: boolean;
  };
  shipping_address_collection?: any | null;
  shipping_options: any[];
  submit_type: 'auto' | 'pay' | 'donate' | 'book';
  subscription_data?: any | null;
  tax_id_collection: {
    enabled: boolean;
  };
  transfer_data?: any | null;
  url: string;
}

// Checkout Session
export type CheckoutSessionMode = 'payment' | 'setup' | 'subscription';
export type CheckoutSessionStatus = 'open' | 'complete' | 'expired';

export interface CheckoutSession {
  id: CheckoutSessionId;
  object: 'checkout.session';
  after_expiration?: any | null;
  allow_promotion_codes?: boolean | null;
  amount_subtotal?: number | null;
  amount_total?: number | null;
  automatic_tax: {
    enabled: boolean;
    status?: 'complete' | 'failed' | 'requires_location_inputs' | null;
  };
  billing_address_collection?: 'auto' | 'required' | null;
  cancel_url: string;
  client_reference_id?: string | null;
  consent?: any | null;
  consent_collection?: any | null;
  created: number;
  currency?: string | null;
  currency_conversion?: any | null;
  custom_fields: any[];
  custom_text: any;
  customer?: CustomerId | null;
  customer_creation?: 'if_required' | 'always' | null;
  customer_details?: {
    address?: Address | null;
    email?: string | null;
    name?: string | null;
    phone?: string | null;
    tax_exempt?: 'none' | 'exempt' | 'reverse';
    tax_ids?: any[];
  } | null;
  customer_email?: string | null;
  expires_at: number;
  invoice?: InvoiceId | null;
  invoice_creation?: any;
  livemode: boolean;
  locale?: string | null;
  metadata: Record<string, string>;
  mode: CheckoutSessionMode;
  payment_intent?: PaymentIntentId | null;
  payment_link?: PaymentLinkId | null;
  payment_method_collection?: 'always' | 'if_required';
  payment_method_options?: any;
  payment_method_types: string[];
  payment_status: 'paid' | 'unpaid' | 'no_payment_required';
  phone_number_collection?: {
    enabled: boolean;
  };
  recovered_from?: string | null;
  setup_intent?: SetupIntentId | null;
  shipping_address_collection?: any | null;
  shipping_cost?: any | null;
  shipping_details?: any | null;
  shipping_options: any[];
  status: CheckoutSessionStatus;
  submit_type?: 'auto' | 'pay' | 'donate' | 'book' | null;
  subscription?: SubscriptionId | null;
  success_url: string;
  total_details?: {
    amount_discount: number;
    amount_shipping?: number | null;
    amount_tax: number;
  } | null;
  url?: string | null;
}

// Payout
export type PayoutStatus = 
  | 'paid'
  | 'pending'
  | 'in_transit'
  | 'canceled'
  | 'failed';

export interface Payout {
  id: PayoutId;
  object: 'payout';
  amount: number;
  arrival_date: number;
  automatic: boolean;
  balance_transaction?: BalanceTransactionId | null;
  created: number;
  currency: string;
  description?: string | null;
  destination?: string | null;
  failure_balance_transaction?: BalanceTransactionId | null;
  failure_code?: string | null;
  failure_message?: string | null;
  livemode: boolean;
  metadata: Record<string, string>;
  method: 'standard' | 'instant';
  original_payout?: PayoutId | null;
  reconciliation_status: 'not_applicable' | 'in_progress' | 'completed';
  reversed_by?: PayoutId | null;
  source_type: 'card' | 'bank_account' | 'fpx';
  statement_descriptor?: string | null;
  status: PayoutStatus;
  type: 'bank_account' | 'card';
}

// Transfer
export interface Transfer {
  id: TransferId;
  object: 'transfer';
  amount: number;
  amount_reversed: number;
  balance_transaction?: BalanceTransactionId | null;
  created: number;
  currency: string;
  description?: string | null;
  destination: AccountId;
  destination_payment?: string;
  livemode: boolean;
  metadata: Record<string, string>;
  reversals: StripeList<any>;
  reversed: boolean;
  source_transaction?: string | null;
  source_type?: 'card' | 'bank_account' | 'fpx';
  transfer_group?: string | null;
}

// Account (Connect)
export type AccountType = 'standard' | 'express' | 'custom';

export interface Account {
  id: AccountId;
  object: 'account';
  business_profile?: {
    mcc?: string | null;
    name?: string | null;
    product_description?: string | null;
    support_address?: Address | null;
    support_email?: string | null;
    support_phone?: string | null;
    support_url?: string | null;
    url?: string | null;
  };
  business_type?: 'individual' | 'company' | 'non_profit' | 'government_entity' | null;
  capabilities?: Record<string, any>;
  charges_enabled: boolean;
  company?: any;
  controller?: any;
  country: string;
  created: number;
  default_currency: string;
  details_submitted: boolean;
  email?: string | null;
  external_accounts?: StripeList<any>;
  future_requirements?: any;
  individual?: any;
  metadata: Record<string, string>;
  payouts_enabled: boolean;
  requirements?: any;
  settings?: any;
  tos_acceptance?: {
    date?: number | null;
    ip?: string | null;
    user_agent?: string | null;
  };
  type: AccountType;
}

// Event
export interface Event {
  id: EventId;
  object: 'event';
  account?: AccountId;
  api_version?: string | null;
  created: number;
  data: {
    object: any;
    previous_attributes?: any;
  };
  livemode: boolean;
  pending_webhooks: number;
  request?: {
    id?: string | null;
    idempotency_key?: string | null;
  } | null;
  type: string;
}

// Webhook Endpoint
export interface WebhookEndpoint {
  id: WebhookEndpointId;
  object: 'webhook_endpoint';
  api_version?: string | null;
  application?: string | null;
  created: number;
  description?: string | null;
  enabled_events: string[];
  livemode: boolean;
  metadata: Record<string, string>;
  status: 'enabled' | 'disabled';
  url: string;
}

// Tax Rate
export interface TaxRate {
  id: TaxRateId;
  object: 'tax_rate';
  active: boolean;
  country?: string | null;
  created: number;
  description?: string | null;
  display_name: string;
  inclusive: boolean;
  jurisdiction?: string | null;
  livemode: boolean;
  metadata: Record<string, string>;
  percentage: number;
  state?: string | null;
  tax_type?: string | null;
}

// Tax ID
export type TaxIdType = 
  | 'ae_trn'
  | 'au_abn'
  | 'au_arn'
  | 'bg_uic'
  | 'br_cnpj'
  | 'br_cpf'
  | 'ca_bn'
  | 'ca_gst_hst'
  | 'ca_pst_bc'
  | 'ca_pst_mb'
  | 'ca_pst_sk'
  | 'ca_qst'
  | 'ch_vat'
  | 'cl_tin'
  | 'eg_tin'
  | 'es_cif'
  | 'eu_oss_vat'
  | 'eu_vat'
  | 'gb_vat'
  | 'ge_vat'
  | 'hk_br'
  | 'hu_tin'
  | 'id_npwp'
  | 'il_vat'
  | 'in_gst'
  | 'is_vat'
  | 'jp_cn'
  | 'jp_rn'
  | 'jp_trn'
  | 'ke_pin'
  | 'kr_brn'
  | 'li_uid'
  | 'mx_rfc'
  | 'my_frp'
  | 'my_itn'
  | 'my_sst'
  | 'no_vat'
  | 'nz_gst'
  | 'ph_tin'
  | 'ru_inn'
  | 'ru_kpp'
  | 'sa_vat'
  | 'sg_gst'
  | 'sg_uen'
  | 'si_tin'
  | 'th_vat'
  | 'tr_tin'
  | 'tw_vat'
  | 'ua_vat'
  | 'us_ein'
  | 'za_vat';

export interface TaxId {
  id: TaxIdId;
  object: 'tax_id';
  country?: string | null;
  created: number;
  customer?: CustomerId | null;
  livemode: boolean;
  type: TaxIdType;
  value: string;
  verification?: {
    status: 'pending' | 'verified' | 'unverified' | 'unavailable';
    verified_address?: string | null;
    verified_name?: string | null;
  } | null;
}

// File
export type FilePurpose = 
  | 'account_requirement'
  | 'additional_verification'
  | 'business_icon'
  | 'business_logo'
  | 'customer_signature'
  | 'dispute_evidence'
  | 'document_provider_identity_document'
  | 'finance_report_run'
  | 'identity_document'
  | 'identity_document_downloadable'
  | 'pci_document'
  | 'selfie'
  | 'sigma_scheduled_query'
  | 'tax_document_user_upload'
  | 'terminal_reader_splashscreen';

export interface File {
  id: FileId;
  object: 'file';
  created: number;
  expires_at?: number | null;
  filename?: string | null;
  links?: StripeList<FileLink> | null;
  purpose: FilePurpose;
  size: number;
  title?: string | null;
  type?: string | null;
  url?: string | null;
}

// File Link
export interface FileLink {
  id: FileLinkId;
  object: 'file_link';
  created: number;
  expired: boolean;
  expires_at?: number | null;
  file: FileId | File;
  livemode: boolean;
  metadata: Record<string, string>;
  url?: string | null;
}

// Error type
export interface StripeError {
  type: 'api_error' | 'card_error' | 'idempotency_error' | 'invalid_request_error' | 'authentication_error' | 'rate_limit_error';
  code?: string;
  decline_code?: string;
  message: string;
  param?: string;
  charge?: string;
  payment_intent?: PaymentIntent;
  payment_method?: PaymentMethod;
  setup_intent?: SetupIntent;
  source?: any;
}
