<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
    <title>Debug Checker</title>
</head>
<body>
    <h2>Debug Card Checker</h2>
    
    <form id="debug-form">
        <div>
            <label>Action:</label>
            <input type="text" name="action" value="check_card" readonly>
        </div>
        <div>
            <label>Amount:</label>
            <input type="number" name="amount" value="1">
        </div>
        <div>
            <label>Card Number:</label>
            <input type="text" name="card_number" value="4242424242424242">
        </div>
        <div>
            <label>Exp Month:</label>
            <input type="text" name="exp_month" value="12">
        </div>
        <div>
            <label>Exp Year:</label>
            <input type="text" name="exp_year" value="25">
        </div>
        <div>
            <label>CVV:</label>
            <input type="text" name="cvv" value="123">
        </div>
        <div>
            <label>Currency:</label>
            <select name="currency">
                <option value="usd">USD</option>
                <option value="inr">INR</option>
            </select>
        </div>
        <button type="submit">Test Check Card</button>
    </form>
    
    <div id="debug-result" style="margin-top: 20px; padding: 10px; border: 1px solid #ccc;"></div>

    <script>
        document.getElementById('debug-form').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const formData = new FormData(this);
            
            console.log('Sending data:', Object.fromEntries(formData));
            
            fetch('process.php', {
                method: 'POST',
                body: formData
            })
            .then(response => response.json())
            .then(data => {
                console.log('Received response:', data);
                document.getElementById('debug-result').innerHTML = 
                    '<h3>Response:</h3><pre>' + JSON.stringify(data, null, 2) + '</pre>';
            })
            .catch(error => {
                console.error('Error:', error);
                document.getElementById('debug-result').innerHTML = 
                    '<h3>Error:</h3><pre>' + error + '</pre>';
            });
        });
    </script>
</body>
</html>