<?php
require_once '../app/db.php';
require_once '../vendor/autoload.php';

\Stripe\Stripe::setApiKey("YOUR_STRIPE_SECRET_KEY");

$session = \Stripe\Checkout\Session::retrieve($_GET['session_id']);

if ($session->payment_status === 'paid') {

    $stmt = $pdo->prepare("
        UPDATE bookings 
        SET payment_status='paid', payment_method='stripe', paid_at=NOW()
        WHERE stripe_session_id=?
    ");
    $stmt->execute([$session->id]);

    echo "Payment Successful!";
}
