Skip to content

Commit 82fabd5

Browse files
Merge branch 'MAGETWO-64833' into MAGETWO-64833-61505
2 parents f1dc91b + c8725fe commit 82fabd5

File tree

4 files changed

+204
-79
lines changed

4 files changed

+204
-79
lines changed

app/code/Magento/Paypal/Model/Api/Nvp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,9 +1482,9 @@ protected function _exportAddressses($data)
14821482
protected function _applyStreetAndRegionWorkarounds(\Magento\Framework\DataObject $address)
14831483
{
14841484
// merge street addresses into 1
1485-
if ($address->hasStreet2()) {
1486-
$address->setStreet(implode("\n", [$address->getStreet(), $address->getStreetLine(2)]));
1487-
$address->unsStreet2();
1485+
if ($address->getData('street2') !== null) {
1486+
$address->setStreet(implode("\n", [$address->getData('street'), $address->getData('street2')]));
1487+
$address->unsetData('street2');
14881488
}
14891489
// attempt to fetch region_id from directory
14901490
if ($address->getCountryId() && $address->getRegion()) {

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -901,35 +901,19 @@ public function getCheckoutMethod()
901901
* @param Address $address
902902
* @param array $exportedAddress
903903
* @return void
904-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
905904
*/
906905
protected function _setExportedAddressData($address, $exportedAddress)
907906
{
908907
// Exported data is more priority if we came from Express Checkout button
909-
$isButton = (bool)$this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON);
908+
$isButton = (bool)$this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON);
910909
if (!$isButton) {
911-
foreach ($exportedAddress->getExportedKeys() as $key) {
912-
$oldData = $address->getDataUsingMethod($key);
913-
$isEmpty = null;
914-
if (is_array($oldData)) {
915-
foreach ($oldData as $val) {
916-
if (!empty($val)) {
917-
$isEmpty = false;
918-
break;
919-
}
920-
$isEmpty = true;
921-
}
922-
}
923-
if (empty($oldData) || $isEmpty === true) {
924-
$address->setDataUsingMethod($key, $exportedAddress->getData($key));
925-
}
926-
}
927-
} else {
928-
foreach ($exportedAddress->getExportedKeys() as $key) {
929-
$data = $exportedAddress->getData($key);
930-
if (!empty($data)) {
931-
$address->setDataUsingMethod($key, $data);
932-
}
910+
return;
911+
}
912+
913+
foreach ($exportedAddress->getExportedKeys() as $key) {
914+
$data = $exportedAddress->getData($key);
915+
if (!empty($data)) {
916+
$address->setDataUsingMethod($key, $data);
933917
}
934918
}
935919
}

app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,21 @@ public function testCallGetExpressCheckoutDetails()
194194
->method('read')
195195
->will($this->returnValue(
196196
"\r\n" . 'ACK=Success&SHIPTONAME=Ship%20To%20Name'
197+
. '&SHIPTOSTREET=testStreet'
198+
. '&SHIPTOSTREET2=testApartment'
199+
. '&BUSINESS=testCompany'
200+
. '&SHIPTOCITY=testCity'
201+
. '&PHONENUM=223322'
202+
. '&STATE=testSTATE'
197203
));
198204
$this->model->callGetExpressCheckoutDetails();
199-
$this->assertEquals('Ship To Name', $this->model->getExportedShippingAddress()->getData('firstname'));
205+
$address = $this->model->getExportedShippingAddress();
206+
$this->assertEquals('Ship To Name', $address->getData('firstname'));
207+
$this->assertEquals(implode("\n", ['testStreet','testApartment']), $address->getStreet());
208+
$this->assertEquals('testCompany', $address->getCompany());
209+
$this->assertEquals('testCity', $address->getCity());
210+
$this->assertEquals('223322', $address->getTelephone());
211+
$this->assertEquals('testSTATE', $address->getRegion());
200212
}
201213

202214
public function testGetDebugReplacePrivateDataKeys()

0 commit comments

Comments
 (0)