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 ...@@ -87,6 +87,7 @@ class Result extends \Magento\Framework\App\Action\Action
$this->_orderHistoryFactory = $orderHistoryFactory; $this->_orderHistoryFactory = $orderHistoryFactory;
$this->_session = $session; $this->_session = $session;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
$this->storeManager = $storeManager;
parent::__construct($context); parent::__construct($context);
} }
......
...@@ -146,10 +146,13 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -146,10 +146,13 @@ class CheckoutDataBuilder implements BuilderInterface
} }
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE) $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
) || $this->adyenHelper->isPaymentMethodAfterpayTouchMethod( ) || $this->adyenHelper->isPaymentMethodAfterpayTouchMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE) $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)) { ) || $this->adyenHelper->isPaymentMethodOneyMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)
) {
$openInvoiceFields = $this->getOpenInvoiceData($order); $openInvoiceFields = $this->getOpenInvoiceData($order);
$request = array_merge($request, $openInvoiceFields); $request = array_merge($request, $openInvoiceFields);
} }
...@@ -228,10 +231,11 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -228,10 +231,11 @@ class CheckoutDataBuilder implements BuilderInterface
$formattedTaxPercentage = $item->getTaxPercent() * 100; $formattedTaxPercentage = $item->getTaxPercent() * 100;
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'id' => $item->getId(),
'itemId' => $item->getId(),
'amountExcludingTax' => $formattedPriceExcludingTax, 'amountExcludingTax' => $formattedPriceExcludingTax,
'taxAmount' => $formattedTaxAmount, 'taxAmount' => $formattedTaxAmount,
'description' => $item->getName(), 'description' => $item->getName(),
'id' => $item->getId(),
'quantity' => $item->getQty(), 'quantity' => $item->getQty(),
'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'), 'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'),
'taxPercentage' => $formattedTaxPercentage 'taxPercentage' => $formattedTaxPercentage
...@@ -248,6 +252,7 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -248,6 +252,7 @@ class CheckoutDataBuilder implements BuilderInterface
$numberOfItems = 1; $numberOfItems = 1;
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'itemId' => 'totalDiscount',
'amountExcludingTax' => $itemAmount, 'amountExcludingTax' => $itemAmount,
'taxAmount' => $itemVatAmount, 'taxAmount' => $itemVatAmount,
'description' => $description, 'description' => $description,
...@@ -275,6 +280,7 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -275,6 +280,7 @@ class CheckoutDataBuilder implements BuilderInterface
} }
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'itemId' => 'shippingCost',
'amountExcludingTax' => $formattedPriceExcludingTax, 'amountExcludingTax' => $formattedPriceExcludingTax,
'taxAmount' => $formattedTaxAmount, 'taxAmount' => $formattedTaxAmount,
'description' => $order->getShippingDescription(), 'description' => $order->getShippingDescription(),
......
...@@ -57,10 +57,11 @@ class CustomerDataBuilder implements BuilderInterface ...@@ -57,10 +57,11 @@ class CustomerDataBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder(); $order = $paymentDataObject->getOrder();
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
$billingAddress = $order->getBillingAddress(); $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 ...@@ -50,7 +50,6 @@ class CheckoutPaymentsDetailsHandler implements HandlerInterface
{ {
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var $payment */
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
// set transaction not to processing by default wait for notification // set transaction not to processing by default wait for notification
......
...@@ -1122,32 +1122,6 @@ class Data extends AbstractHelper ...@@ -1122,32 +1122,6 @@ class Data extends AbstractHelper
return $this->scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId); 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 * Format Magento locale codes with undersocre to ISO locale codes with dash
* @param $localeCode * @param $localeCode
...@@ -1792,24 +1766,20 @@ class Data extends AbstractHelper ...@@ -1792,24 +1766,20 @@ class Data extends AbstractHelper
*/ */
public function buildThreeDS2ProcessResponseJson($type = null, $token = null) public function buildThreeDS2ProcessResponseJson($type = null, $token = null)
{ {
$response = json_encode( $response = ['threeDS2' => false];
[
'threeDS2' => false
]
);
if ($type && $token) { if ($type && $token) {
$response = json_encode( $response = [
[ "threeDS2" => true,
"threeDS2" => true, "type" => $type,
"type" => $type, "token" => $token
"token" => $token ];
]
);
} }
return $response; return json_encode($response);
}
/**
* @param int $storeId * @param int $storeId
* @return mixed|string * @return mixed|string
*/ */
......
...@@ -38,6 +38,11 @@ class Requests extends AbstractHelper ...@@ -38,6 +38,11 @@ class Requests extends AbstractHelper
*/ */
private $adyenHelper; private $adyenHelper;
/**
* Requests constructor.
*
* @param Data $adyenHelper
*/
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper \Adyen\Payment\Helper\Data $adyenHelper
) { ) {
...@@ -67,7 +72,7 @@ class Requests extends AbstractHelper ...@@ -67,7 +72,7 @@ class Requests extends AbstractHelper
* @param $billingAddress * @param $billingAddress
* @return mixed * @return mixed
*/ */
public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $payment = null) public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $storeId, $payment = null)
{ {
if ($customerId > 0) { if ($customerId > 0) {
$request['shopperReference'] = $customerId; $request['shopperReference'] = $customerId;
...@@ -119,6 +124,8 @@ class Requests extends AbstractHelper ...@@ -119,6 +124,8 @@ class Requests extends AbstractHelper
if ($countryId = $billingAddress->getCountryId()) { if ($countryId = $billingAddress->getCountryId()) {
$request['countryCode'] = $countryId; $request['countryCode'] = $countryId;
} }
$request['shopperLocale'] = $this->adyenHelper->getCurrentLocaleCode($storeId);
} }
return $request; return $request;
...@@ -290,7 +297,7 @@ class Requests extends AbstractHelper ...@@ -290,7 +297,7 @@ class Requests extends AbstractHelper
$request['browserInfo']['screenHeight'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::SCREEN_HEIGHT]; $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']['colorDepth'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::SCREEN_COLOR_DEPTH];
$request['browserInfo']['timeZoneOffset'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::TIMEZONE_OFFSET]; $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]) { if ($javaEnabled = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::JAVA_ENABLED]) {
$request['browserInfo']['javaEnabled'] = $javaEnabled; $request['browserInfo']['javaEnabled'] = $javaEnabled;
......
...@@ -68,10 +68,16 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface ...@@ -68,10 +68,16 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
private $threeDS2ResponseValidator; private $threeDS2ResponseValidator;
/** /**
* AdyenThreeDS2Process constructor. * AdyenPaymentProcess constructor.
* *
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Adyen\Payment\Helper\Data $adyenHelper * @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( public function __construct(
\Magento\Framework\Model\Context $context, \Magento\Framework\Model\Context $context,
...@@ -105,6 +111,11 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface ...@@ -105,6 +111,11 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Decode payload from frontend // Decode payload from frontend
$payload = json_decode($payload, true); $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 // Get payment and cart information from session
$quote = $this->checkoutSession->getQuote(); $quote = $this->checkoutSession->getQuote();
$payment = $quote->getPayment(); $payment = $quote->getPayment();
...@@ -120,7 +131,7 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface ...@@ -120,7 +131,7 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Customer data builder // Customer data builder
$customerId = $quote->getCustomerId(); $customerId = $quote->getCustomerId();
$billingAddress = $quote->getBillingAddress(); $billingAddress = $quote->getBillingAddress();
$request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress); $request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress, $storeId);
// Customer Ip data builder // Customer Ip data builder
$shopperIp = $quote->getRemoteIp(); $shopperIp = $quote->getRemoteIp();
......
...@@ -134,7 +134,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -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 // add to config
$config['payment'] ['adyenHpp']['gender'] = $gender; $config['payment'] ['adyenHpp']['gender'] = $gender;
......
...@@ -51,6 +51,11 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver ...@@ -51,6 +51,11 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver
*/ */
private $adyenHelper; private $adyenHelper;
/**
* AdyenBoletoDataAssignObserver constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper \Adyen\Payment\Helper\Data $adyenHelper
) { ) {
......
...@@ -45,6 +45,7 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver ...@@ -45,6 +45,7 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
const SCREEN_WIDTH = 'screen_width'; const SCREEN_WIDTH = 'screen_width';
const SCREEN_HEIGHT = 'screen_height'; const SCREEN_HEIGHT = 'screen_height';
const TIMEZONE_OFFSET = 'timezone_offset'; const TIMEZONE_OFFSET = 'timezone_offset';
const LANGUAGE = 'language';
/** /**
* @var array * @var array
...@@ -63,7 +64,8 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver ...@@ -63,7 +64,8 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
self::SCREEN_COLOR_DEPTH, self::SCREEN_COLOR_DEPTH,
self::SCREEN_WIDTH, self::SCREEN_WIDTH,
self::SCREEN_HEIGHT, self::SCREEN_HEIGHT,
self::TIMEZONE_OFFSET self::TIMEZONE_OFFSET,
self::LANGUAGE
]; ];
/** /**
......
...@@ -40,6 +40,7 @@ class AdyenOneclickDataAssignObserver extends AbstractDataAssignObserver ...@@ -40,6 +40,7 @@ class AdyenOneclickDataAssignObserver extends AbstractDataAssignObserver
const SCREEN_WIDTH = 'screen_width'; const SCREEN_WIDTH = 'screen_width';
const SCREEN_HEIGHT = 'screen_height'; const SCREEN_HEIGHT = 'screen_height';
const TIMEZONE_OFFSET = 'timezone_offset'; const TIMEZONE_OFFSET = 'timezone_offset';
const LANGUAGE = 'language';
/** /**
* @var array * @var array
...@@ -53,7 +54,8 @@ class AdyenOneclickDataAssignObserver extends AbstractDataAssignObserver ...@@ -53,7 +54,8 @@ class AdyenOneclickDataAssignObserver extends AbstractDataAssignObserver
self::SCREEN_COLOR_DEPTH, self::SCREEN_COLOR_DEPTH,
self::SCREEN_WIDTH, self::SCREEN_WIDTH,
self::SCREEN_HEIGHT, self::SCREEN_HEIGHT,
self::TIMEZONE_OFFSET self::TIMEZONE_OFFSET,
self::LANGUAGE
]; ];
/** /**
......
...@@ -298,7 +298,8 @@ define( ...@@ -298,7 +298,8 @@ define(
'screen_color_depth': browserInfo.colorDepth, 'screen_color_depth': browserInfo.colorDepth,
'screen_width': browserInfo.screenWidth, 'screen_width': browserInfo.screenWidth,
'screen_height': browserInfo.screenHeight, 'screen_height': browserInfo.screenHeight,
'timezone_offset': browserInfo.timeZoneOffset 'timezone_offset': browserInfo.timeZoneOffset,
'language': browserInfo.language
} }
}; };
......
...@@ -304,7 +304,8 @@ define( ...@@ -304,7 +304,8 @@ define(
'screen_color_depth': browserInfo.colorDepth, 'screen_color_depth': browserInfo.colorDepth,
'screen_width': browserInfo.screenWidth, 'screen_width': browserInfo.screenWidth,
'screen_height': browserInfo.screenHeight, 'screen_height': browserInfo.screenHeight,
'timezone_offset': browserInfo.timeZoneOffset 'timezone_offset': browserInfo.timeZoneOffset,
'language': browserInfo.language
} }
}; };
return data; 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