<?php
// check_payment.php - Returns the status of an order
require_once 'config.php';

$order_id = $_GET['order_id'] ?? null;

if (!$order_id) {
    echo json_encode(['status' => 'error', 'message' => 'Missing order_id']);
    exit;
}

$response = supabase_request('GET', 'transactions?order_id=eq.' . $order_id);

if ($response['status'] == 200 && !empty($response['data'])) {
    $order = $response['data'][0];
    echo json_encode([
        'status' => 'success',
        'payment_status' => $order['status'] // Will be 'pending' or 'completed'
    ]);
} else {
    echo json_encode(['status' => 'error', 'message' => 'Order not found']);
}
?>
