Invoices doesn’t get captured online in Magento 2.4.5-P1 – How to debug?

I’ll try to keep it simple, the invoices are created as they should in the system, but the invoices doesn’t get captured online anymore. The function below is supposed to do the capturing work.

We don’t know if the function is invoked, or doesn’t get all the data, as it should.

Is there a way to add logging, and or debug this function in Magento?

private function createInvoice(Order $order, int $capture, int $notifyCustomer, Phrase $comment): OrderInvoice
    {
        $invoice = $this->invoiceService->prepareInvoice($order);
        if (!$invoice) {
            throw new LocalizedException(__('Can not save the invoice right now.'));
        }
        if (!$invoice->getTotalQty()) {
            throw new LocalizedException(__('You can not create an invoice without products.'));
        }
        $comment = $comment->render();
        $invoice->addComment($comment, $notifyCustomer);
        $invoice->setCustomerNote($comment);
        switch ($capture) {
            case OrderInvoice::CAPTURE_ONLINE:
                $invoice->setRequestedCaptureCase(OrderInvoice::CAPTURE_ONLINE);
                break;
            case OrderInvoice::CAPTURE_OFFLINE:
                $invoice->setRequestedCaptureCase(OrderInvoice::CAPTURE_OFFLINE);
                break;
        }
        $invoice->register();
        $invoice->getOrder()->setCustomerNoteNotify($notifyCustomer);
        $invoice->getOrder()->setIsInProcess(true);
        $saveTransaction = $this->transactionFactory->create();
        $saveTransaction->addObject($invoice)->addObject($invoice->getOrder());
        $saveTransaction->save();
        return $invoice;
    }

Thanks,