<?php
$invoice = $_GET['invoice'] ?? '';
if (!$invoice) exit('invalid');

$meta_file = __DIR__ . '/invoices/meta.json';
$meta = file_exists($meta_file) ? json_decode(file_get_contents($meta_file), true) : [];

if (!isset($meta[$invoice])) exit('not found');

$meta[$invoice]['status'] = 'deleted';

file_put_contents($meta_file, json_encode($meta, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
echo 'ok';
