getData('info'); if (!$info instanceof \Magento\Payment\Model\InfoInterface) { throw new \Magento\Framework\Exception\LocalizedException( __('We cannot retrieve the payment info model object.') ); } return $info; } /** * Retrieve payment method model * * @return \Magento\Payment\Model\MethodInterface */ public function getMethod() { return $this->getInfo()->getMethodInstance(); } /** * Render as PDF * @return string */ public function toPdf() { $this->setTemplate('Magento_Payment::info/pdf/default.phtml'); return $this->toHtml(); } /** * Getter for children PDF, as array. Analogue of $this->getChildHtml() * * Children must have toPdf() callable * Known issue: not sorted * @return array */ public function getChildPdfAsArray() { $result = []; foreach ($this->getLayout()->getChildBlocks($this->getNameInLayout()) as $child) { if (method_exists($child, 'toPdf') && is_callable([$child, 'toPdf'])) { $result[] = $child->toPdf(); } } return $result; } /** * Get some specific information in format of array($label => $value) * * @return array */ public function getSpecificInformation() { return $this->_prepareSpecificInformation()->getData(); } /** * Render the value as an array * * @param mixed $value * @param bool $escapeHtml * @return array */ public function getValueAsArray($value, $escapeHtml = false) { if (empty($value)) { return []; } if (!is_array($value)) { $value = [$value]; } if ($escapeHtml) { foreach ($value as $_key => $_val) { $value[$_key] = $this->escapeHtml($_val); } } return $value; } /** * Check whether payment information should show up in secure mode * true => only "public" payment information may be shown * false => full information may be shown * * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getIsSecureMode() { if ($this->hasIsSecureMode()) { return (bool)(int)$this->_getData('is_secure_mode'); } $method = $this->getMethod(); if (!$method) { return true; } $store = $method->getStore(); if (!$store) { return false; } $methodStore = $this->_storeManager->getStore($store); return $methodStore->getCode() != \Magento\Store\Model\Store::ADMIN_CODE; } /** * Prepare information specific to current payment method * * @param null|\Magento\Framework\DataObject|array $transport * @return \Magento\Framework\DataObject */ protected function _prepareSpecificInformation($transport = null) { if (null === $this->_paymentSpecificInformation) { if (null === $transport) { $transport = new \Magento\Framework\DataObject(); } elseif (is_array($transport)) { $transport = new \Magento\Framework\DataObject($transport); } $this->_paymentSpecificInformation = $transport; } return $this->_paymentSpecificInformation; } }