<?php
// simple_test.php - Simple working test endpoint
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { 
    http_response_code(200); 
    exit(); 
}

// Simple test - return a mock payment URL
$input = json_decode(file_get_contents('php://input'), true);

if (!$input) {
    echo json_encode(['success' => false, 'message' => 'Invalid JSON']);
    exit;
}

$amount = isset($input['amount']) ? $input['amount'] : 100;

// Return a mock PhonePe payment URL for testing
echo json_encode([
    'success' => true,
    'paymentUrl' => 'https://api-preprod.phonepe.com/apis/pg-sandbox/pg/v1/paypage/TEST123',
    'message' => 'Mock payment URL generated',
    'amount' => $amount,
    'debug' => [
        'input' => $input,
        'timestamp' => time()
    ]
]);
?>
