<?php
// mock_payment.php - Working mock payment for testing
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(); 
}

// Mock successful payment response
$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 working PhonePe test URL
echo json_encode([
    'success' => true,
    'paymentUrl' => 'https://www.google.com', // Simple test URL
    'message' => 'Payment URL generated successfully',
    'amount' => $amount,
    'transactionId' => 'TXN_' . time(),
    'debug' => [
        'input' => $input,
        'timestamp' => time(),
        'status' => 'READY_FOR_PAYMENT'
    ]
]);
?>
