<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;

/**
 * FinFlo Direct Debit (hosted checkout) configuration.
 * Option 2: Hosted checkout – user is redirected to FinFlo's payment page.
 *
 * Set FINFLO_API_KEY and optionally FINFLO_BASE_URL in .env.
 */
class FinFlo extends BaseConfig
{
    /** FinFlo API base URL (public v1) */
    public string $baseUrl = 'https://finflo.net/public/v1';

    /** Platform app slug for Bet Tips (no-wallet app; credits FinFlo central wallet) */
    public string $appSlug = 'bet-tips';

    /** In-house API key – do not expose in client apps. Use only on backend. */
    public string $apiKey = '';

    public function getBaseUrl(): string
    {
        $v = getenv('FINFLO_BASE_URL');
        return $v ? rtrim($v, '/') : rtrim($this->baseUrl, '/');
    }

    public function getApiKey(): string
    {
        return getenv('FINFLO_API_KEY') ?: $this->apiKey;
    }

    /** Full URL for create-session: POST /api/payments/direct-debit/create-session */
    public function getCreateSessionUrl(): string
    {
        return $this->getBaseUrl() . '/api/payments/direct-debit/create-session';
    }
}
