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,9 +173,12 @@ class Result extends \Magento\Framework\App\Action\Action
$response = $this->validatePayloadAndReturnResponse($response);
}
$incrementId = null;
if (!empty($response['merchantReference'])) {
$incrementId = $response['merchantReference'];
}
if ($incrementId) {
$order = $this->_getOrder($incrementId);
if ($order->getId()) {
$this->_eventManager->dispatch('adyen_payment_process_resulturl_before', [
......@@ -198,11 +201,7 @@ class Result extends \Magento\Framework\App\Action\Action
__('Order does not exists with increment_id: %1', $incrementId)
);
}
} else {
throw new \Magento\Framework\Exception\LocalizedException(
__('Empty merchantReference')
);
}
return $result;
}
......@@ -245,6 +244,9 @@ class Result extends \Magento\Framework\App\Action\Action
break;
case Notification::RECEIVED:
$result = true;
if (strpos($paymentMethod, "alipay_hk_web") !== false) {
$result = false;
}
$this->_adyenLogger->addAdyenResult('Do nothing wait for the notification');
break;
case Notification::PENDING:
......@@ -348,11 +350,16 @@ class Result extends \Magento\Framework\App\Action\Action
* @param $incrementId
* @return \Magento\Sales\Model\Order
*/
protected function _getOrder($incrementId)
protected function _getOrder($incrementId = null)
{
if (!$this->_order) {
if (!is_null($incrementId)) {
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
} else {
$this->_order = $this->_session->getLastRealOrder();
}
}
return $this->_order;
}
......@@ -368,11 +375,13 @@ class Result extends \Magento\Framework\App\Action\Action
$client = $this->_adyenHelper->initializeAdyenClient($this->storeManager->getStore()->getId());
$service = $this->_adyenHelper->createAdyenCheckoutService($client);
$request = array(
"details" => array(
"payload" => $response["payload"]
)
);
$request = [];
if (!empty($this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation("paymentData"))) {
$request['paymentData'] = $this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation("paymentData");
}
$request["details"] = $response;
try {
$response = $service->paymentsDetails($request);
......
......@@ -228,6 +228,7 @@ class CheckoutDataBuilder implements BuilderInterface
$formattedPriceExcludingTax = $this->adyenHelper->formatAmount($priceExcludingTax, $currency);
$formattedTaxAmount = $this->adyenHelper->formatAmount($item->getTaxAmount(), $currency);
$formattedTaxPercentage = $item->getTaxPercent() * 100;
$formFields['lineItems'][] = [
'id' => $item->getId(),
......@@ -237,7 +238,7 @@ class CheckoutDataBuilder implements BuilderInterface
'description' => $item->getName(),
'quantity' => $item->getQty(),
'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'),
'taxPercentage' => $item->getTaxPercent()
'taxPercentage' => $formattedTaxPercentage
];
}
......@@ -272,13 +273,19 @@ class CheckoutDataBuilder implements BuilderInterface
$taxClassId = $this->taxConfig->getShippingTaxClass($this->storeManager->getStore()->getId());
$formattedTaxPercentage = 0;
if ($priceExcludingTax !== 0) {
$formattedTaxPercentage = $this->quote->getShippingAddress()->getShippingTaxAmount() / $priceExcludingTax * 100 * 100;
}
$formFields['lineItems'][] = [
'itemId' => 'shippingCost',
'amountExcludingTax' => $formattedPriceExcludingTax,
'taxAmount' => $formattedTaxAmount,
'description' => $order->getShippingDescription(),
'quantity' => 1,
'taxPercentage' => $this->quote->getShippingAddress()->getShippingTaxAmount()
'taxPercentage' => $formattedTaxPercentage
];
}
......
......@@ -111,6 +111,11 @@ class CustomerDataBuilder implements BuilderInterface
if ($countryId = $billingAddress->getCountryId()) {
$result['countryCode'] = $countryId;
}
if ($shopperLocale = $this->adyenHelper->getCurrentLocaleCode($order->getStoreId())) {
$result['shopperLocale'] = $shopperLocale;
}
}
return $result;
......
......@@ -118,6 +118,16 @@ class Data extends AbstractHelper
*/
private $agreementResourceModel;
/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
private $localeResolver;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $config;
/**
* Data constructor.
* @param \Magento\Framework\App\Helper\Context $context
......@@ -155,7 +165,9 @@ class Data extends AbstractHelper
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\CacheInterface $cache,
\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);
$this->_encryptor = $encryptor;
......@@ -174,6 +186,8 @@ class Data extends AbstractHelper
$this->cache = $cache;
$this->billingAgreementFactory = $billingAgreementFactory;
$this->agreementResourceModel = $agreementResourceModel;
$this->localeResolver = $localeResolver;
$this->config = $config;
}
/**
......@@ -1701,4 +1715,30 @@ class Data extends AbstractHelper
$timeStamp = new \DateTime($date);
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
),
],
"shopperReference" => $this->getCurrentShopperReference(),
"shopperLocale" => $this->getCurrentLocaleCode($store)
"shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store->getId())
];
$billingAddress = $this->getQuote()->getBillingAddress();
......@@ -325,32 +325,6 @@ class PaymentMethods extends AbstractHelper
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
*/
......
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "4.1.0",
"version": "4.1.1",
"license": [
"OSL-3.0",
"AFL-3.0"
......
......@@ -24,7 +24,7 @@
-->
<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>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
......
......@@ -412,6 +412,11 @@ define(
*/
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 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