diff --git a/vendor/magento/module-negotiable-quote/Model/Plugin/Quote/Model/PaymentMethodManagementPlugin.php b/vendor/magento/module-negotiable-quote/Model/Plugin/Quote/Model/PaymentMethodManagementPlugin.php new file mode 100644 index 000000000000..6f4c25b6b3a5 --- /dev/null +++ b/vendor/magento/module-negotiable-quote/Model/Plugin/Quote/Model/PaymentMethodManagementPlugin.php @@ -0,0 +1,54 @@ +quoteRepository->get($cartId); + $extensionAttributes = $quote->getExtensionAttributes(); + if ($extensionAttributes?->getNegotiableQuote()?->getIsRegularQuote() !== null) { + $quote->setIsActive(false); + } + } +} diff --git a/vendor/magento/module-negotiable-quote/Model/QuoteContext.php b/vendor/magento/module-negotiable-quote/Model/QuoteContext.php new file mode 100644 index 000000000000..f853a7526d79 --- /dev/null +++ b/vendor/magento/module-negotiable-quote/Model/QuoteContext.php @@ -0,0 +1,58 @@ +quoteId; + } + + /** + * Set negotiable quote id + * + * @param int|null $quoteId + * @return void + */ + public function setNegotiableQuoteId(?int $quoteId): void + { + $this->quoteId = $quoteId; + } + + /** + * @inheritDoc + */ + public function _resetState(): void + { + $this->quoteId = null; + } +} diff --git a/vendor/magento/module-negotiable-quote/etc/di.xml b/vendor/magento/module-negotiable-quote/etc/di.xml index 256ea510cd2b..bd1eccbde8d9 100644 --- a/vendor/magento/module-negotiable-quote/etc/di.xml +++ b/vendor/magento/module-negotiable-quote/etc/di.xml @@ -57,6 +57,10 @@ + + + diff --git a/vendor/magento/module-negotiable-quote-async-order/Model/AsyncPaymentInformationManagementPublisher.php b/vendor/magento/module-negotiable-quote-async-order/Model/AsyncPaymentInformationManagementPublisher.php index 44b5b1a18d46..fabc8622ab42 100644 --- a/vendor/magento/module-negotiable-quote-async-order/Model/AsyncPaymentInformationManagementPublisher.php +++ b/vendor/magento/module-negotiable-quote-async-order/Model/AsyncPaymentInformationManagementPublisher.php @@ -16,61 +16,37 @@ namespace Magento\NegotiableQuoteAsyncOrder\Model; -use Magento\AsyncOrder\Model\OrderManagement; use Magento\AsyncOrder\Api\AsyncPaymentInformationCustomerPublisherInterface; -use Magento\Quote\Api\Data\PaymentInterface; -use Magento\Quote\Api\Data\AddressInterface; -use Magento\NegotiableQuoteAsyncOrder\Api\AsyncPaymentInformationManagementInterface; +use Magento\AsyncOrder\Model\OrderManagement; +use Magento\Framework\App\DeploymentConfig; use Magento\NegotiableQuote\Api\PaymentInformationManagementInterface; +use Magento\NegotiableQuote\Model\QuoteContext; use Magento\NegotiableQuote\Model\Webapi\CustomerCartValidator; -use Magento\Framework\App\DeploymentConfig; +use Magento\NegotiableQuoteAsyncOrder\Api\AsyncPaymentInformationManagementInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\PaymentInterface; class AsyncPaymentInformationManagementPublisher implements AsyncPaymentInformationManagementInterface { - /** - * @var PaymentInformationManagementInterface - */ - private $paymentInformationManagement; - - /** - * @var AsyncPaymentInformationCustomerPublisherInterface - */ - private $asyncPaymentInformationCustomerPublisher; - - /** - * @var DeploymentConfig - */ - private $deploymentConfig; - - /** - * @var CustomerCartValidator - */ - private $validator; - - /** - * @var OrderManagement - */ - private $orderManagement; - /** * @param PaymentInformationManagementInterface $paymentInformationManagement * @param AsyncPaymentInformationCustomerPublisherInterface $asyncPaymentInformationCustomerPublisher * @param DeploymentConfig $deploymentConfig * @param CustomerCartValidator $validator * @param OrderManagement $orderManagement + * @param CartRepositoryInterface $cartRepository + * @param QuoteContext $quoteContext */ public function __construct( - PaymentInformationManagementInterface $paymentInformationManagement, - AsyncPaymentInformationCustomerPublisherInterface $asyncPaymentInformationCustomerPublisher, - DeploymentConfig $deploymentConfig, - CustomerCartValidator $validator, - OrderManagement $orderManagement + private readonly PaymentInformationManagementInterface $paymentInformationManagement, + private readonly AsyncPaymentInformationCustomerPublisherInterface $asyncPaymentInformationCustomerPublisher, + private readonly DeploymentConfig $deploymentConfig, + private readonly CustomerCartValidator $validator, + private readonly OrderManagement $orderManagement, + private readonly CartRepositoryInterface $cartRepository, + private readonly QuoteContext $quoteContext ) { - $this->paymentInformationManagement = $paymentInformationManagement; - $this->asyncPaymentInformationCustomerPublisher = $asyncPaymentInformationCustomerPublisher; - $this->deploymentConfig = $deploymentConfig; - $this->validator = $validator; - $this->orderManagement = $orderManagement; } /** @@ -90,6 +66,10 @@ public function savePaymentInformationAndPlaceOrder( ->savePaymentInformationAndPlaceOrder($cartId, $paymentMethod, $billingAddress); } $this->validator->validate($cartId); + $quote = $this->cartRepository->get($cartId); + if ($quote?->getExtensionAttributes()?->getNegotiableQuote()?->getIsRegularQuote() !== null) { + $this->quoteContext->setNegotiableQuoteId((int) $quote->getId()); + } return $this->asyncPaymentInformationCustomerPublisher ->savePaymentInformationAndPlaceOrder($cartId, $paymentMethod, $billingAddress); } diff --git a/vendor/magento/module-negotiable-quote-async-order/Plugin/AsyncOrder/Model/OrderManagementPlugin.php b/vendor/magento/module-negotiable-quote-async-order/Plugin/AsyncOrder/Model/OrderManagementPlugin.php new file mode 100644 index 000000000000..8bef042429a2 --- /dev/null +++ b/vendor/magento/module-negotiable-quote-async-order/Plugin/AsyncOrder/Model/OrderManagementPlugin.php @@ -0,0 +1,51 @@ +quoteContext->getNegotiableQuoteId() + && $this->quoteContext->getNegotiableQuoteId() === ((int)$quote->getId()) + ) { + $quote->setIsActive(true); + } + } +} diff --git a/vendor/magento/module-negotiable-quote-async-order/etc/di.xml b/vendor/magento/module-negotiable-quote-async-order/etc/di.xml index 9400fa5528e1..159b2db4bdb2 100644 --- a/vendor/magento/module-negotiable-quote-async-order/etc/di.xml +++ b/vendor/magento/module-negotiable-quote-async-order/etc/di.xml @@ -8,4 +8,8 @@ + + + diff --git a/vendor/magento/module-purchase-order/Api/NegotiableQuotePurchaseOrderPaymentInformationManagementInterface.php b/vendor/magento/module-purchase-order/Api/NegotiableQuotePurchaseOrderPaymentInformationManagementInterface.php new file mode 100644 index 000000000000..f51e1f3e3c99 --- /dev/null +++ b/vendor/magento/module-purchase-order/Api/NegotiableQuotePurchaseOrderPaymentInformationManagementInterface.php @@ -0,0 +1,44 @@ +validator->validate($cartId); + return $this->purchaseOrderPaymentInformationManagement + ->savePaymentInformationAndPlacePurchaseOrder($cartId, $paymentMethod, $billingAddress); + } +} diff --git a/vendor/magento/module-purchase-order/etc/di.xml b/vendor/magento/module-purchase-order/etc/di.xml index 893e294d7b1b..101460cba21c 100644 --- a/vendor/magento/module-purchase-order/etc/di.xml +++ b/vendor/magento/module-purchase-order/etc/di.xml @@ -18,6 +18,7 @@ + diff --git a/vendor/magento/module-purchase-order/etc/webapi.xml b/vendor/magento/module-purchase-order/etc/webapi.xml index 52ae421b0221..60543fe6092a 100644 --- a/vendor/magento/module-purchase-order/etc/webapi.xml +++ b/vendor/magento/module-purchase-order/etc/webapi.xml @@ -19,6 +19,13 @@ %cart_id% + + + + + + diff --git a/vendor/magento/module-purchase-order/view/frontend/web/js/action/place-po-order.js b/vendor/magento/module-purchase-order/view/frontend/web/js/action/place-po-order.js index 9233ce5eedbb..ad0b5d5d8ee2 100644 --- a/vendor/magento/module-purchase-order/view/frontend/web/js/action/place-po-order.js +++ b/vendor/magento/module-purchase-order/view/frontend/web/js/action/place-po-order.js @@ -23,7 +23,16 @@ define([ paymentMethod: paymentData }; - serviceUrl = urlBuilder.createUrl('/carts/mine/po-payment-information', {}); + if (window.checkoutConfig.isNegotiableQuote) { + serviceUrl = urlBuilder.createUrl( + '/negotiable-carts/:cartId/po-payment-information?isNegotiableQuote=true', + { + cartId: quote.getQuoteId() + } + ); + } else { + serviceUrl = urlBuilder.createUrl('/carts/mine/po-payment-information', {}); + } return placeOrderService(serviceUrl, payload, messageContainer); };