export interface GatewaySecretConfig {
  id: 'bkash' | 'nagad' | 'rocket' | 'sslcommerz' | 'shurjopay' | 'aamarpay' | 'uddoktapay';
  name: string;
  is_enabled: boolean;
  mode: 'test' | 'live';
  merchant_id?: string;
  merchant_mobile?: string;
  store_id?: string;
  store_password?: string;
  signature_key?: string;
  api_key?: string;
  allowed_channels?: string[];
  session_timeout?: number | string;
  username?: string;
  password?: string;
  app_key?: string;
  app_secret?: string;
  public_key?: string;
  private_key?: string;
  terminal_id?: string;
  pin_password?: string;
  order_prefix?: string;
  api_url?: string;
  callback_url?: string;
  success_url?: string;
  fail_url?: string;
  cancel_url?: string;
  ipn_url?: string;
  webhook_url?: string;
}

export type PaymentStatus = 'pending' | 'processing' | 'paid' | 'failed' | 'cancelled' | 'expired' | 'refunded';

export interface ServerTransaction {
  id: string;
  transaction_id: string;
  listing_id: string;
  listing_name: string;
  listing_url?: string;
  facebook_url?: string;
  website_url?: string;
  listing_image: string;
  category_id: string;
  category_name?: string;
  amount: number;
  currency: string;
  gateway: 'bkash' | 'nagad' | 'rocket' | 'sslcommerz' | 'shurjopay' | 'aamarpay' | 'uddoktapay';
  mode: 'test' | 'live';
  status: PaymentStatus;
  gateway_transaction_id?: string;
  gateway_response?: Record<string, any>;
  ip_address?: string;
  created_at: string;
  updated_at: string;
  paid_at?: string;
  failure_reason?: string;
  callback_processed_at?: string;
}

export interface PaymentInitParams {
  targetListingId?: string;
  name: string;
  url?: string;
  facebook_url?: string;
  website_url?: string;
  imageUrl: string;
  categoryId: string;
  categoryName?: string;
  amount: number;
  gateway: 'bkash' | 'nagad' | 'rocket' | 'sslcommerz' | 'shurjopay' | 'aamarpay' | 'uddoktapay';
  channel?: string;
  customerIp?: string;
  originUrl?: string;
}

export interface PaymentInitResult {
  success: boolean;
  transactionId: string;
  gateway: string;
  mode: 'test' | 'live';
  checkoutUrl?: string;
  action: 'redirect' | 'modal' | 'sandbox_sim';
  sandboxData?: {
    transactionId: string;
    amount: number;
    gateway: string;
    listingName: string;
    simulatedSuccessUrl: string;
    simulatedFailUrl: string;
    simulatedCancelUrl: string;
  };
  message?: string;
}
