CREATE TABLE IF NOT EXISTS `hotspot_payment_transactions` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `invoice` varchar(64) NOT NULL,
  `username` varchar(100) NOT NULL DEFAULT 'hotspot',
  `mac` varchar(80) DEFAULT NULL,
  `ip` varchar(80) DEFAULT NULL,
  `login_url` text DEFAULT NULL,
  `dst` text DEFAULT NULL,
  `package_key` varchar(30) NOT NULL,
  `package_label` varchar(100) DEFAULT NULL,
  `amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `profile` varchar(80) NOT NULL,
  `days` int(11) NOT NULL DEFAULT 0,
  `status` varchar(30) NOT NULL DEFAULT 'created',
  `payment_id` varchar(160) DEFAULT NULL,
  `trx_id` varchar(120) DEFAULT NULL,
  `token` varchar(80) DEFAULT NULL,
  `raw_response` mediumtext DEFAULT NULL,
  `error_message` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `paid_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_invoice` (`invoice`),
  UNIQUE KEY `uniq_payment_id` (`payment_id`),
  UNIQUE KEY `uniq_trx_id` (`trx_id`),
  KEY `idx_status` (`status`),
  KEY `idx_mac` (`mac`),
  KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
