agreementFactory = $agreementFactory; } /** * Override check for Billing Agreements * * @param SpecificationInterface $specification * @param bool $result * @param MethodInterface $paymentMethod * @param Quote $quote * @return bool * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterIsApplicable( SpecificationInterface $specification, $result, MethodInterface $paymentMethod, Quote $quote ) { if (!$result) { return false; } if ($paymentMethod->getCode() == Config::METHOD_BILLING_AGREEMENT) { if ($quote->getCustomerId()) { $availableBA = $this->agreementFactory->create()->getAvailableCustomerBillingAgreements( $quote->getCustomerId() ); return count($availableBA) > 0; } return false; } return true; } }