Skip to content

Commit e76579f

Browse files
committed
Merge branch 'MAGETWO-99022' of https://github.com/magento-mpi/magento2ce into pr_2019_04_17
2 parents 1ffd8c5 + 9b90443 commit e76579f

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

app/code/Magento/Braintree/Controller/Paypal/Review.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Exception\LocalizedException;
1515
use Magento\Framework\App\Action\HttpPostActionInterface;
1616
use Magento\Framework\App\Action\HttpGetActionInterface;
17+
use Magento\Payment\Model\Method\Logger;
1718

1819
/**
1920
* Class Review
@@ -25,6 +26,11 @@ class Review extends AbstractAction implements HttpPostActionInterface, HttpGetA
2526
*/
2627
private $quoteUpdater;
2728

29+
/**
30+
* @var Logger
31+
*/
32+
private $logger;
33+
2834
/**
2935
* @var string
3036
*/
@@ -37,15 +43,18 @@ class Review extends AbstractAction implements HttpPostActionInterface, HttpGetA
3743
* @param Config $config
3844
* @param Session $checkoutSession
3945
* @param QuoteUpdater $quoteUpdater
46+
* @param Logger $logger
4047
*/
4148
public function __construct(
4249
Context $context,
4350
Config $config,
4451
Session $checkoutSession,
45-
QuoteUpdater $quoteUpdater
52+
QuoteUpdater $quoteUpdater,
53+
Logger $logger
4654
) {
4755
parent::__construct($context, $config, $checkoutSession);
4856
$this->quoteUpdater = $quoteUpdater;
57+
$this->logger = $logger;
4958
}
5059

5160
/**
@@ -57,6 +66,7 @@ public function execute()
5766
$this->getRequest()->getPostValue('result', '{}'),
5867
true
5968
);
69+
$this->logger->debug($requestData);
6070
$quote = $this->checkoutSession->getQuote();
6171

6272
try {

app/code/Magento/Braintree/Model/Paypal/Helper/QuoteUpdater.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ private function updateShippingAddress(Quote $quote, array $details)
123123
{
124124
$shippingAddress = $quote->getShippingAddress();
125125

126-
$shippingAddress->setLastname($details['lastName']);
127-
$shippingAddress->setFirstname($details['firstName']);
126+
$shippingAddress->setLastname($this->getShippingRecipientLastName($details));
127+
$shippingAddress->setFirstname($this->getShippingRecipientFirstName($details));
128128
$shippingAddress->setEmail($details['email']);
129129

130130
$shippingAddress->setCollectShippingRates(true);
@@ -188,4 +188,30 @@ private function updateAddressData(Address $address, array $addressData)
188188
$address->setSameAsBilling(false);
189189
$address->setCustomerAddressId(null);
190190
}
191+
192+
/**
193+
* Returns shipping recipient first name.
194+
*
195+
* @param array $details
196+
* @return string
197+
*/
198+
private function getShippingRecipientFirstName(array $details)
199+
{
200+
return isset($details['shippingAddress']['recipientName'])
201+
? explode(' ', $details['shippingAddress']['recipientName'], 2)[0]
202+
: $details['firstName'];
203+
}
204+
205+
/**
206+
* Returns shipping recipient last name.
207+
*
208+
* @param array $details
209+
* @return string
210+
*/
211+
private function getShippingRecipientLastName(array $details)
212+
{
213+
return isset($details['shippingAddress']['recipientName'])
214+
? explode(' ', $details['shippingAddress']['recipientName'], 2)[1]
215+
: $details['lastName'];
216+
}
191217
}

app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/QuoteUpdaterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private function getDetails(): array
165165
'region' => 'IL',
166166
'postalCode' => '60618',
167167
'countryCodeAlpha2' => 'US',
168-
'recipientName' => 'John Doe',
168+
'recipientName' => 'Jane Smith',
169169
],
170170
'billingAddress' => [
171171
'streetAddress' => '123 Billing Street',
@@ -186,9 +186,9 @@ private function getDetails(): array
186186
private function updateShippingAddressStep(array $details): void
187187
{
188188
$this->shippingAddress->method('setLastname')
189-
->with($details['lastName']);
189+
->with('Smith');
190190
$this->shippingAddress->method('setFirstname')
191-
->with($details['firstName']);
191+
->with('Jane');
192192
$this->shippingAddress->method('setEmail')
193193
->with($details['email']);
194194
$this->shippingAddress->method('setCollectShippingRates')

0 commit comments

Comments
 (0)