Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Free.php
Go to the documentation of this file.
1 <?php
7 
9 
22 {
23  const PAYMENT_METHOD_FREE_CODE = 'free';
24 
28  const XML_PATH_PAYMENT_FREE_ACTIVE = 'payment/free/active';
29 
30  const XML_PATH_PAYMENT_FREE_ORDER_STATUS = 'payment/free/order_status';
31 
32  const XML_PATH_PAYMENT_FREE_PAYMENT_ACTION = 'payment/free/payment_action';
33 
39  protected $_canAuthorize = true;
40 
47 
51  protected $priceCurrency;
52 
67  public function __construct(
68  \Magento\Framework\Model\Context $context,
69  \Magento\Framework\Registry $registry,
70  \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
71  \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
72  \Magento\Payment\Helper\Data $paymentData,
73  \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
74  \Magento\Payment\Model\Method\Logger $logger,
76  \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
77  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
78  array $data = []
79  ) {
80  parent::__construct(
81  $context,
82  $registry,
83  $extensionFactory,
85  $paymentData,
86  $scopeConfig,
87  $logger,
88  $resource,
89  $resourceCollection,
90  $data
91  );
92  $this->priceCurrency = $priceCurrency;
93  }
94 
101  public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
102  {
103  return parent::isAvailable(
104  $quote
105  ) && null !== $quote && $this->priceCurrency->round(
106  $quote->getGrandTotal()
107  ) == 0;
108  }
109 
116  public function isAvailableInConfig($quote = null)
117  {
118  return parent::isAvailable($quote);
119  }
120 
126  public function getConfigPaymentAction()
127  {
128  return $this->getConfigData('order_status') == 'pending' ? null : parent::getConfigPaymentAction();
129  }
130 }
isAvailableInConfig($quote=null)
Definition: Free.php:116
$quote
$resource
Definition: bulk.php:12
isAvailable(\Magento\Quote\Api\Data\CartInterface $quote=null)
Definition: Free.php:101
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
Definition: Free.php:67
const XML_PATH_PAYMENT_FREE_PAYMENT_ACTION
Definition: Free.php:32