<?php
/**
 * Test script to verify Zashof payment integration
 */
require_once 'config/database.php';
require_once 'includes/zashof.php';

echo "<h1>Zashof Payment Integration Test</h1>";

// Test configuration loading
echo "<h2>Configuration Test</h2>";
try {
    $config = get_zashof_config();
    echo "<p style='color: green;'>✓ Configuration loaded successfully</p>";
    echo "<pre>" . print_r($config, true) . "</pre>";
} catch (Exception $e) {
    echo "<p style='color: red;'>✗ Configuration error: " . $e->getMessage() . "</p>";
}

// Test Zashof class
echo "<h2>Class Instantiation Test</h2>";
try {
    $zashof = new ZashofPayment();
    echo "<p style='color: green;'>✓ ZashofPayment class instantiated successfully</p>";
    
    // Test if enabled
    $enabled = $zashof->isEnabled();
    echo "<p>Enabled: " . ($enabled ? 'Yes' : 'No') . "</p>";
    
    if ($enabled) {
        echo "<p style='color: green;'>✓ Zashof payment is enabled</p>";
        
        // Test configuration status
        $configStatus = $zashof->getConfigStatus();
        echo "<h3>Configuration Status:</h3>";
        echo "<ul>";
        echo "<li>Enabled: " . ($configStatus['enabled'] ? 'Yes' : 'No') . "</li>";
        echo "<li>API Key Set: " . ($configStatus['api_key_set'] ? 'Yes' : 'No') . "</li>";
        echo "<li>Base URL: " . htmlspecialchars($configStatus['base_url']) . "</li>";
        echo "<li>Create Charge URL: " . htmlspecialchars($configStatus['create_charge_url']) . "</li>";
        echo "<li>Verify Payment URL: " . htmlspecialchars($configStatus['verify_payment_url']) . "</li>";
        echo "</ul>";
    } else {
        echo "<p style='color: orange;'>⚠ Zashof payment is disabled (this is expected if not configured)</p>";
    }
} catch (Exception $e) {
    echo "<p style='color: red;'>✗ ZashofPayment class error: " . $e->getMessage() . "</p>";
}

echo "<h2>Integration Status</h2>";
echo "<p>The Zashof payment integration is ready for use. To test it:</p>";
echo "<ol>";
echo "<li>Go to Admin Panel → Zashof Payment Settings</li>";
echo "<li>Enter your Zashof API credentials</li>";
echo "<li>Enable Zashof Payment</li>";
echo "<li>Login as a student and go to 'ফি ম্যানেজ' → 'আমার ফি'</li>";
echo "<li>If you have due fees, you'll see an 'অনলাইনে পরিশোধ করুন' button</li>";
echo "<li>Click the button to initiate payment</li>";
echo "</ol>";

echo "<p><a href='fees/my_fees.php'>Go to My Fees</a> | <a href='admin/zashof_settings.php'>Configure Zashof Payment</a></p>";
?>