import { PaymentIntentStatus, PaymentMethodType } from '@prisma/client';

export type PaymentPlatform = 'web' | 'mobile';

export type ClientAction =
  | { type: 'REDIRECT'; url: string }
  | { type: 'LAUNCH_APP'; prepayId: string; receiveCode?: string; shortCode: string };

export interface ProviderInitiationInput {
  merchantOrderId: string;
  bookingRef: string;
  amountMinor: number;
  currency: string;
  platform?: PaymentPlatform;
}

export interface ProviderInitiationResult {
  providerOrderId: string;
  clientAction: ClientAction;
  expiresAt: Date;
  rawInitiation: Record<string, unknown>;
}

export interface ProviderStatus {
  status: PaymentIntentStatus;
  providerTxnId?: string;
  failureCode?: string;
  failureMessage?: string;
  rawResponse: Record<string, unknown>;
}

export interface PaymentProvider {
  readonly method: PaymentMethodType;
  initiate(input: ProviderInitiationInput): Promise<ProviderInitiationResult>;
  queryStatus(merchantOrderId: string): Promise<ProviderStatus>;
}
