31 private $checkoutAgreementsList;
36 private $activeStoreAgreementsFilter;
47 \
Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface $checkoutAgreementsList,
52 $this->checkoutAgreementsList = $checkoutAgreementsList;
53 $this->activeStoreAgreementsFilter = $activeStoreAgreementsFilter;
66 \
Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
68 \
Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
86 \
Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
88 \
Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
103 $agreements = $paymentMethod->getExtensionAttributes() ===
null 105 : $paymentMethod->getExtensionAttributes()->getAgreementIds();
107 if (!$this->agreementsValidator->isValid($agreements)) {
108 throw new \Magento\Framework\Exception\CouldNotSaveException(
110 "The order wasn't placed. " 111 .
"First, agree to the terms and conditions, then try placing your order again." 123 $isAgreementsEnabled = $this->scopeConfiguration->isSetFlag(
127 $agreementsList = $isAgreementsEnabled
128 ? $this->checkoutAgreementsList->getList($this->activeStoreAgreementsFilter->buildSearchCriteria())
130 return (
bool)($isAgreementsEnabled && count($agreementsList) > 0);
validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $paymentMethod)
beforeSavePaymentInformation(\Magento\Checkout\Api\PaymentInformationManagementInterface $subject, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress=null)
__construct(\Magento\Checkout\Api\AgreementsValidatorInterface $agreementsValidator, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration, \Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface $checkoutAgreementsList, \Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter $activeStoreAgreementsFilter)
beforeSavePaymentInformationAndPlaceOrder(\Magento\Checkout\Api\PaymentInformationManagementInterface $subject, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress=null)