<?php
/**
 * Test UddoktaPay Verification Script
 * 
 * This script tests the UddoktaPay verification functionality
 */

// Include the database connection first
require_once 'config/database.php';

// Now include the UddoktaPay class
require_once 'includes/uddoktapay.php';

echo "Testing UddoktaPay verification functionality...\n";

// Create UddoktaPay instance
$uddoktapay = new UddoktaPay();

// Test configuration
echo "\n1. Testing configuration...\n";
$config = get_uddoktapay_config();
echo "Configuration: " . json_encode($config, JSON_PRETTY_PRINT) . "\n";

// Test validation
echo "\n2. Testing configuration validation...\n";
$validation = validate_uddoktapay_config();
echo "Validation result: " . json_encode($validation, JSON_PRETTY_PRINT) . "\n";

// Test if enabled
echo "\n3. Testing if UddoktaPay is enabled...\n";
$isEnabled = $uddoktapay->isEnabled();
echo "Is enabled: " . ($isEnabled ? 'Yes' : 'No') . "\n";

if ($isEnabled) {
    echo "\n4. Testing verification with a sample invoice ID...\n";
    // Try to verify a sample invoice ID (this will likely fail, but we'll see the error)
    $result = $uddoktapay->verifyPayment('INV-TEST-12345');
    echo "Verification result: " . json_encode($result, JSON_PRETTY_PRINT) . "\n";
} else {
    echo "\nCannot test verification because UddoktaPay is not properly configured.\n";
    echo "Please check the configuration and try again.\n";
}

echo "\nTest completed.\n";
?>