We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 6a7bb718 authored by Attila Kiss's avatar Attila Kiss Committed by GitHub

Merge pull request #759 from Adyen/develop

Release 6.2.1
parents 7b2f7171 0f77b4b4
......@@ -101,6 +101,9 @@ class CaptureDataBuilder implements BuilderInterface
$latestInvoice = $invoices->getLastItem();
foreach ($latestInvoice->getItems() as $invoiceItem) {
if ($invoiceItem->getOrderItem()->getParentItem()) {
continue;
}
++$count;
$numberOfItems = (int)$invoiceItem->getQty();
$formFields = $this->adyenHelper->createOpenInvoiceLineItem(
......
......@@ -24,46 +24,99 @@
namespace Adyen\Payment\Observer\Adminhtml;
use Adyen\Payment\Helper\Data as AdyenHelper;
use Adyen\Payment\Logger\AdyenLogger;
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;
use Throwable;
class BeforeShipmentObserver extends AbstractDataAssignObserver
{
private $adyenHelper;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var InvoiceRepository
*/
private $invoiceRepository;
/**
* BeforeShipmentObserver constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param AdyenHelper $adyenHelper
* @param AdyenLogger $logger
* @param InvoiceRepository $invoiceRepository
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
AdyenHelper $adyenHelper,
AdyenLogger $logger,
InvoiceRepository $invoiceRepository
) {
$this->adyenHelper = $adyenHelper;
$this->logger = $logger;
$this->invoiceRepository = $invoiceRepository;
}
/**
* @param Observer $observer
* @throws \Magento\Framework\Exception\LocalizedException
* @throws Exception
*/
public function execute(Observer $observer)
{
$shipment = $observer->getEvent()->getShipment();
/** @var Shipment $shipment */
$shipment = $observer->getEvent()->getData('shipment');
$order = $shipment->getOrder();
if (!$this->isPaymentMethodAdyen($order)) {
$this->logger->info(
"Payment method is not from Adyen for order id {$order->getId()}",
['observer' => 'BeforeShipmentObserver']
);
return;
}
$captureOnShipment = $this->adyenHelper->getConfigData(
'capture_on_shipment',
'adyen_abstract',
$order->getStoreId()
);
if ($this->isPaymentMethodAdyen($order) && $captureOnShipment) {
if (!$captureOnShipment) {
$this->logger->info(
"Capture on shipment not configured for order id {$order->getId()}",
['observer' => 'BeforeShipmentObserver']
);
return;
}
$payment = $order->getPayment();
$brandCode = $payment->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
$brandCode = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE);
if (!$this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
$this->logger->info(
"Payment method is from Adyen but isn't OpenInvoice for order id {$order->getId()}",
['observer' => 'BeforeShipmentObserver']
);
return;
}
if (!$order->canInvoice()) {
$this->logger->info(
"Cannot invoice order with id {$order->getId()}",
['observer' => 'BeforeShipmentObserver']
);
return;
}
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
if ($order->canInvoice()) {
try {
$invoice = $order->prepareInvoice();
$invoice->getOrder()->setIsInProcess(true);
......@@ -71,13 +124,12 @@ 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();
$invoice->save();
} catch (\Exception $e) {
throw new \Exception(sprintf('Error saving invoice. The error message is:', $e->getMessage()));
}
}
}
$this->invoiceRepository->save($invoice);
} catch (Throwable $e) {
$this->logger->error($e);
throw new Exception('Error saving invoice. The error message is: ' . $e->getMessage());
}
}
......
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "6.2.0",
"version": "6.2.1",
"license": [
"OSL-3.0",
"AFL-3.0"
......
......@@ -900,13 +900,6 @@
</arguments>
</virtualType>
<!--Checkout Response validator-->
<virtualType name="CheckoutResponseValidator" type="Adyen\Payment\Gateway\Validator\CheckoutResponseValidator">
<arguments>
<argument name="loggerInterface" xsi:type="object">Adyen\Payment\Logger\AdyenLogger</argument>
</arguments>
</virtualType>
<virtualType name="PosCloudResponseValidator" type="Adyen\Payment\Gateway\Validator\PosCloudResponseValidator">
<arguments>
<argument name="loggerInterface" xsi:type="object">Adyen\Payment\Logger\AdyenLogger</argument>
......
......@@ -111,7 +111,7 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
*/
var secureFieldsInitialize = function () {
if (!"<?php $block->getCheckoutOriginKeys(); ?>") {
if (!"<?= $block->getCheckoutOriginKeys(); ?>") {
document.getElementById('noApiKey').style = "visibility: visible; display:inline-block";
return;
}
......
......@@ -65,12 +65,6 @@ define(
getCode: function () {
return 'adyen_google_pay';
},
getData: function () {
return {
'method': this.item.method,
'additional_data': {}
};
},
isActive: function () {
return true;
},
......
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