<?php
require_once __DIR__ . '/../system/bootstrap.php';
require_once __DIR__ . '/../system/audit.php';

$ref = $_GET['m_payment_id'] ?? '';

if ($ref) {
    $pdo->prepare(
        'UPDATE payment_attempts
         SET status = "cancelled", updated_at = NOW()
         WHERE payment_ref = :ref'
    )->execute(['ref' => $ref]);

    audit_log('payment_cancelled', 'payment_attempt', null, null, [
        'payment_ref' => $ref
    ]);
}

header('Location: /company/billing.php?payment=cancelled');
exit;
