diff --git a/Api/AdyenPosCloudInterface.php b/Api/AdyenPosCloudInterface.php index 6a837e759..ccddd9ecc 100644 --- a/Api/AdyenPosCloudInterface.php +++ b/Api/AdyenPosCloudInterface.php @@ -16,5 +16,5 @@ interface AdyenPosCloudInterface * @param int $orderId * @return void */ - public function pay(int $orderId, string $payload): void; + public function pay(int $orderId): void; } diff --git a/Model/Api/AdyenPosCloud.php b/Model/Api/AdyenPosCloud.php index 2c3742503..2e546b6f5 100644 --- a/Model/Api/AdyenPosCloud.php +++ b/Model/Api/AdyenPosCloud.php @@ -38,7 +38,7 @@ public function __construct( $this->adyenLogger = $adyenLogger; } - public function pay(int $orderId, string $payload): void + public function pay(int $orderId): void { $order = $this->orderRepository->get($orderId); $this->execute($order); diff --git a/Plugin/GuestPaymentInformationResetOrderId.php b/Plugin/GuestPaymentInformationResetOrderId.php index 244ee2c3d..f0ec661ef 100644 --- a/Plugin/GuestPaymentInformationResetOrderId.php +++ b/Plugin/GuestPaymentInformationResetOrderId.php @@ -11,6 +11,7 @@ namespace Adyen\Payment\Plugin; +use Adyen\Payment\Helper\PaymentMethods; use Adyen\Payment\Logger\AdyenLogger; use Exception; use Magento\Checkout\Api\GuestPaymentInformationManagementInterface; @@ -26,6 +27,13 @@ class GuestPaymentInformationResetOrderId */ protected $quoteRepository; + /** + * Payment methods helper + * + * @var PaymentMethods + */ + protected $paymentMethodsHelper; + /** * @var AdyenLogger */ @@ -44,12 +52,14 @@ class GuestPaymentInformationResetOrderId */ public function __construct( CartRepositoryInterface $quoteRepository, - AdyenLogger $adyenLogger, - QuoteIdMaskFactory $quoteIdMaskFactory + QuoteIdMaskFactory $quoteIdMaskFactory, + PaymentMethods $paymentMethodsHelper, + AdyenLogger $adyenLogger ) { $this->quoteRepository = $quoteRepository; - $this->adyenLogger = $adyenLogger; $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->paymentMethodsHelper = $paymentMethodsHelper; + $this->adyenLogger = $adyenLogger; } /** @@ -65,7 +75,11 @@ public function beforeSavePaymentInformationAndPlaceOrder( $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); $quoteId = $quoteIdMask->getQuoteId(); $quote = $this->quoteRepository->get($quoteId); - $quote->setReservedOrderId(null); + $method = $quote->getPayment()->getMethod(); + + if ($this->paymentMethodsHelper->isAdyenPayment($method)) { + $quote->setReservedOrderId(null); + } } catch (Exception $e) { $this->adyenLogger->error("Failed to reset reservedOrderId for guest shopper" . $e->getMessage()); } diff --git a/Plugin/PaymentInformationResetOrderId.php b/Plugin/PaymentInformationResetOrderId.php index f6d493fbd..288e7159a 100644 --- a/Plugin/PaymentInformationResetOrderId.php +++ b/Plugin/PaymentInformationResetOrderId.php @@ -11,6 +11,7 @@ namespace Adyen\Payment\Plugin; +use Adyen\Payment\Helper\PaymentMethods; use Adyen\Payment\Logger\AdyenLogger; use Exception; use Magento\Checkout\Api\PaymentInformationManagementInterface; @@ -25,6 +26,13 @@ class PaymentInformationResetOrderId */ protected $quoteRepository; + /** + * Payment methods helper + * + * @var PaymentMethods + */ + protected $paymentMethodsHelper; + /** * @var AdyenLogger */ @@ -33,13 +41,16 @@ class PaymentInformationResetOrderId /** * PaymentInformationResetOrderId constructor. * @param CartRepositoryInterface $quoteRepository + * @param PaymentMethods $paymentMethodsHelper * @param AdyenLogger $adyenLogger */ public function __construct( CartRepositoryInterface $quoteRepository, + PaymentMethods $paymentMethodsHelper, AdyenLogger $adyenLogger ) { $this->quoteRepository = $quoteRepository; + $this->paymentMethodsHelper = $paymentMethodsHelper; $this->adyenLogger = $adyenLogger; } @@ -54,7 +65,11 @@ public function beforeSavePaymentInformationAndPlaceOrder( ) { try { $quote = $this->quoteRepository->get($cartId); - $quote->setReservedOrderId(null); + $method = $quote->getPayment()->getMethod(); + + if ($this->paymentMethodsHelper->isAdyenPayment($method)) { + $quote->setReservedOrderId(null); + } } catch (Exception $e) { $this->adyenLogger->error("Failed to reset reservedOrderId " . $e->getMessage()); } diff --git a/view/frontend/web/js/model/adyen-payment-service.js b/view/frontend/web/js/model/adyen-payment-service.js index e10493320..c78312e6a 100644 --- a/view/frontend/web/js/model/adyen-payment-service.js +++ b/view/frontend/web/js/model/adyen-payment-service.js @@ -150,7 +150,7 @@ define( {cartId: quote.getQuoteId()} ) } - const payload = JSON.stringify({'payload': '{}', orderId}) + const payload = JSON.stringify({orderId}) return storage.post(url, payload, true) },