123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Payment\Model;
- use Magento\Framework\App\RequestInterface;
- use Magento\Framework\Exception\LocalizedException;
- use Magento\Framework\UrlInterface;
- use Magento\Framework\View\Asset\Repository;
- use Psr\Log\LoggerInterface;
- use Magento\Payment\Model\Config as PaymentConfig;
- /**
- * Credit card configuration model
- *
- * @api
- * @since 100.0.2
- */
- class CcConfig
- {
- /**
- * @var \Magento\Payment\Model\Config
- */
- protected $config;
- /**
- * @var Repository
- */
- protected $assetRepo;
- /**
- * @var RequestInterface
- */
- protected $request;
- /**
- * @var UrlInterface
- */
- protected $urlBuilder;
- /**
- * @var LoggerInterface
- */
- protected $logger;
- /**
- * @param PaymentConfig $paymentConfig
- * @param Repository $assetRepo
- * @param RequestInterface $request
- * @param UrlInterface $urlBuilder
- * @param LoggerInterface $logger
- */
- public function __construct(
- PaymentConfig $paymentConfig,
- Repository $assetRepo,
- RequestInterface $request,
- UrlInterface $urlBuilder,
- LoggerInterface $logger
- ) {
- $this->config = $paymentConfig;
- $this->assetRepo = $assetRepo;
- $this->request = $request;
- $this->urlBuilder = $urlBuilder;
- $this->logger = $logger;
- }
- /**
- * Solo/switch card start years
- *
- * @return array
- * @deprecated 100.1.0 unused
- */
- public function getSsStartYears()
- {
- $years = [];
- $first = date("Y");
- for ($index = 5; $index >= 0; $index--) {
- $year = $first - $index;
- $years[$year] = $year;
- }
- return $years;
- }
- /**
- * Retrieve available credit card types
- *
- * @return array
- */
- public function getCcAvailableTypes()
- {
- return $this->config->getCcTypes();
- }
- /**
- * Retrieve credit card expire months
- *
- * @return array
- */
- public function getCcMonths()
- {
- return $this->config->getMonths();
- }
- /**
- * Retrieve credit card expire years
- *
- * @return array
- */
- public function getCcYears()
- {
- return $this->config->getYears();
- }
- /**
- * Retrieve has verification configuration
- *
- * @return bool
- */
- public function hasVerification()
- {
- return true;
- }
- /**
- * Whether switch/solo card type available
- *
- * @return bool
- * @deprecated 100.1.0 unused
- */
- public function hasSsCardType()
- {
- return false;
- }
- /**
- * Retrieve CVV tooltip image url
- *
- * @return string
- */
- public function getCvvImageUrl()
- {
- return $this->getViewFileUrl('Magento_Checkout::cvv.png');
- }
- /**
- * Retrieve url of a view file
- *
- * @param string $fileId
- * @param array $params
- * @return string
- */
- public function getViewFileUrl($fileId, array $params = [])
- {
- try {
- $params = array_merge(['_secure' => $this->request->isSecure()], $params);
- return $this->assetRepo->getUrlWithParams($fileId, $params);
- } catch (LocalizedException $e) {
- $this->logger->critical($e);
- return $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']);
- }
- }
- /**
- * Create a file asset that's subject of fallback system
- *
- * @param string $fileId
- * @param array $params
- * @return \Magento\Framework\View\Asset\File
- */
- public function createAsset($fileId, array $params = [])
- {
- $params = array_merge(['_secure' => $this->request->isSecure()], $params);
- return $this->assetRepo->createAsset($fileId, $params);
- }
- }
|