We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 98af8b54 authored by Marcos Garcia's avatar Marcos Garcia Committed by GitHub

[PW-2437] Fix issue with capture on shipment (#755)

When setting the plugin to capture on shipment, the capture is not actually happening. This is because the invoice is not configured on how to manage the capture process (online or offline). This commit provides the invoice object with information about the capture mode.
parent 9f0eae1e
......@@ -30,6 +30,7 @@ use Adyen\Payment\Observer\AdyenHppDataAssignObserver;
use Exception;
use Magento\Framework\Event\Observer;
use Magento\Payment\Observer\AbstractDataAssignObserver;
use Magento\Sales\Model\Order\Invoice;
use Magento\Sales\Model\Order\InvoiceRepository;
use Magento\Sales\Model\Order\Shipment;
use Psr\Log\LoggerInterface;
......@@ -123,6 +124,7 @@ class BeforeShipmentObserver extends AbstractDataAssignObserver
// set transaction id so you can do a online refund from credit memo
$pspReference = $order->getPayment()->getAdyenPspReference();
$invoice->setTransactionId($pspReference);
$invoice->setRequestedCaptureCase(Invoice::CAPTURE_ONLINE);
$invoice->register()->pay();
$this->invoiceRepository->save($invoice);
} catch (Throwable $e) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment