']; $invStmt = $this->db->prepare("SELECT * FROM billing_invoices WHERE id = :id FOR UPDATE"); $invStmt->execute([':id' => $invoiceId]); $invoice = $invStmt->fetch(PDO::FETCH_ASSOC); if (!$invoice) { if ($startedTransaction) $this->db->rollBack(); return ['success' => false, 'message' => "Invoice terkait (#{$invoiceId}) tidak ditemukan."]; } if ($allowedRouterScope !== null) { $allowedRouterIds = array_map('strval', $allowedRouterScope['router_ids'] ?? []); $allowedSessions = array_map('strval', $allowedRouterScope['sessions'] ?? []); $sessionToRouterIds = is_array($allowedRouterScope['session_to_router_ids'] ?? null) ? $allowedRouterScope['session_to_router_ids'] : []; if ( !$this->isRowInRouterScope($payment, $allowedRouterIds, $allowedSessions) || !$this->isRowInRouterScope($invoice, $allowedRouterIds, $allowedSessions) || !$this->areRowsSameRouter($payment, $invoice, $sessionToRouterIds) ) { if ($startedTransaction) $this->db->rollBack(); return [ 'success' => false, 'code' => 'FORBIDDEN_ROUTER', 'message' => 'Akses ditolak: pembayaran atau invoice berada di luar cakupan router ya