예제 #1
0
 /**
  * @param bool $result
  *
  * @dataProvider dataProviderForTestIsAvailable
  */
 public function testIsAvailable($result)
 {
     $storeId = 15;
     $this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($storeId);
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with('payment/' . Stub::STUB_CODE . '/active', ScopeInterface::SCOPE_STORE, $storeId)->willReturn($result);
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->equalTo('payment_method_is_active'), $this->countOf(3));
     $this->assertEquals($result, $this->payment->isAvailable($this->quoteMock));
 }
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     if ($quote && ($quote->getBaseGrandTotal() < $this->_minAmount || $this->_maxAmount && $quote->getBaseGrandTotal() > $this->_maxAmount)) {
         return false;
     }
     return parent::isAvailable($quote);
 }
예제 #3
0
 /**
  * Check whether payment method can be used
  *
  * @param CartInterface|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     if ($quote === null) {
         return false;
     }
     return parent::isAvailable($quote) && $this->isCarrierAllowed($quote->getShippingAddress()->getShippingMethod());
 }
예제 #4
0
 /**
  * Check whether method is available
  *
  * @param \Magento\Paypal\Model\Quote|\Magento\Quote\Api\Data\CartInterface|null $quote
  * @return bool
  */
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     if ($this->_isAvailable === null) {
         $this->_isAvailable = parent::isAvailable($quote) && $this->_isAvailable($quote);
         $this->_canUseCheckout = $this->_isAvailable && $this->_canUseCheckout;
         $this->_canUseInternal = $this->_isAvailable && $this->_canUseInternal;
     }
     return $this->_isAvailable;
 }
예제 #5
0
 /**
  * Check whether method is available
  *
  * @param \Magento\Paypal\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     if (is_null($this->_isAvailable)) {
         $this->_isAvailable = parent::isAvailable($quote) && $this->_isAvailable($quote);
         $this->_canUseCheckout = $this->_isAvailable && $this->_canUseCheckout;
         $this->_canUseInternal = $this->_isAvailable && $this->_canUseInternal;
     }
     return $this->_isAvailable;
 }
예제 #6
0
 /**
  * Get map of cc_code, cc_num, cc_expdate for gateway
  * Returns json formatted string
  *
  * @return string
  */
 protected function getCardFieldsMap()
 {
     $result = [];
     if ($this->method->isAvailable()) {
         $configData = $this->getMethodConfigData('ccfields');
         $keys = ['cccvv', 'ccexpdate', 'ccnum'];
         $result = array_combine($keys, explode(',', $configData));
     }
     return $result;
 }
예제 #7
0
 /**
  * Check whether method is available
  *
  * @param \Magento\Paypal\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     if (is_null($this->_isAvailable)) {
         if (is_object($quote) && $quote->getCustomerId()) {
             $availableBA = $this->_agreementFactory->create()->getAvailableCustomerBillingAgreements($quote->getCustomerId());
             $isAvailableBA = count($availableBA) > 0;
             $this->_canUseCheckout = $this->_canUseInternal = $isAvailableBA;
         }
         $this->_isAvailable = parent::isAvailable($quote) && $this->_isAvailable($quote);
         $this->_canUseCheckout = $this->_isAvailable && $this->_canUseCheckout;
         $this->_canUseInternal = $this->_isAvailable && $this->_canUseInternal;
     }
     return $this->_isAvailable;
 }
 /**
  * @param CartInterface|null $quote
  * @return bool
  */
 public function isAvailable(CartInterface $quote = null)
 {
     if (!parent::isAvailable($quote)) {
         return false;
     }
     $customer = $quote->getCustomer();
     $openpayCustomer = $customer->getExtensionAttributes()->getOpenpayCustomer();
     if ($openpayCustomer->getBalance() < $quote->getData('grand_total') || $quote->getData('grand_total') <= 0) {
         return false;
     }
     $currency = $quote->getCurrency()->getQuoteCurrencyCode();
     $acceptedCurrencies = $this->getCurrenciesAccepted();
     if (!in_array($currency, $acceptedCurrencies)) {
         return false;
     }
     return true;
 }
예제 #9
0
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     return parent::isAvailable($quote);
 }
예제 #10
0
파일: Free.php 프로젝트: aiesh/magento2
 /**
  * Check whether method is available
  *
  * @param \Magento\Sales\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     return parent::isAvailable($quote) && !empty($quote) && $this->_storeManager->getStore()->roundPrice($quote->getGrandTotal()) == 0;
 }
예제 #11
0
 /**
  * Check whether payment method can be used
  * @param Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     if (parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable()) {
         return true;
     }
     return false;
 }
예제 #12
0
 /**
  * Check whether method is available
  *
  * @param \Magento\Sales\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     return parent::isAvailable($quote) && !empty($quote) && $this->priceCurrency->round($quote->getGrandTotal()) == 0;
 }
예제 #13
0
 /**
  * Check whether payment method can be used
  *
  * @param \Magento\Quote\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     return AbstractMethod::isAvailable($quote) && $this->getConfig()->isMethodAvailable($this->getCode());
 }
예제 #14
0
 /**
  * Check whether payment method can be used
  *
  * @param \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote|null $quote
  * @return bool
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     return AbstractMethod::isAvailable($quote) && $this->getConfig()->isMethodAvailable($this->getCode());
 }
예제 #15
0
 /**
  * Check whether there are CC types set in configuration
  *
  * @param \Magento\Quote\Api\Data\CartInterface|null $quote
  * @return bool
  */
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     return $this->getConfigData('cctypes', $quote ? $quote->getStoreId() : null) && parent::isAvailable($quote);
 }
예제 #16
0
 /**
  * Check whether payment method can be used
  *
  * @param \Magento\Sales\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $storeId = $this->_storeManager->getStore($this->getStore())->getId();
     /** @var \Magento\Paypal\Model\Config $config */
     $config = $this->_configFactory->create()->setStoreId($storeId);
     if (\Magento\Payment\Model\Method\AbstractMethod::isAvailable($quote) && $config->isMethodAvailable($this->getCode())) {
         return true;
     }
     return false;
 }
예제 #17
0
 /**
  * Check whether payment method can be used
  *
  * @param \Magento\Quote\Api\Data\CartInterface|null $quote
  *
  * @return bool
  */
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     $parent = parent::isAvailable($quote);
     $clientId = $this->_scopeConfig->getValue(\MercadoPago\Core\Helper\Data::XML_PATH_CLIENT_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     $clientSecret = $this->_scopeConfig->getValue(\MercadoPago\Core\Helper\Data::XML_PATH_CLIENT_SECRET, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     $standard = !empty($clientId) && !empty($clientSecret);
     if (!$parent || !$standard) {
         return false;
     }
     return $this->_helperData->isValidClientCredentials($clientId, $clientSecret);
 }
예제 #18
0
 /**
  * Check whether payment method can be used
  *
  * @param \Magento\Quote\Api\Data\CartInterface|null $quote
  * @return bool
  */
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     if (is_null($quote)) {
         return parent::isAvailable();
     } else {
         return parent::isAvailable($quote) && $this->isShippingMethodAllowed($quote->getShippingAddress()->getShippingMethod()) && $this->paytypeHelper->getAllForQuote($quote) !== [];
     }
 }
예제 #19
0
파일: Free.php 프로젝트: nja78/magento2
 /**
  * Check whether method is enabled in config
  *
  * @param \Magento\Quote\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailableInConfig($quote = null)
 {
     return parent::isAvailable($quote);
 }
 /**
  * Check whether payment method can be used
  *
  * @param CartInterface|null $quote
  * @return bool
  */
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     if ($quote === null) {
         return false;
     }
     return parent::isAvailable($quote) && $this->isCarrierAllowed($quote->getShippingAddress()->getShippingMethod());
 }
예제 #21
0
파일: Cc.php 프로젝트: kid17/magento2
 /**
  * Check whether there are CC types set in configuration
  *
  * @param \Magento\Quote\Api\Data\CartInterface|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     return $this->getConfigData('cctypes', $quote ? $quote->getStoreId() : null) && parent::isAvailable($quote);
 }
 /**
  * @param CartInterface|null $quote
  * @return bool
  */
 public function isAvailable(CartInterface $quote = null)
 {
     if (!parent::isAvailable($quote)) {
         return false;
     }
     $customer = $quote->getCustomer();
     $openpayCards = $customer->getExtensionAttributes()->getOpenpayCard();
     if (count($openpayCards) === 0) {
         return false;
     }
     $openpayConfigValues = $this->config->getValue('payment/openpay');
     $chargeMinAmount = $openpayConfigValues['chargeMinAmount'];
     if ($chargeMinAmount > $quote->getGrandTotal()) {
         return false;
     }
     $currency = $quote->getCurrency()->getQuoteCurrencyCode();
     $acceptedCurrencies = $this->getCurrenciesAccepted();
     if (!in_array($currency, $acceptedCurrencies)) {
         return false;
     }
     return true;
 }
예제 #23
0
 /**
  * Determines method's availability based on config data and quote amount
  *
  * @param \Magento\Quote\Api\Data\CartInterface|null $quote
  * @return bool
  */
 public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
 {
     return parent::isAvailable($quote) && $this->getConfigHelper()->isMethodAvailable();
 }
예제 #24
0
 /**
  * @param Quote|\Magento\Quote\Api\Data\CartInterface $quote
  *
  * @return bool
  */
 protected function _isAvailableRatePay($quote)
 {
     $dob = $quote->getCustomer()->getDob();
     $minAge = (int) $this->getConfigData('min_age');
     if ($minAge <= 0) {
         $this->_logger->debug(__METHOD__ . ':warning min-age not set for ratepay');
         return false;
     }
     //we only need to check the dob if it's set. Else we ask for dob on payment selection page.
     if ($dob) {
         $dobObject = new \DateTime($dob);
         $currentYear = date('Y');
         $currentMonth = date('m');
         $currentDay = date('d');
         $ageCheckDate = $currentYear - $minAge . '-' . $currentMonth . '-' . $currentDay;
         $ageCheckObject = new \DateTime($ageCheckDate);
         if ($ageCheckObject < $dobObject) {
             return false;
         }
     }
     if ($quote->hasVirtualItems()) {
         return false;
     }
     if ($this->getConfigData('billing_shipping_address_identical') && !$this->compareAddresses($quote)) {
         return false;
     }
     $currencies = explode(',', $this->getConfigData('currency'));
     if (!in_array($quote->getQuoteCurrencyCode(), $currencies)) {
         return false;
     }
     if (strlen($this->getConfigData('shippingcountry'))) {
         $countries = explode(',', $this->getConfigData('shippingcountry'));
         if (!in_array($quote->getShippingAddress()->getCountry(), $countries)) {
             return false;
         }
     }
     if (strlen($this->getConfigData('max_basket_size'))) {
         if ($quote->getItemsQty() > $this->getConfigData('max_basket_size')) {
             return false;
         }
     }
     if (strlen($this->getConfigData('min_basket_size'))) {
         if ($quote->getItemsQty() < $this->getConfigData('min_basket_size')) {
             return false;
         }
     }
     return parent::isAvailable($quote);
 }