export type BillingProvider = 'internal' | 'whmcs' | 'stripe';

export function getBillingProvider(): BillingProvider {
  const value = process.env['BILLING_PROVIDER'] ?? 'internal';
  if (value === 'whmcs' || value === 'stripe') {
    return value;
  }
  return 'internal';
}

/** Commercial billing is handled outside the credit wallet (WHMCS or Stripe). */
export function isExternalBilling(): boolean {
  const provider = getBillingProvider();
  return provider === 'whmcs' || provider === 'stripe';
}

export function isWhmcsBilling(): boolean {
  return getBillingProvider() === 'whmcs';
}

export function isStripeBilling(): boolean {
  return getBillingProvider() === 'stripe';
}
