We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday 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 ...@@ -44,22 +44,30 @@ class Success extends \Magento\Framework\View\Element\Template
*/ */
protected $_orderFactory; protected $_orderFactory;
/**
* @var \Magento\Framework\Pricing\Helper\Data
*/
public $priceHelper;
/** /**
* Success constructor. * Success constructor.
* *
* @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Framework\Pricing\Helper\Data $priceHelper
* @param array $data * @param array $data
*/ */
public function __construct( public function __construct(
\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\View\Element\Template\Context $context,
\Magento\Checkout\Model\Session $checkoutSession, \Magento\Checkout\Model\Session $checkoutSession,
\Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\Pricing\Helper\Data $priceHelper,
array $data = [] array $data = []
) { ) {
$this->_checkoutSession = $checkoutSession; $this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->priceHelper = $priceHelper;
parent::__construct($context, $data); parent::__construct($context, $data);
} }
...@@ -96,10 +104,10 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -96,10 +104,10 @@ class Success extends \Magento\Framework\View\Element\Template
/** /**
* @return null|\string[] * @return null|\string[]
*/ */
public function getBoletoPdfUrl() public function getBoletoData()
{ {
if ($this->isBoletoPayment()) { if ($this->isBoletoPayment()) {
return $this->getOrder()->getPayment()->getAdditionalInformation('url'); return $this->getOrder()->getPayment()->getAdditionalInformation('action');
} }
return null; return null;
} }
...@@ -129,10 +137,14 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -129,10 +137,14 @@ class Success extends \Magento\Framework\View\Element\Template
public function getMultibancoData() public function getMultibancoData()
{ {
$result = []; $result = [];
if (!empty($this->getOrder()->getPayment()) && if (empty($this->getOrder()->getPayment())) {
!empty($this->getOrder()->getPayment()->getAdditionalInformation('comprafacil.entity')) 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; return $result;
......
...@@ -89,6 +89,7 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -89,6 +89,7 @@ class CheckoutResponseValidator extends AbstractValidator
} }
} }
} elseif (!empty($response['additionalData']['comprafacil.entity'])) { } 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) { foreach ($response['additionalData'] as $key => $value) {
if (strpos($key, 'comprafacil') === 0) { if (strpos($key, 'comprafacil') === 0) {
$payment->setAdditionalInformation($key, $value); $payment->setAdditionalInformation($key, $value);
...@@ -105,31 +106,11 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -105,31 +106,11 @@ class CheckoutResponseValidator extends AbstractValidator
$payment->setAdditionalInformation('pspReference', $response['pspReference']); $payment->setAdditionalInformation('pspReference', $response['pspReference']);
break; break;
case "PresentToShopper": case "PresentToShopper":
$payment->setAdditionalInformation('pspReference', $response['pspReference']); if (!empty($response['action'])) {
// set additionalData $payment->setAdditionalInformation('action', $response['action']);
if (isset($response['outputDetails']) && is_array($response['outputDetails'])) { }
if (!empty($response['pspReference'])) {
$outputDetails = $response['outputDetails']; $payment->setAdditionalInformation('pspReference', $response['pspReference']);
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']
);
}
} }
break; break;
case "RedirectShopper": case "RedirectShopper":
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
} }
], ],
"require": { "require": {
"adyen/php-api-library": "~4.1", "adyen/php-api-library": "~6",
"magento/framework": ">=101.0.8 <102 || >=102.0.1", "magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*", "magento/module-vault": "101.*",
"magento/module-paypal": "100.3.*" "magento/module-paypal": "100.3.*"
......
...@@ -69,7 +69,7 @@ $_isDemoMode = $block->isDemoMode(); ...@@ -69,7 +69,7 @@ $_isDemoMode = $block->isDemoMode();
<?php endif; ?> <?php endif; ?>
<?php if($_info->getAdditionalInformation('lastname') != ""): ?> <?php if($_info->getAdditionalInformation('lastname') != ""): ?>
<div> <div>
<?php echo __('Firstname: %1', $_info->getAdditionalInformation('lastname')) ?> <?php echo __('Lastname: %1', $_info->getAdditionalInformation('lastname')) ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
......
...@@ -26,9 +26,12 @@ ...@@ -26,9 +26,12 @@
*/ */
?> ?>
<?php if ($block->isBoletoPayment()) : ?> <?php if ($block->isBoletoPayment()) : ?>
<?php
$boletoData = $block->getBoletoData();
?>
<p> <p>
<?php echo $block->escapeHtml(__('Boleto PDF: ')); ?> <?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')); ?> <?php echo $block->escapeHtml(__('Click here to download the Boleto PDF')); ?>
</a> </a>
</p> </p>
...@@ -97,35 +100,35 @@ ...@@ -97,35 +100,35 @@
<table> <table>
<tbody> <tbody>
<?php if (!empty($multibancoData['comprafacil.entity'])) : ?> <?php if (strcmp($multibancoData['paymentMethodType'], 'multibanco') === 0) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Entity')); ?></th> <th><?php echo $block->escapeHtml(__('Entity')); ?></th>
<td><?php echo $multibancoData['comprafacil.entity'] ?></td> <td><?php echo $multibancoData['entity'] ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.reference'])) : ?> <?php if (!empty($multibancoData['reference'])) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Reference')); ?></th> <th><?php echo $block->escapeHtml(__('Reference')); ?></th>
<td><?php echo $multibancoData['comprafacil.reference'] ?></td> <td><?php echo $multibancoData['reference'] ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.amount'])) : ?> <?php if (!empty($multibancoData['totalAmount'])) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Amount')); ?></th> <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> </tr>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.deadline'])) : ?> <?php if (!empty($multibancoData['expiresAt'])) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Payment deadline')); ?></th> <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> </tr>
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>
</table> </table>
<?php endif; ?> <?php endif; ?>
\ No newline at end of file
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