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

Merge pull request #434 from Adyen/PW-1085

PW-1085 House number parsing doesn't always work properly
parents 0dbcbcaf a208542b
...@@ -335,16 +335,21 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -335,16 +335,21 @@ 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());
$street = $this->_adyenHelper->getStreet($billingAddress);
if (isset($street['name']) && $street['name'] != "") { if ($this->_adyenHelper->isSeparateHouseNumberRequired($billingAddress->getCountryId())) {
$formFields['billingAddress.street'] = $street['name']; $street = $this->_adyenHelper->getStreet($billingAddress);
}
if (isset($street['name']) && $street['name'] != "") {
$formFields['billingAddress.street'] = $street['name'];
}
if (isset($street['house_number']) && $street['house_number'] != "") { if (isset($street['house_number']) && $street['house_number'] != "") {
$formFields['billingAddress.houseNumberOrName'] = $street['house_number']; $formFields['billingAddress.houseNumberOrName'] = $street['house_number'];
} else {
$formFields['billingAddress.houseNumberOrName'] = "NA";
}
} else { } else {
$formFields['billingAddress.houseNumberOrName'] = "NA"; $formFields['billingAddress.street'] = implode(" ", $billingAddress->getStreet());
} }
if (trim($billingAddress->getCity()) == "") { if (trim($billingAddress->getCity()) == "") {
...@@ -384,18 +389,23 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -384,18 +389,23 @@ class Redirect extends \Magento\Payment\Block\Form
$shippingAddress = $this->_order->getShippingAddress(); $shippingAddress = $this->_order->getShippingAddress();
if ($shippingAddress) { if ($shippingAddress) {
$street = $this->_adyenHelper->getStreet($shippingAddress); if ($this->_adyenHelper->isSeparateHouseNumberRequired($shippingAddress->getCountryId())) {
$street = $this->_adyenHelper->getStreet($shippingAddress);
if (isset($street['name']) && $street['name'] != "") { if (isset($street['name']) && $street['name'] != "") {
$formFields['deliveryAddress.street'] = $street['name']; $formFields['deliveryAddress.street'] = $street['name'];
} }
if (isset($street['house_number']) && $street['house_number'] != "") { if (isset($street['house_number']) && $street['house_number'] != "") {
$formFields['deliveryAddress.houseNumberOrName'] = $street['house_number']; $formFields['deliveryAddress.houseNumberOrName'] = $street['house_number'];
} else {
$formFields['deliveryAddress.houseNumberOrName'] = "NA";
}
} else { } else {
$formFields['deliveryAddress.houseNumberOrName'] = "NA"; $formFields['deliveryAddress.street'] = implode(" ", $shippingAddress->getStreet());
} }
if (trim($shippingAddress->getCity()) == "") { if (trim($shippingAddress->getCity()) == "") {
$formFields['deliveryAddress.city'] = "NA"; $formFields['deliveryAddress.city'] = "NA";
} else { } else {
...@@ -420,6 +430,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -420,6 +430,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