/**
 * Billing checkout types — pre-built Stripe Checkout Session creation.
 */

import { z } from 'zod';

export const BillingCheckoutSchema = z
  .object({
    userId: z.string().min(1),
    priceId: z.string().min(1).optional(),
    plan: z.enum(['pro', 'enterprise']).optional(),
    successUrl: z.string().url(),
    cancelUrl: z.string().url(),
    trialDays: z.number().int().min(0).max(365).optional(),
    promoCode: z.string().max(64).optional(),
    collectTax: z.boolean().default(false),
    customerEmail: z.string().email().optional(),
    metadata: z.record(z.string().max(500)).optional(),
  })
  .refine(data => data.priceId || data.plan, { message: 'Either priceId or plan is required' });

export type BillingCheckoutInput = z.infer<typeof BillingCheckoutSchema>;

export interface BillingCheckoutResponse {
  sessionId: string;
  url: string | null;
}
