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 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 ...@@ -32,22 +32,28 @@ class Success extends \Magento\Framework\View\Element\Template
/** /**
* @var \Magento\Sales\Model\Order $order * @var \Magento\Sales\Model\Order $order
*/ */
protected $_order; protected $order;
/** /**
* @var \Magento\Checkout\Model\Session * @var \Magento\Checkout\Model\Session
*/ */
protected $_checkoutSession; protected $checkoutSession;
/** /**
* @var \Magento\Checkout\Model\OrderFactory * @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. * Success constructor.
...@@ -63,11 +69,15 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -63,11 +69,15 @@ class Success extends \Magento\Framework\View\Element\Template
\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, \Magento\Framework\Pricing\Helper\Data $priceHelper,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = [] array $data = []
) { ) {
$this->_checkoutSession = $checkoutSession; $this->checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory; $this->orderFactory = $orderFactory;
$this->priceHelper = $priceHelper; $this->priceHelper = $priceHelper;
$this->adyenHelper = $adyenHelper;
$this->storeManager = $storeManager;
parent::__construct($context, $data); parent::__construct($context, $data);
} }
...@@ -151,14 +161,55 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -151,14 +161,55 @@ class Success extends \Magento\Framework\View\Element\Template
return $result; 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 * @return \Magento\Sales\Model\Order
*/ */
public function getOrder() public function getOrder()
{ {
if ($this->_order == null) { if ($this->order == null) {
$this->_order = $this->_orderFactory->create()->load($this->_checkoutSession->getLastOrderId()); $this->order = $this->orderFactory->create()->load($this->checkoutSession->getLastOrderId());
} }
return $this->_order; return $this->order;
} }
} }
...@@ -173,7 +173,7 @@ class PaymentMethods extends AbstractHelper ...@@ -173,7 +173,7 @@ class PaymentMethods extends AbstractHelper
"countryCode" => $this->getCurrentCountryCode($store, $country), "countryCode" => $this->getCurrentCountryCode($store, $country),
"amount" => [ "amount" => [
"currency" => $currencyCode, "currency" => $currencyCode,
"value" => (int)$this->adyenHelper->formatAmount( "value" => $this->adyenHelper->formatAmount(
$this->getCurrentPaymentAmount(), $this->getCurrentPaymentAmount(),
$currencyCode $currencyCode
), ),
...@@ -253,14 +253,34 @@ class PaymentMethods extends AbstractHelper ...@@ -253,14 +253,34 @@ class PaymentMethods extends AbstractHelper
} }
/** /**
* @return bool|int * @return float
*/ */
protected function getCurrentPaymentAmount() 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 $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 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "6.3.0", "version": "6.4.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
...@@ -22,10 +22,15 @@ ...@@ -22,10 +22,15 @@
* Author: Adyen <magento@adyen.com> * 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"> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<body> 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"> <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> </referenceContainer>
</body> </body>
</page> </page>
...@@ -14,7 +14,8 @@ var config = { ...@@ -14,7 +14,8 @@ var config = {
}, },
map: { 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 @@ ...@@ -25,7 +25,28 @@
* @var \Adyen\Payment\Block\Checkout\Success $block * @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 <?php
$boletoData = $block->getBoletoData(); $boletoData = $block->getBoletoData();
?> ?>
...@@ -37,7 +58,7 @@ ...@@ -37,7 +58,7 @@
</p> </p>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($block->getBankTransferData())): ?> <?php if (!empty($block->getBankTransferData())): ?>
<?php <?php
$banktranferData = $block->getBankTransferData(); $banktranferData = $block->getBankTransferData();
$order = $block->getOrder(); $order = $block->getOrder();
...@@ -51,7 +72,8 @@ ...@@ -51,7 +72,8 @@
<?php if (!empty($order->getGrandTotal())): ?> <?php if (!empty($order->getGrandTotal())): ?>
<tr> <tr>
<th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th> <th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th>
<td><?= /* @noEscape */ $order->formatPrice($order->getGrandTotal()); ?></td> <td><?= /* @noEscape */
$order->formatPrice($order->getGrandTotal()); ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
...@@ -122,7 +144,8 @@ ...@@ -122,7 +144,8 @@
<?php if (!empty($multibancoData['totalAmount'])): ?> <?php if (!empty($multibancoData['totalAmount'])): ?>
<tr> <tr>
<th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th> <th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th>
<td><?= /* @noEscape */ $block->priceHelper->currency($multibancoData['totalAmount']['value']);?> <td><?= /* @noEscape */
$block->priceHelper->currency($multibancoData['totalAmount']['value']); ?>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
...@@ -135,4 +158,5 @@ ...@@ -135,4 +158,5 @@
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>
</table> </table>
<?php endif; ?>
<?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