Exemple #1
0
 public function testIsSatisfiedBy()
 {
     $paymentMethodCode = 'test';
     $this->configMock->expects($this->once())->method('getMethodsInfo')->will($this->returnValue(array($paymentMethodCode => array(\Magento\RecurringPayment\Model\Method\RecurringPaymentSpecification::CONFIG_KEY => 1))));
     $this->recurringPaymentSpecification = $this->objectManagerHelper->getObject('Magento\\RecurringPayment\\Model\\Method\\RecurringPaymentSpecification', array('paymentConfig' => $this->configMock));
     $this->assertTrue($this->recurringPaymentSpecification->isSatisfiedBy($paymentMethodCode));
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function observe(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Sales\Model\Quote $quote */
     $quote = $observer->getEvent()->getQuote();
     /** @var \Magento\Payment\Model\Method\AbstractMethod $paymentMethod */
     $paymentMethod = $observer->getEvent()->getMethodInstance();
     $result = $observer->getEvent()->getResult();
     if ($quote && $this->quoteFilter->hasRecurringItems($quote) && !$this->specification->isSatisfiedBy($paymentMethod->getCode())) {
         $result->isAvailable = false;
     }
 }
Exemple #3
0
 /**
  * @param \Magento\Payment\Model\Checks\ZeroTotal $subject
  * @param callable $proceed
  * @param PaymentMethodChecksInterface $paymentMethod
  * @param Quote $quote
  * @return bool
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundIsApplicable(\Magento\Payment\Model\Checks\ZeroTotal $subject, \Closure $proceed, PaymentMethodChecksInterface $paymentMethod, Quote $quote)
 {
     return $proceed($paymentMethod, $quote) || $this->specification->isSatisfiedBy($paymentMethod->getCode()) && $this->filter->hasRecurringItems($quote);
 }