export type BillingPlatform = 'ios' | 'android';

export type SubscriptionStatus = 'active' | 'expired' | 'cancelled' | 'revoked';

export type PurchaseEventType =
  | 'purchase_created'
  | 'subscription_renewed'
  | 'subscription_expired'
  | 'subscription_cancelled'
  | 'subscription_refunded'
  | 'subscription_revoked'
  | 'manual_grant'
  | 'restore'
  // Matches the legacy Express event_type value exactly (kept misspelled for data continuity).
  | 'singup_bonus';

export interface NormalizedStorePurchase {
  platform: BillingPlatform;
  user_id: string;
  productId: string;
  transactionId: string;
  originalTransactionId?: string;
  expiresAt?: Date;
  status: SubscriptionStatus;
  rawPayload: Record<string, unknown>;
}

export interface VerifyPurchaseInput {
  user_id: string;
  platform: BillingPlatform;
  productId: string;
  receipt?: string;
  purchaseToken?: string;
  transactionId?: string;
  originalTransactionId?: string;
  expiresAt?: string;
  forceTransfer?: boolean;
  payload?: Record<string, unknown>;
}
