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

Merge branch 'develop' into feature/3ds2

parents 4da491cb 9d94bcaf
......@@ -172,36 +172,35 @@ class Result extends \Magento\Framework\App\Action\Action
$response = $this->validatePayloadAndReturnResponse($response);
}
$incrementId = $response['merchantReference'];
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'];
}
$incrementId = null;
// update the order
$result = $this->_validateUpdateOrder($order, $response);
if (!empty($response['merchantReference'])) {
$incrementId = $response['merchantReference'];
}
$this->_eventManager->dispatch('adyen_payment_process_resulturl_after', [
'order' => $order,
'adyen_response' => $response
]);
} else {
throw new \Magento\Framework\Exception\LocalizedException(
__('Order does not exists with increment_id: %1', $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
$result = $this->_validateUpdateOrder($order, $response);
$this->_eventManager->dispatch('adyen_payment_process_resulturl_after', [
'order' => $order,
'adyen_response' => $response
]);
} else {
throw new \Magento\Framework\Exception\LocalizedException(
__('Empty merchantReference')
__('Order does not exists with increment_id: %1', $incrementId)
);
}
return $result;
}
......@@ -244,6 +243,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:
......@@ -347,11 +349,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) {
$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;
}
......@@ -367,11 +374,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);
......@@ -381,4 +390,4 @@ class Result extends \Magento\Framework\App\Action\Action
return $response;
}
}
\ No newline at end of file
}
......@@ -225,6 +225,7 @@ class CheckoutDataBuilder implements BuilderInterface
$formattedPriceExcludingTax = $this->adyenHelper->formatAmount($priceExcludingTax, $currency);
$formattedTaxAmount = $this->adyenHelper->formatAmount($item->getTaxAmount(), $currency);
$formattedTaxPercentage = $item->getTaxPercent() * 100;
$formFields['lineItems'][] = [
'amountExcludingTax' => $formattedPriceExcludingTax,
......@@ -233,7 +234,7 @@ class CheckoutDataBuilder implements BuilderInterface
'id' => $item->getId(),
'quantity' => $item->getQty(),
'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'),
'taxPercentage' => $item->getTaxPercent()
'taxPercentage' => $formattedTaxPercentage
];
}
......@@ -267,12 +268,18 @@ 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'][] = [
'amountExcludingTax' => $formattedPriceExcludingTax,
'taxAmount' => $formattedTaxAmount,
'description' => $order->getShippingDescription(),
'quantity' => 1,
'taxPercentage' => $this->quote->getShippingAddress()->getShippingTaxAmount()
'taxPercentage' => $formattedTaxPercentage
];
}
......
......@@ -57,9 +57,9 @@ class CustomerDataBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$payment = $paymentDataObject->getPayment();
$payment = $paymentDataObject->getPayment();
$customerId = $order->getCustomerId();
$billingAddress = $order->getBillingAddress();
$billingAddress = $order->getBillingAddress();
return $this->adyenRequestsHelper->buildCustomerData([], $customerId, $billingAddress, $payment);
}
......
......@@ -123,6 +123,11 @@ class Data extends AbstractHelper
*/
private $localeResolver;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $config;
/**
* Data constructor.
* @param \Magento\Framework\App\Helper\Context $context
......@@ -161,7 +166,8 @@ class Data extends AbstractHelper
\Magento\Framework\App\CacheInterface $cache,
\Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Framework\Locale\ResolverInterface $localeResolver
\Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\Config\ScopeConfigInterface $config
) {
parent::__construct($context);
$this->_encryptor = $encryptor;
......@@ -181,6 +187,7 @@ class Data extends AbstractHelper
$this->billingAgreementFactory = $billingAgreementFactory;
$this->agreementResourceModel = $agreementResourceModel;
$this->localeResolver = $localeResolver;
$this->config = $config;
}
/**
......@@ -1802,5 +1809,29 @@ class Data extends AbstractHelper
}
return $response;
* @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->adyenHelper->getCurrentLocaleCode($store)
"shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store->getId())
];
$billingAddress = $this->getQuote()->getBillingAddress();
......
......@@ -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"/>
......
......@@ -415,6 +415,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