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 5b8e6426 authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Merge pull request #448 from Adyen/develop

Release 4.1.1
parents e2b38820 9d94bcaf
...@@ -173,36 +173,35 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -173,36 +173,35 @@ class Result extends \Magento\Framework\App\Action\Action
$response = $this->validatePayloadAndReturnResponse($response); $response = $this->validatePayloadAndReturnResponse($response);
} }
$incrementId = $response['merchantReference']; $incrementId = null;
if ($incrementId) {
$order = $this->_getOrder($incrementId);
if ($order->getId()) {
$this->_eventManager->dispatch('adyen_payment_process_resulturl_before', [
'order' => $order,
'adyen_response' => $response
]);
if (isset($response['handled'])) {
return $response['handled_response'];
}
// update the order if (!empty($response['merchantReference'])) {
$result = $this->_validateUpdateOrder($order, $response); $incrementId = $response['merchantReference'];
}
$this->_eventManager->dispatch('adyen_payment_process_resulturl_after', [ $order = $this->_getOrder($incrementId);
'order' => $order, if ($order->getId()) {
'adyen_response' => $response $this->_eventManager->dispatch('adyen_payment_process_resulturl_before', [
]); 'order' => $order,
} else { 'adyen_response' => $response
throw new \Magento\Framework\Exception\LocalizedException( ]);
__('Order does not exists with increment_id: %1', $incrementId) if (isset($response['handled'])) {
); return $response['handled_response'];
} }
// update the order
$result = $this->_validateUpdateOrder($order, $response);
$this->_eventManager->dispatch('adyen_payment_process_resulturl_after', [
'order' => $order,
'adyen_response' => $response
]);
} else { } else {
throw new \Magento\Framework\Exception\LocalizedException( throw new \Magento\Framework\Exception\LocalizedException(
__('Empty merchantReference') __('Order does not exists with increment_id: %1', $incrementId)
); );
} }
return $result; return $result;
} }
...@@ -245,6 +244,9 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -245,6 +244,9 @@ class Result extends \Magento\Framework\App\Action\Action
break; break;
case Notification::RECEIVED: case Notification::RECEIVED:
$result = true; $result = true;
if (strpos($paymentMethod, "alipay_hk_web") !== false) {
$result = false;
}
$this->_adyenLogger->addAdyenResult('Do nothing wait for the notification'); $this->_adyenLogger->addAdyenResult('Do nothing wait for the notification');
break; break;
case Notification::PENDING: case Notification::PENDING:
...@@ -348,11 +350,16 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -348,11 +350,16 @@ class Result extends \Magento\Framework\App\Action\Action
* @param $incrementId * @param $incrementId
* @return \Magento\Sales\Model\Order * @return \Magento\Sales\Model\Order
*/ */
protected function _getOrder($incrementId) protected function _getOrder($incrementId = null)
{ {
if (!$this->_order) { if (!$this->_order) {
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId); if (!is_null($incrementId)) {
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
} else {
$this->_order = $this->_session->getLastRealOrder();
}
} }
return $this->_order; return $this->_order;
} }
...@@ -368,11 +375,13 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -368,11 +375,13 @@ class Result extends \Magento\Framework\App\Action\Action
$client = $this->_adyenHelper->initializeAdyenClient($this->storeManager->getStore()->getId()); $client = $this->_adyenHelper->initializeAdyenClient($this->storeManager->getStore()->getId());
$service = $this->_adyenHelper->createAdyenCheckoutService($client); $service = $this->_adyenHelper->createAdyenCheckoutService($client);
$request = array( $request = [];
"details" => array(
"payload" => $response["payload"] if (!empty($this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation("paymentData"))) {
) $request['paymentData'] = $this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation("paymentData");
); }
$request["details"] = $response;
try { try {
$response = $service->paymentsDetails($request); $response = $service->paymentsDetails($request);
...@@ -382,4 +391,4 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -382,4 +391,4 @@ class Result extends \Magento\Framework\App\Action\Action
return $response; return $response;
} }
} }
\ No newline at end of file
...@@ -228,6 +228,7 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -228,6 +228,7 @@ class CheckoutDataBuilder implements BuilderInterface
$formattedPriceExcludingTax = $this->adyenHelper->formatAmount($priceExcludingTax, $currency); $formattedPriceExcludingTax = $this->adyenHelper->formatAmount($priceExcludingTax, $currency);
$formattedTaxAmount = $this->adyenHelper->formatAmount($item->getTaxAmount(), $currency); $formattedTaxAmount = $this->adyenHelper->formatAmount($item->getTaxAmount(), $currency);
$formattedTaxPercentage = $item->getTaxPercent() * 100;
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'id' => $item->getId(), 'id' => $item->getId(),
...@@ -237,7 +238,7 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -237,7 +238,7 @@ class CheckoutDataBuilder implements BuilderInterface
'description' => $item->getName(), 'description' => $item->getName(),
'quantity' => $item->getQty(), 'quantity' => $item->getQty(),
'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'), 'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'),
'taxPercentage' => $item->getTaxPercent() 'taxPercentage' => $formattedTaxPercentage
]; ];
} }
...@@ -272,13 +273,19 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -272,13 +273,19 @@ class CheckoutDataBuilder implements BuilderInterface
$taxClassId = $this->taxConfig->getShippingTaxClass($this->storeManager->getStore()->getId()); $taxClassId = $this->taxConfig->getShippingTaxClass($this->storeManager->getStore()->getId());
$formattedTaxPercentage = 0;
if ($priceExcludingTax !== 0) {
$formattedTaxPercentage = $this->quote->getShippingAddress()->getShippingTaxAmount() / $priceExcludingTax * 100 * 100;
}
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'itemId' => 'shippingCost', 'itemId' => 'shippingCost',
'amountExcludingTax' => $formattedPriceExcludingTax, 'amountExcludingTax' => $formattedPriceExcludingTax,
'taxAmount' => $formattedTaxAmount, 'taxAmount' => $formattedTaxAmount,
'description' => $order->getShippingDescription(), 'description' => $order->getShippingDescription(),
'quantity' => 1, 'quantity' => 1,
'taxPercentage' => $this->quote->getShippingAddress()->getShippingTaxAmount() 'taxPercentage' => $formattedTaxPercentage
]; ];
} }
......
...@@ -111,6 +111,11 @@ class CustomerDataBuilder implements BuilderInterface ...@@ -111,6 +111,11 @@ class CustomerDataBuilder implements BuilderInterface
if ($countryId = $billingAddress->getCountryId()) { if ($countryId = $billingAddress->getCountryId()) {
$result['countryCode'] = $countryId; $result['countryCode'] = $countryId;
} }
if ($shopperLocale = $this->adyenHelper->getCurrentLocaleCode($order->getStoreId())) {
$result['shopperLocale'] = $shopperLocale;
}
} }
return $result; return $result;
......
...@@ -118,6 +118,16 @@ class Data extends AbstractHelper ...@@ -118,6 +118,16 @@ class Data extends AbstractHelper
*/ */
private $agreementResourceModel; private $agreementResourceModel;
/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
private $localeResolver;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $config;
/** /**
* Data constructor. * Data constructor.
* @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Helper\Context $context
...@@ -155,7 +165,9 @@ class Data extends AbstractHelper ...@@ -155,7 +165,9 @@ class Data extends AbstractHelper
\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\CacheInterface $cache, \Magento\Framework\App\CacheInterface $cache,
\Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory, \Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\Config\ScopeConfigInterface $config
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
...@@ -174,6 +186,8 @@ class Data extends AbstractHelper ...@@ -174,6 +186,8 @@ class Data extends AbstractHelper
$this->cache = $cache; $this->cache = $cache;
$this->billingAgreementFactory = $billingAgreementFactory; $this->billingAgreementFactory = $billingAgreementFactory;
$this->agreementResourceModel = $agreementResourceModel; $this->agreementResourceModel = $agreementResourceModel;
$this->localeResolver = $localeResolver;
$this->config = $config;
} }
/** /**
...@@ -1701,4 +1715,30 @@ class Data extends AbstractHelper ...@@ -1701,4 +1715,30 @@ class Data extends AbstractHelper
$timeStamp = new \DateTime($date); $timeStamp = new \DateTime($date);
return $timeStamp->format($format); return $timeStamp->format($format);
} }
/**
* @param int $storeId
* @return mixed|string
*/
public function getCurrentLocaleCode($storeId)
{
$localeCode = $this->getAdyenAbstractConfigData('shopper_locale', $storeId);
if ($localeCode != "") {
return $localeCode;
}
$locale = $this->localeResolver->getLocale();
if ($locale) {
return $locale;
}
// should have the value if not fall back to default
$localeCode = $this->config->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
return $localeCode;
}
} }
...@@ -198,7 +198,7 @@ class PaymentMethods extends AbstractHelper ...@@ -198,7 +198,7 @@ class PaymentMethods extends AbstractHelper
), ),
], ],
"shopperReference" => $this->getCurrentShopperReference(), "shopperReference" => $this->getCurrentShopperReference(),
"shopperLocale" => $this->getCurrentLocaleCode($store) "shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store->getId())
]; ];
$billingAddress = $this->getQuote()->getBillingAddress(); $billingAddress = $this->getQuote()->getBillingAddress();
...@@ -325,32 +325,6 @@ class PaymentMethods extends AbstractHelper ...@@ -325,32 +325,6 @@ class PaymentMethods extends AbstractHelper
return ""; return "";
} }
/**
* @param $store
* @return mixed|string
*/
protected function getCurrentLocaleCode($store)
{
$localeCode = $this->adyenHelper->getAdyenAbstractConfigData('shopper_locale', $store->getId());
if ($localeCode != "") {
return $localeCode;
}
$locale = $this->localeResolver->getLocale();
if ($locale) {
return $locale;
}
// should have the value if not fall back to default
$localeCode = $this->config->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
return $localeCode;
}
/** /**
* @var array * @var array
*/ */
......
...@@ -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": "4.1.0", "version": "4.1.1",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="4.1.0"> <module name="Adyen_Payment" setup_version="4.1.1">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -412,6 +412,11 @@ define( ...@@ -412,6 +412,11 @@ define(
*/ */
result.renderKlarnaComponent = function () { result.renderKlarnaComponent = function () {
/* The new Klarna integration doesn't return details and the component does not handle it */
if (!value.details) {
return;
}
var klarnaNode = document.getElementById('klarnaContainer'); var klarnaNode = document.getElementById('klarnaContainer');
var klarna = self.checkoutComponent.create('klarna', { var klarna = self.checkoutComponent.create('klarna', {
......
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