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 3202b52c authored by Alexandros Moraitis's avatar Alexandros Moraitis Committed by GitHub

Merge pull request #779 from Adyen/develop

Release 6.4.0
parents 842509ae ab9f4bcc
......@@ -32,22 +32,28 @@ class Success extends \Magento\Framework\View\Element\Template
/**
* @var \Magento\Sales\Model\Order $order
*/
protected $_order;
protected $order;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;
protected $checkoutSession;
/**
* @var \Magento\Checkout\Model\OrderFactory
*/
protected $_orderFactory;
protected $orderFactory;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $adyenHelper;
/**
* @var \Magento\Framework\Pricing\Helper\Data
* @var \Magento\Store\Model\StoreManagerInterface
*/
public $priceHelper;
protected $storeManager;
/**
* Success constructor.
......@@ -63,11 +69,15 @@ class Success extends \Magento\Framework\View\Element\Template
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\Pricing\Helper\Data $priceHelper,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
) {
$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->checkoutSession = $checkoutSession;
$this->orderFactory = $orderFactory;
$this->priceHelper = $priceHelper;
$this->adyenHelper = $adyenHelper;
$this->storeManager = $storeManager;
parent::__construct($context, $data);
}
......@@ -151,14 +161,55 @@ class Success extends \Magento\Framework\View\Element\Template
return $result;
}
/**
* If PresentToShopper resultCode and action has provided render this with the checkout component on the success page
* @return bool
*/
public function renderAction()
{
if (
!empty($this->getOrder()->getPayment()->getAdditionalInformation('resultCode')) &&
$this->getOrder()->getPayment()->getAdditionalInformation('resultCode') == 'PresentToShopper' &&
!empty($this->getOrder()->getPayment()->getAdditionalInformation('action'))
) {
return true;
}
return false;
}
public function getAction()
{
return json_encode($this->getOrder()->getPayment()->getAdditionalInformation('action'));
}
public function getLocale()
{
return $this->adyenHelper->getCurrentLocaleCode(
$this->storeManager->getStore()->getId()
);
}
public function getOriginKey()
{
return $this->adyenHelper->getOriginKeyForBaseUrl();
}
public function getEnvironment()
{
return $this->adyenHelper->getCheckoutEnvironment(
$this->storeManager->getStore()->getId()
);
}
/**
* @return \Magento\Sales\Model\Order
*/
public function getOrder()
{
if ($this->_order == null) {
$this->_order = $this->_orderFactory->create()->load($this->_checkoutSession->getLastOrderId());
if ($this->order == null) {
$this->order = $this->orderFactory->create()->load($this->checkoutSession->getLastOrderId());
}
return $this->_order;
return $this->order;
}
}
......@@ -173,7 +173,7 @@ class PaymentMethods extends AbstractHelper
"countryCode" => $this->getCurrentCountryCode($store, $country),
"amount" => [
"currency" => $currencyCode,
"value" => (int)$this->adyenHelper->formatAmount(
"value" => $this->adyenHelper->formatAmount(
$this->getCurrentPaymentAmount(),
$currencyCode
),
......@@ -253,14 +253,34 @@ class PaymentMethods extends AbstractHelper
}
/**
* @return bool|int
* @return float
*/
protected function getCurrentPaymentAmount()
{
if (($grandTotal = $this->getQuote()->getGrandTotal()) > 0) {
$grandTotal = $this->getQuote()->getGrandTotal();
if (!is_numeric($grandTotal)) {
throw new \Exception(
sprintf(
'Cannot retrieve a valid grand total from quote ID: `%s`. Expected a numeric value.',
$this->getQuote()->getEntityId()
)
);
}
$grandTotal = (float) $grandTotal;
if ($grandTotal > 0) {
return $grandTotal;
}
return 10;
throw new \Exception(
sprintf(
'Cannot retrieve a valid grand total from quote ID: `%s`. Expected a float > `0`, got `%f`.',
$this->getQuote()->getEntityId(),
$grandTotal
)
);
}
/**
......
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "6.3.0",
"version": "6.4.0",
"license": [
"OSL-3.0",
"AFL-3.0"
......
......@@ -22,10 +22,15 @@
* Author: Adyen <magento@adyen.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Adyen_Payment::css/styles.css"/>
</head>
<body>
<referenceContainer name="order.success.additional.info">
<block class="Adyen\Payment\Block\Checkout\Success" name="onepage.success.adyen_payment" template="checkout/success.phtml" cacheable="false"/>
<block class="Adyen\Payment\Block\Checkout\Success" name="onepage.success.adyen_payment"
template="checkout/success.phtml" cacheable="false"/>
</referenceContainer>
</body>
</body>
</page>
......@@ -14,7 +14,8 @@ var config = {
},
map: {
'*': {
'adyenCheckout': 'https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.4.0/adyen.js'
'adyenCheckout': 'https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.4.0/adyen.js',
'adyenCheckout3101': 'https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.10.1/adyen.js'
}
}
};
......@@ -25,7 +25,28 @@
* @var \Adyen\Payment\Block\Checkout\Success $block
*/
?>
<?php if ($block->isBoletoPayment()): ?>
<?php if ($block->renderAction()): ?>
<script type="text/javascript">
require([
'jquery',
'adyenCheckout3101'
], function ($, AdyenCheckout) {
var action = JSON.parse('<?= /* @noEscape */ $block->getAction(); ?>');
var checkoutComponent = new AdyenCheckout({
locale: '<?= $block->escapeHtml($block->getLocale()); ?>',
environment: '<?= $block->escapeHtml($block->getEnvironment()); ?>',
originKey: '<?= $block->escapeHtml($block->getOriginKey()); ?>'
});
try {
checkoutComponent.createFromAction(action).mount('#ActionContainer');
} catch(err) {
// Action component cannot be created
}
});
</script>
<div id="ActionContainer"></div>
<?php else: ?>
<?php if ($block->isBoletoPayment()): ?>
<?php
$boletoData = $block->getBoletoData();
?>
......@@ -37,7 +58,7 @@
</p>
<?php endif; ?>
<?php if (!empty($block->getBankTransferData())): ?>
<?php if (!empty($block->getBankTransferData())): ?>
<?php
$banktranferData = $block->getBankTransferData();
$order = $block->getOrder();
......@@ -51,7 +72,8 @@
<?php if (!empty($order->getGrandTotal())): ?>
<tr>
<th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th>
<td><?= /* @noEscape */ $order->formatPrice($order->getGrandTotal()); ?></td>
<td><?= /* @noEscape */
$order->formatPrice($order->getGrandTotal()); ?></td>
</tr>
<?php endif; ?>
......@@ -122,7 +144,8 @@
<?php if (!empty($multibancoData['totalAmount'])): ?>
<tr>
<th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th>
<td><?= /* @noEscape */ $block->priceHelper->currency($multibancoData['totalAmount']['value']);?>
<td><?= /* @noEscape */
$block->priceHelper->currency($multibancoData['totalAmount']['value']); ?>
</td>
</tr>
<?php endif; ?>
......@@ -135,4 +158,5 @@
<?php endif; ?>
</tbody>
</table>
<?php endif; ?>
<?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