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 ba812aeb authored by Alexandros Moraitis's avatar Alexandros Moraitis Committed by GitHub

[PW-3095] Set reservedOrderId to null before placing an order (#830)

* Add interceptor for payment-information

* Add exception message for failed reset reverseOrderId

* Replace the checkoutsession with cartQuitoRepository

* Add copyright

* Update Plugin/PaymentInformationResetOrderId.php
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>

* Update etc/di.xml
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>

* Update etc/di.xml
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>

* Add separate interfaces

* Retrieve the quote using the maskedId cartId to reset reserved order id
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
parent 4ec964b0
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Plugin;
use Magento\Quote\Api\CartRepositoryInterface;
class GuestPaymentInformationResetOrderId
{
/**
* Quote repository.
*
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $adyenLogger;
/**
* @var \Magento\Quote\Model\QuoteIdMaskFactory
*/
protected $quoteIdMaskFactory;
/**
* GuestPaymentInformationResetOrderId constructor.
* @param CartRepositoryInterface $quoteRepository
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
*/
public function __construct(
CartRepositoryInterface $quoteRepository,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
)
{
$this->quoteRepository = $quoteRepository;
$this->adyenLogger = $adyenLogger;
$this->quoteIdMaskFactory = $quoteIdMaskFactory;
}
/**
* @param \Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject
* @param $cartId
* @return null
*/
public function beforeSavePaymentInformationAndPlaceOrder(
\Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject,
$cartId
) {
try {
$quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
$quoteId = $quoteIdMask->getQuoteId();
$this->quoteRepository->get($quoteId)->setReservedOrderId(null);
} catch (\Exception $e) {
$this->adyenLogger->error("Failed to reset reservedOrderId for guest shopper" . $e->getMessage());
}
return null;
}
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Plugin;
use Magento\Quote\Api\CartRepositoryInterface;
class PaymentInformationResetOrderId
{
/**
* Quote repository.
*
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $adyenLogger;
/**
* PaymentInformationResetOrderId constructor.
* @param CartRepositoryInterface $quoteRepository
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
CartRepositoryInterface $quoteRepository,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
)
{
$this->quoteRepository = $quoteRepository;
$this->adyenLogger = $adyenLogger;
}
/**
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
* @param $cartId
*/
public function beforeSavePaymentInformationAndPlaceOrder(
\Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
$cartId
) {
try {
$this->quoteRepository->get($cartId)->setReservedOrderId(null);
} catch (\Exception $e) {
$this->adyenLogger->error("Failed to reset reservedOrderId " . $e->getMessage());
}
return null;
}
}
......@@ -1028,6 +1028,14 @@
<type name="Magento\Vault\Api\PaymentTokenRepositoryInterface">
<plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/>
</type>
<type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
<plugin name="AdyenPaymentInformationResetOrderId" type="Adyen\Payment\Plugin\PaymentInformationResetOrderId"
sortOrder="10"/>
</type>
<type name="Magento\Checkout\Api\GuestPaymentInformationManagementInterface">
<plugin name="GuestAdyenPaymentInformationResetOrderId" type="Adyen\Payment\Plugin\GuestPaymentInformationResetOrderId"
sortOrder="10"/>
</type>
<!--Notifications overview-->
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
......
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