We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit f0eb2756 authored by Ángel Campos's avatar Ángel Campos Committed by GitHub

[PW-2033]: Update Magento2 to latest library version dependency (6.0.0) (#656)

* [PW-2033]: Adjusting Boleto and Multibanco response handling for PHP API Lib 6.0.0

* Update Block/Checkout/Success.php
Co-Authored-By: default avatarcyattilakiss <42297201+cyattilakiss@users.noreply.github.com>

* Update Block/Checkout/Success.php
Co-Authored-By: default avatarcyattilakiss <42297201+cyattilakiss@users.noreply.github.com>

* Update composer.json
Co-Authored-By: default avatarcyattilakiss <42297201+cyattilakiss@users.noreply.github.com>

* [PW-2033]: Added !empty check on action and pspReference and assigned both variables

* [PW-2033]: Adjusting Multibanco additional data
Co-authored-by: default avatarcyattilakiss <42297201+cyattilakiss@users.noreply.github.com>
parent 5457e62d
......@@ -44,22 +44,30 @@ class Success extends \Magento\Framework\View\Element\Template
*/
protected $_orderFactory;
/**
* @var \Magento\Framework\Pricing\Helper\Data
*/
public $priceHelper;
/**
* Success constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Framework\Pricing\Helper\Data $priceHelper
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\Pricing\Helper\Data $priceHelper,
array $data = []
) {
$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->priceHelper = $priceHelper;
parent::__construct($context, $data);
}
......@@ -96,10 +104,10 @@ class Success extends \Magento\Framework\View\Element\Template
/**
* @return null|\string[]
*/
public function getBoletoPdfUrl()
public function getBoletoData()
{
if ($this->isBoletoPayment()) {
return $this->getOrder()->getPayment()->getAdditionalInformation('url');
return $this->getOrder()->getPayment()->getAdditionalInformation('action');
}
return null;
}
......@@ -129,10 +137,14 @@ class Success extends \Magento\Framework\View\Element\Template
public function getMultibancoData()
{
$result = [];
if (!empty($this->getOrder()->getPayment()) &&
!empty($this->getOrder()->getPayment()->getAdditionalInformation('comprafacil.entity'))
if (empty($this->getOrder()->getPayment())) {
return $result;
}
$action = $this->getOrder()->getPayment()->getAdditionalInformation('action');
if (!empty($action["paymentMethodType"]) &&
(strcmp($action["paymentMethodType"], 'multibanco') === 0)
) {
$result = $this->getOrder()->getPayment()->getAdditionalInformation();
$result = $action;
}
return $result;
......
......@@ -89,6 +89,7 @@ class CheckoutResponseValidator extends AbstractValidator
}
}
} elseif (!empty($response['additionalData']['comprafacil.entity'])) {
//Multibanco resultCode has changed after checkout v49 and comprafacil.entity is not received anymore
foreach ($response['additionalData'] as $key => $value) {
if (strpos($key, 'comprafacil') === 0) {
$payment->setAdditionalInformation($key, $value);
......@@ -105,31 +106,11 @@ class CheckoutResponseValidator extends AbstractValidator
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
break;
case "PresentToShopper":
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
// set additionalData
if (isset($response['outputDetails']) && is_array($response['outputDetails'])) {
$outputDetails = $response['outputDetails'];
if (isset($outputDetails['boletobancario.dueDate'])) {
$payment->setAdditionalInformation(
'dueDate',
$outputDetails['boletobancario.dueDate']
);
}
if (isset($outputDetails['boletobancario.expirationDate'])) {
$payment->setAdditionalInformation(
'expirationDate',
$outputDetails['boletobancario.expirationDate']
);
}
if (isset($outputDetails['boletobancario.url'])) {
$payment->setAdditionalInformation(
'url',
$outputDetails['boletobancario.url']
);
}
if (!empty($response['action'])) {
$payment->setAdditionalInformation('action', $response['action']);
}
if (!empty($response['pspReference'])) {
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
}
break;
case "RedirectShopper":
......
......@@ -14,7 +14,7 @@
}
],
"require": {
"adyen/php-api-library": "~4.1",
"adyen/php-api-library": "~6",
"magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*",
"magento/module-paypal": "100.3.*"
......
......@@ -69,7 +69,7 @@ $_isDemoMode = $block->isDemoMode();
<?php endif; ?>
<?php if($_info->getAdditionalInformation('lastname') != ""): ?>
<div>
<?php echo __('Firstname: %1', $_info->getAdditionalInformation('lastname')) ?>
<?php echo __('Lastname: %1', $_info->getAdditionalInformation('lastname')) ?>
</div>
<?php endif; ?>
......
......@@ -26,9 +26,12 @@
*/
?>
<?php if ($block->isBoletoPayment()) : ?>
<?php
$boletoData = $block->getBoletoData();
?>
<p>
<?php echo $block->escapeHtml(__('Boleto PDF: ')); ?>
<a href="<?php echo $block->escapeUrl($block->getBoletoPdfUrl()); ?>">
<a href="<?php echo $block->escapeUrl($boletoData['downloadUrl']); ?>">
<?php echo $block->escapeHtml(__('Click here to download the Boleto PDF')); ?>
</a>
</p>
......@@ -97,35 +100,35 @@
<table>
<tbody>
<?php if (!empty($multibancoData['comprafacil.entity'])) : ?>
<?php if (strcmp($multibancoData['paymentMethodType'], 'multibanco') === 0) : ?>
<tr>
<th><?php echo $block->escapeHtml(__('Entity')); ?></th>
<td><?php echo $multibancoData['comprafacil.entity'] ?></td>
<td><?php echo $multibancoData['entity'] ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.reference'])) : ?>
<?php if (!empty($multibancoData['reference'])) : ?>
<tr>
<th><?php echo $block->escapeHtml(__('Reference')); ?></th>
<td><?php echo $multibancoData['comprafacil.reference'] ?></td>
<td><?php echo $multibancoData['reference'] ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.amount'])) : ?>
<?php if (!empty($multibancoData['totalAmount'])) : ?>
<tr>
<th><?php echo $block->escapeHtml(__('Amount')); ?></th>
<td><?php echo $multibancoData['comprafacil.amount'] ?></td>
<td><?php echo $block->priceHelper->currency($multibancoData['totalAmount']['value']) //TODO: This value is showing as it comes from the API call and based on the currency the decimal point could be wrong until the Checkout Component is implemented ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.deadline'])) : ?>
<?php if (!empty($multibancoData['expiresAt'])) : ?>
<tr>
<th><?php echo $block->escapeHtml(__('Payment deadline')); ?></th>
<td><?php echo $multibancoData['comprafacil.deadline'] ?> <?php echo $block->escapeHtml(__('Days')); ?></td>
<td><?php echo $multibancoData['expiresAt'] ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php endif; ?>
\ No newline at end of file
<?php endif; ?>
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