interface RazorpayPaymentHandlerResponse {
  razorpay_payment_id: string;
  // Present for one-off order payments.
  razorpay_order_id?: string;
  // Present for recurring subscription payments.
  razorpay_subscription_id?: string;
  razorpay_signature: string;
}

interface RazorpayOptions {
  key: string;
  // One of these is required: `order_id` for one-off payments,
  // `subscription_id` for recurring subscriptions.
  order_id?: string;
  subscription_id?: string;
  name?: string;
  description?: string;
  image?: string;
  currency?: string;
  amount?: number;
  prefill?: {
    name?: string;
    email?: string;
    contact?: string;
  };
  notes?: Record<string, string>;
  theme?: {
    color?: string;
  };
  handler?: (response: RazorpayPaymentHandlerResponse) => void | Promise<void>;
  modal?: {
    ondismiss?: () => void;
    escape?: boolean;
    backdropclose?: boolean;
    confirm_close?: boolean;
  };
}

interface RazorpayInstance {
  open: () => void;
  close: () => void;
  on: (event: string, handler: (response: unknown) => void) => void;
}

interface RazorpayConstructor {
  new (options: RazorpayOptions): RazorpayInstance;
}

declare global {
  interface Window {
    Razorpay: RazorpayConstructor;
  }
}

export {};
