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 a7731e2e authored by attilak's avatar attilak

fix issues after rebase

parent 3c026efb
......@@ -87,6 +87,7 @@ class Result extends \Magento\Framework\App\Action\Action
$this->_orderHistoryFactory = $orderHistoryFactory;
$this->_session = $session;
$this->_adyenLogger = $adyenLogger;
$this->storeManager = $storeManager;
parent::__construct($context);
}
......
......@@ -149,7 +149,10 @@ class CheckoutDataBuilder implements BuilderInterface
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
) || $this->adyenHelper->isPaymentMethodAfterpayTouchMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)) {
) || $this->adyenHelper->isPaymentMethodOneyMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)
) {
$openInvoiceFields = $this->getOpenInvoiceData($order);
$request = array_merge($request, $openInvoiceFields);
}
......@@ -228,10 +231,11 @@ class CheckoutDataBuilder implements BuilderInterface
$formattedTaxPercentage = $item->getTaxPercent() * 100;
$formFields['lineItems'][] = [
'id' => $item->getId(),
'itemId' => $item->getId(),
'amountExcludingTax' => $formattedPriceExcludingTax,
'taxAmount' => $formattedTaxAmount,
'description' => $item->getName(),
'id' => $item->getId(),
'quantity' => $item->getQty(),
'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'),
'taxPercentage' => $formattedTaxPercentage
......@@ -248,6 +252,7 @@ class CheckoutDataBuilder implements BuilderInterface
$numberOfItems = 1;
$formFields['lineItems'][] = [
'itemId' => 'totalDiscount',
'amountExcludingTax' => $itemAmount,
'taxAmount' => $itemVatAmount,
'description' => $description,
......@@ -275,6 +280,7 @@ class CheckoutDataBuilder implements BuilderInterface
}
$formFields['lineItems'][] = [
'itemId' => 'shippingCost',
'amountExcludingTax' => $formattedPriceExcludingTax,
'taxAmount' => $formattedTaxAmount,
'description' => $order->getShippingDescription(),
......
......@@ -60,7 +60,8 @@ class CustomerDataBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment();
$customerId = $order->getCustomerId();
$billingAddress = $order->getBillingAddress();
$storeId = $order->getStoreId();
return $this->adyenRequestsHelper->buildCustomerData([], $customerId, $billingAddress, $payment);
return $this->adyenRequestsHelper->buildCustomerData([], $customerId, $billingAddress, $storeId, $payment);
}
}
......@@ -50,7 +50,6 @@ class CheckoutPaymentsDetailsHandler implements HandlerInterface
{
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var $payment */
$payment = $paymentDataObject->getPayment();
// set transaction not to processing by default wait for notification
......
......@@ -1122,32 +1122,6 @@ class Data extends AbstractHelper
return $this->scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $store
* @return mixed|string
*/
public function getCurrentLocaleCode($store)
{
$localeCode = $this->getAdyenAbstractConfigData('shopper_locale', $store->getId());
if ($localeCode != "") {
return $this->formatLocaleCode($localeCode);
}
$localeCode = $this->localeResolver->getLocale();
if ($localeCode) {
return $this->formatLocaleCode($localeCode);
}
// should have the value if not fall back to default
$localeCode = $this->scopeConfig->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
return $this->formatLocaleCode($localeCode);
}
/**
* Format Magento locale codes with undersocre to ISO locale codes with dash
* @param $localeCode
......@@ -1792,24 +1766,20 @@ class Data extends AbstractHelper
*/
public function buildThreeDS2ProcessResponseJson($type = null, $token = null)
{
$response = json_encode(
[
'threeDS2' => false
]
);
$response = ['threeDS2' => false];
if ($type && $token) {
$response = json_encode(
[
$response = [
"threeDS2" => true,
"type" => $type,
"token" => $token
]
);
];
}
return $response;
return json_encode($response);
}
/**
* @param int $storeId
* @return mixed|string
*/
......
......@@ -38,6 +38,11 @@ class Requests extends AbstractHelper
*/
private $adyenHelper;
/**
* Requests constructor.
*
* @param Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
......@@ -67,7 +72,7 @@ class Requests extends AbstractHelper
* @param $billingAddress
* @return mixed
*/
public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $payment = null)
public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $storeId, $payment = null)
{
if ($customerId > 0) {
$request['shopperReference'] = $customerId;
......@@ -119,6 +124,8 @@ class Requests extends AbstractHelper
if ($countryId = $billingAddress->getCountryId()) {
$request['countryCode'] = $countryId;
}
$request['shopperLocale'] = $this->adyenHelper->getCurrentLocaleCode($storeId);
}
return $request;
......@@ -290,7 +297,7 @@ class Requests extends AbstractHelper
$request['browserInfo']['screenHeight'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::SCREEN_HEIGHT];
$request['browserInfo']['colorDepth'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::SCREEN_COLOR_DEPTH];
$request['browserInfo']['timeZoneOffset'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::TIMEZONE_OFFSET];
$request['browserInfo']['language'] = $this->adyenHelper->getCurrentLocaleCode($store);
$request['browserInfo']['language'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::LANGUAGE];
if ($javaEnabled = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::JAVA_ENABLED]) {
$request['browserInfo']['javaEnabled'] = $javaEnabled;
......
......@@ -68,10 +68,16 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
private $threeDS2ResponseValidator;
/**
* AdyenThreeDS2Process constructor.
* AdyenPaymentProcess constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Helper\Requests $adyenRequestHelper
* @param \Adyen\Payment\Gateway\Http\TransferFactory $transferFactory
* @param \Adyen\Payment\Gateway\Http\Client\TransactionPayment $transactionPayment
* @param \Adyen\Payment\Gateway\Validator\CheckoutResponseValidator $checkoutResponseValidator
* @param \Adyen\Payment\Gateway\Validator\ThreeDS2ResponseValidator $threeDS2ResponseValidator
*/
public function __construct(
\Magento\Framework\Model\Context $context,
......@@ -105,6 +111,11 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Decode payload from frontend
$payload = json_decode($payload, true);
// Validate JSON that has just been parsed if it was in a valid format
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Magento\Framework\Exception\LocalizedException(__('Error with payment method please select different payment method.'));
}
// Get payment and cart information from session
$quote = $this->checkoutSession->getQuote();
$payment = $quote->getPayment();
......@@ -120,7 +131,7 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Customer data builder
$customerId = $quote->getCustomerId();
$billingAddress = $quote->getBillingAddress();
$request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress);
$request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress, $storeId);
// Customer Ip data builder
$shopperIp = $quote->getRemoteIp();
......
......@@ -134,7 +134,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
}
}
$config['payment']['adyenHpp']['locale'] = $this->adyenHelper->getCurrentLocaleCode($this->storeManager->getStore());
$config['payment']['adyenHpp']['locale'] = $this->adyenHelper->getCurrentLocaleCode($this->storeManager->getStore()->getId());
// add to config
$config['payment'] ['adyenHpp']['gender'] = $gender;
......
......@@ -51,6 +51,11 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver
*/
private $adyenHelper;
/**
* AdyenBoletoDataAssignObserver constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
......
......@@ -45,6 +45,7 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
const SCREEN_WIDTH = 'screen_width';
const SCREEN_HEIGHT = 'screen_height';
const TIMEZONE_OFFSET = 'timezone_offset';
const LANGUAGE = 'language';
/**
* @var array
......@@ -63,7 +64,8 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
self::SCREEN_COLOR_DEPTH,
self::SCREEN_WIDTH,
self::SCREEN_HEIGHT,
self::TIMEZONE_OFFSET
self::TIMEZONE_OFFSET,
self::LANGUAGE
];
/**
......
......@@ -40,6 +40,7 @@ class AdyenOneclickDataAssignObserver extends AbstractDataAssignObserver
const SCREEN_WIDTH = 'screen_width';
const SCREEN_HEIGHT = 'screen_height';
const TIMEZONE_OFFSET = 'timezone_offset';
const LANGUAGE = 'language';
/**
* @var array
......@@ -53,7 +54,8 @@ class AdyenOneclickDataAssignObserver extends AbstractDataAssignObserver
self::SCREEN_COLOR_DEPTH,
self::SCREEN_WIDTH,
self::SCREEN_HEIGHT,
self::TIMEZONE_OFFSET
self::TIMEZONE_OFFSET,
self::LANGUAGE
];
/**
......
......@@ -298,7 +298,8 @@ define(
'screen_color_depth': browserInfo.colorDepth,
'screen_width': browserInfo.screenWidth,
'screen_height': browserInfo.screenHeight,
'timezone_offset': browserInfo.timeZoneOffset
'timezone_offset': browserInfo.timeZoneOffset,
'language': browserInfo.language
}
};
......
......@@ -304,7 +304,8 @@ define(
'screen_color_depth': browserInfo.colorDepth,
'screen_width': browserInfo.screenWidth,
'screen_height': browserInfo.screenHeight,
'timezone_offset': browserInfo.timeZoneOffset
'timezone_offset': browserInfo.timeZoneOffset,
'language': browserInfo.language
}
};
return data;
......
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