Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Cc.php
Go to the documentation of this file.
1 <?php
7 
15 {
21  protected $_paymentConfig;
22 
28  public function __construct(
29  \Magento\Framework\View\Element\Template\Context $context,
30  \Magento\Payment\Model\Config $paymentConfig,
31  array $data = []
32  ) {
33  parent::__construct($context, $data);
34  $this->_paymentConfig = $paymentConfig;
35  }
36 
42  public function getCcTypeName()
43  {
44  $types = $this->_paymentConfig->getCcTypes();
45  $ccType = $this->getInfo()->getCcType();
46  if (isset($types[$ccType])) {
47  return $types[$ccType];
48  }
49  return empty($ccType) ? __('N/A') : $ccType;
50  }
51 
57  public function hasCcExpDate()
58  {
59  return (int)$this->getInfo()->getCcExpMonth() || (int)$this->getInfo()->getCcExpYear();
60  }
61 
67  public function getCcExpMonth()
68  {
69  $month = $this->getInfo()->getCcExpMonth();
70  if ($month < 10) {
71  $month = '0' . $month;
72  }
73  return $month;
74  }
75 
81  public function getCcExpDate()
82  {
83  $date = new \DateTime('now', new \DateTimeZone($this->_localeDate->getConfigTimezone()));
84  $date->setDate($this->getInfo()->getCcExpYear(), $this->getInfo()->getCcExpMonth() + 1, 0);
85  return $date;
86  }
87 
94  protected function _prepareSpecificInformation($transport = null)
95  {
96  if (null !== $this->_paymentSpecificInformation) {
98  }
99  $transport = parent::_prepareSpecificInformation($transport);
100  $data = [];
101  if ($ccType = $this->getCcTypeName()) {
102  $data[(string)__('Credit Card Type')] = $ccType;
103  }
104  if ($this->getInfo()->getCcLast4()) {
105  $data[(string)__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
106  }
107 
108  if (!$this->getIsSecureMode()) {
109  if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
110  $data[(string)__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
111  }
112  $year = $this->getInfo()->getCcSsStartYear();
113  $month = $this->getInfo()->getCcSsStartMonth();
114  if ($year && $month) {
115  $data[(string)__('Switch/Solo/Maestro Start Date')] = $this->_formatCardDate($year, $month);
116  }
117  }
118  return $transport->setData(array_merge($data, $transport->getData()));
119  }
120 
128  protected function _formatCardDate($year, $month)
129  {
130  return sprintf('%s/%s', sprintf('%02d', $month), $year);
131  }
132 }
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Payment\Model\Config $paymentConfig, array $data=[])
Definition: Cc.php:28
__()
Definition: __.php:13
$ccType
Definition: info.phtml:16
_prepareSpecificInformation($transport=null)
Definition: Cc.php:94
_formatCardDate($year, $month)
Definition: Cc.php:128