export type Currency = 'NGN' | 'GHS' | 'USD' | 'ZAR' | 'KES' | 'XOF';

export type PaymentChannels =
  | 'bank'
  | 'card'
  | 'qr'
  | 'ussd'
  | 'mobile_money'
  | 'eft'
  | 'bank_transfer'
  | 'payattitude';

type Bearer = 'account' | 'subaccount';

type phone = number | string;

interface PaystackCustomFields {
  display_name: string;
  variable_name: string;
  value: any;
}

interface PaystackMetadata {
  custom_fields: PaystackCustomFields[];
}

interface PaystackMetadata {
  [key: string]: any;
}

interface PaystackConnectSplit {
  account_id: string;
  share: number;
}

export interface PaystackProps {
  publicKey: string;
  email: string;
  amount: number;
  firstname?: string;
  lastname?: string;
  phone?: phone;
  reference?: string;
  metadata?: PaystackMetadata;
  currency?: Currency | string;
  channels?: PaymentChannels[] | string[];
  label?: string;
  plan?: string;
  quantity?: number;
  subaccount?: string;
  transaction_charge?: number;
  bearer?: Bearer;
  split_code?: string;
  split?: Record<string, any>;
  connect_split?: PaystackConnectSplit[];
  connect_account?: string;
  onBankTransferConfirmationPending?: (response?: any) => void;
}
export type PaystackTransaction = {
  reference: string //	This is the unique payment reference that can be used for reconciliation
  trans: string // This is the transaction id (for backward compatibility)
  status:	string	// The final state of the transaction
  message: string	// Complimentary note of the transaction status
  transaction: string	// This is the transaction id
  trxref:	string // This is the unique payment reference that can be used for reconciliation (for backward compatibility)
}
export interface PaystackCallbacks {
  onSuccess?: (transaction?: PaystackTransaction) => void;
  onCancel?: () => void
  onClose?: () => void;
  onLoad?: (response?: any) => void;
  onError?: (error?: any) => void;
}

export type InitializePayment = (options: PaystackCallbacks & { config?: Omit<PaystackProps, 'publicKey'> }) => void;

export type HookConfig = Omit<Partial<PaystackProps>, 'publicKey'> &
  Pick<PaystackProps, 'publicKey'>;
