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

Send house number separately only at klarna enabled countries

parent 815628af
...@@ -335,6 +335,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -335,6 +335,9 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['shopper.lastName'] = trim($billingAddress->getLastname()); $formFields['shopper.lastName'] = trim($billingAddress->getLastname());
$formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone()); $formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone());
if ($this->_adyenHelper->isSeparateHouseNumberRequired($billingAddress->getCountryId())) {
$this->_adyenLogger->addAdyenDebug("separate house number required");
$street = $this->_adyenHelper->getStreet($billingAddress); $street = $this->_adyenHelper->getStreet($billingAddress);
if (isset($street['name']) && $street['name'] != "") { if (isset($street['name']) && $street['name'] != "") {
...@@ -346,6 +349,10 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -346,6 +349,10 @@ class Redirect extends \Magento\Payment\Block\Form
} else { } else {
$formFields['billingAddress.houseNumberOrName'] = "NA"; $formFields['billingAddress.houseNumberOrName'] = "NA";
} }
} else {
$this->_adyenLogger->addAdyenDebug("separate house number NOT required");
$formFields['billingAddress.street'] = implode(" ", $billingAddress->getStreet());
}
if (trim($billingAddress->getCity()) == "") { if (trim($billingAddress->getCity()) == "") {
$formFields['billingAddress.city'] = "NA"; $formFields['billingAddress.city'] = "NA";
...@@ -382,8 +389,10 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -382,8 +389,10 @@ class Redirect extends \Magento\Payment\Block\Form
protected function setShippingAddressData($formFields) protected function setShippingAddressData($formFields)
{ {
$shippingAddress = $this->_order->getShippingAddress(); $shippingAddress = $this->_order->getShippingAddress();
$this->_adyenLogger->addAdyenDebug($shippingAddress->getCountryId());
if ($shippingAddress) { if ($shippingAddress) {
if ($this->_adyenHelper->isSeparateHouseNumberRequired($shippingAddress->getCountryId())) {
$this->_adyenLogger->addAdyenDebug("separate house number required");
$street = $this->_adyenHelper->getStreet($shippingAddress); $street = $this->_adyenHelper->getStreet($shippingAddress);
if (isset($street['name']) && $street['name'] != "") { if (isset($street['name']) && $street['name'] != "") {
...@@ -395,6 +404,11 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -395,6 +404,11 @@ class Redirect extends \Magento\Payment\Block\Form
} else { } else {
$formFields['deliveryAddress.houseNumberOrName'] = "NA"; $formFields['deliveryAddress.houseNumberOrName'] = "NA";
} }
} else {
$this->_adyenLogger->addAdyenDebug("separate house number NOT required");
$formFields['deliveryAddress.street'] = implode(" ", $shippingAddress->getStreet());
}
if (trim($shippingAddress->getCity()) == "") { if (trim($shippingAddress->getCity()) == "") {
$formFields['deliveryAddress.city'] = "NA"; $formFields['deliveryAddress.city'] = "NA";
...@@ -420,6 +434,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -420,6 +434,7 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['deliveryAddress.country'] = trim($shippingAddress->getCountryId()); $formFields['deliveryAddress.country'] = trim($shippingAddress->getCountryId());
} }
} }
return $formFields; return $formFields;
} }
......
...@@ -1607,4 +1607,16 @@ class Data extends AbstractHelper ...@@ -1607,4 +1607,16 @@ class Data extends AbstractHelper
return $this->getAdyenCcVaultConfigDataFlag('active', $storeId); return $this->getAdyenCcVaultConfigDataFlag('active', $storeId);
} }
/**
* Checks if the house number needs to be sent to the Adyen API separately or as it is in the street field
*
* @param $country
* @return bool
*/
public function isSeparateHouseNumberRequired($country)
{
$countryList = ["nl", "de", "se", "no", "at", "fi", "dk"];
return in_array(strtolower($country), $countryList);
}
} }
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