<?php
// config.php

require_once('vendor/autoload.php');

// Assicurati di non esporre le tue chiavi segrete pubblicamente.
// Usa variabili d'ambiente per la chiave segreta in produzione!
// Esempio: $_ENV['STRIPE_SECRET_KEY']
\Stripe\Stripe::setApiKey('sk_test_51RVay2DGNOaN6NWBydkXZBSXrSCGvkflHGQiPs4tkLLdEbgU9rFlooK2QnPrD5JOMKJzvUBtnvtsgak9jLhTzTFN00dtBQ1YaT'); // Sostituisci con la tua chiave segreta test/live
\Stripe\Stripe::setAppInfo(
    'Gestione Stripe | Da Express a Custom',
    '0.0.2', // La versione della tua app
    'https://gestionestripe.gvproductions.info'
);

// URL base della tua piattaforma per i redirect di Stripe
define('YOUR_PLATFORM_URL', 'https://gestionestripe.gvproductions.info');

// Chiave segreta del Webhook (da Stripe Dashboard -> Developers -> Webhooks)
define('STRIPE_WEBHOOK_SECRET', 'whsec_epSkKozP25OQx6FiHZddq8Fa4PlaGBEr'); // Sostituisci con la tua chiave segreta del webhook

// --- Configurazione Database ---
define('DB_HOST', 'localhost'); // Di solito 'localhost' o l'IP del tuo server DB
define('DB_NAME', 'gvproduc_stripe_connect_db'); // Il nome del database che hai creato
define('DB_USER', 'gvproduc_stripe_connect_db'); // Il tuo username del database
define('DB_PASS', '434083Gv$'); // La tua password del database

try {
    $dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4';
    $pdo = new PDO($dsn, DB_USER, DB_PASS, [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // Mostra eccezioni per errori
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, // Risultati come array associativi
        PDO::ATTR_EMULATE_PREPARES => false, // Per vere prepared statements
    ]);
} catch (PDOException $e) {
    // Gestione dell'errore di connessione al database
    error_log("Errore di connessione al database: " . $e->getMessage());
    http_response_code(500); // Internal Server Error
    echo json_encode(['error' => 'Errore di connessione al database.']);
    exit(); // Termina lo script
}

?>