/**
 * Shared Stripe param/result types (browser-safe)
 *
 * These types define the public interface for Stripe operations -- used by both
 * the server-side adapter and the SDK typed wrappers. They contain zero Node.js
 * dependencies and are safe to import in any environment.
 *
 * Server-internal types (API response shapes, credentials) remain in
 * server/adapters/stripe/fetch/utils/types.ts
 */

// ============================================================================
// Create Payment Link
// ============================================================================

/**
 * Create payment link parameters
 */
export interface CreatePaymentLinkParams {
  priceId: string
  quantity?: number
  metadata?: Record<string, string>
  afterCompletionType?: 'redirect' | 'hosted_confirmation'
  redirectUrl?: string
  allowPromotionCodes?: boolean
  automaticTax?: boolean
  billingAddressCollection?: 'auto' | 'required'
  invoiceCreation?: boolean
}

/**
 * Create payment link result
 */
export interface CreatePaymentLinkResult {
  id: string
  url: string
  active: boolean
  livemode: boolean
}

// ============================================================================
// Get Payment Link
// ============================================================================

/**
 * Get payment link parameters
 */
export interface GetPaymentLinkParams {
  paymentLinkId: string
}

/**
 * Get payment link result
 */
export interface GetPaymentLinkResult {
  id: string
  url: string
  active: boolean
  livemode: boolean
  metadata: Record<string, string>
}

// ============================================================================
// Update Payment Link
// ============================================================================

/**
 * Update payment link parameters
 */
export interface UpdatePaymentLinkParams {
  paymentLinkId: string
  active?: boolean
  metadata?: Record<string, string>
}

/**
 * Update payment link result
 */
export interface UpdatePaymentLinkResult {
  id: string
  active: boolean
  url: string
}

// ============================================================================
// List Payment Links
// ============================================================================

/**
 * List payment links parameters
 */
export interface ListPaymentLinksParams {
  active?: boolean
  limit?: number
  startingAfter?: string
  endingBefore?: string
}

/**
 * List payment links result
 */
export interface ListPaymentLinksResult {
  data: Array<{
    id: string
    url: string
    active: boolean
    metadata: Record<string, string>
  }>
  hasMore: boolean
}

// ============================================================================
// Create Auto Payment Link (Dynamic Pricing)
// ============================================================================

/**
 * Create auto payment link parameters
 */
export interface CreateAutoPaymentLinkParams {
  dealId: string
  companyName: string
  contactEmail: string
  initialFee: number
  monthlyFee: number
}

/**
 * Create auto payment link result
 */
export interface CreateAutoPaymentLinkResult {
  paymentLinkId: string
  url: string
  hasInitialFee: boolean
  hasRecurring: boolean
}

// ============================================================================
// Create Checkout Session
// ============================================================================

/**
 * Create checkout session parameters
 */
export interface CreateCheckoutSessionParams {
  amount: number
  currency?: string
  productName?: string
  productDescription?: string
  metadata?: Record<string, string>
  successUrl: string
  cancelUrl: string
  customerEmail?: string
}

/**
 * Create checkout session result
 */
export interface CreateCheckoutSessionResult {
  id: string
  url: string
  expiresAt: number
}
