![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-payment/Model/Method/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Payment\Model\Method; use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Free payment method * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() * * This is an implementation of payment method that allows order for free. * Magento contains special flow for handling this payment method. * Inheritance is allowed to modify it behavior. * * @api * @since 100.0.2 */ class Free extends \Magento\Payment\Model\Method\AbstractMethod { public const PAYMENT_METHOD_FREE_CODE = 'free'; /** * XML Paths for configuration constants */ public const XML_PATH_PAYMENT_FREE_ACTIVE = 'payment/free/active'; public const XML_PATH_PAYMENT_FREE_ORDER_STATUS = 'payment/free/order_status'; public const XML_PATH_PAYMENT_FREE_PAYMENT_ACTION = 'payment/free/payment_action'; /** * Payment Method features * * @var bool */ protected $_canAuthorize = true; /** * Payment code name * * @var string */ protected $_code = self::PAYMENT_METHOD_FREE_CODE; /** * @var PriceCurrencyInterface */ protected $priceCurrency; /** * @var bool */ protected $_isOffline = true; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Logger $logger * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __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 = [] ) { parent::__construct( $context, $registry, $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, $logger, $resource, $resourceCollection, $data ); $this->priceCurrency = $priceCurrency; } /** * Check whether method is available * * @param \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote|null $quote * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { return parent::isAvailable( $quote ) && null !== $quote && $this->priceCurrency->round( $quote->getGrandTotal() ) == 0; } /** * 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); } /** * Get config payment action, do nothing if status is pending * * @return string|null */ public function getConfigPaymentAction() { return $this->getConfigData('order_status') == 'pending' ? null : parent::getConfigPaymentAction(); } }