Is there a way to enable logging, and or debug this function in Magento?
The invoices is created successfully, but the capture online doesn’t work.
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,