Commit bff0916e authored by attilak's avatar attilak

Refactor retrieving action and additionalData in Success.php block

parent 4e26bfaa
...@@ -90,6 +90,7 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -90,6 +90,7 @@ class Success extends \Magento\Framework\View\Element\Template
/** /**
* Detect if Boleto is used as payment method * Detect if Boleto is used as payment method
*
* @return bool * @return bool
*/ */
public function isBoletoPayment() public function isBoletoPayment()
...@@ -102,14 +103,15 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -102,14 +103,15 @@ class Success extends \Magento\Framework\View\Element\Template
} }
/** /**
* @return null|\string[] * @return array|string[]
*/ */
public function getBoletoData() public function getBoletoData()
{ {
if ($this->isBoletoPayment()) { if ($this->isBoletoPayment()) {
return $this->getOrder()->getPayment()->getAdditionalInformation('action'); return $this->getActionData();
} }
return null;
return [];
} }
/** /**
...@@ -119,38 +121,42 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -119,38 +121,42 @@ class Success extends \Magento\Framework\View\Element\Template
*/ */
public function getBankTransferData() public function getBankTransferData()
{ {
$result = []; $additionalData = $this->getAdditionalData();
if (!empty($this->getOrder()->getPayment()) &&
!empty($this->getOrder()->getPayment()->getAdditionalInformation('bankTransfer.owner')) if (empty($additionalData['bankTransfer.owner'])) {
) { return [];
$result = $this->getOrder()->getPayment()->getAdditionalInformation();
} }
return $result; return $additionalData;
} }
/** /**
* Get multibanco additional data * Retreive additionalData for a payment
* *
* @return array|string[] * @return array|string[]
*/ */
public function getMultibancoData() public function getAdditionalData()
{ {
$result = [];
if (empty($this->getOrder()->getPayment())) { if (empty($this->getOrder()->getPayment())) {
return $result; return [];
}
$action = $this->getOrder()->getPayment()->getAdditionalInformation('action');
if (!empty($action["paymentMethodType"]) &&
(strcmp($action["paymentMethodType"], 'multibanco') === 0)
) {
$result = $action;
} }
return $result; return $this->getOrder()->getPayment()->getAdditionalInformation('additionalData');
} }
/**
* Retreive action for a payment
*
* @return array|string[]
*/
public function getActionData()
{
if (empty($this->getOrder()->getPayment())) {
return [];
}
return $this->getOrder()->getPayment()->getAdditionalInformation('action');
}
/** /**
* @return \Magento\Sales\Model\Order * @return \Magento\Sales\Model\Order
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment