示例#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());
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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);
 }