Skip to content

Commit 18c8be6

Browse files
MC-16375: Unable to pay with Braintree Paypal (Payment Action = Authorize and Capture) for Gift Card as Guest
- Fix braintree paypal quote address
1 parent 45a5bf9 commit 18c8be6

File tree

2 files changed

+17
-31
lines changed

2 files changed

+17
-31
lines changed

app/code/Magento/Braintree/Plugin/DisableQuoteAddressValidation.php

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,37 @@
77

88
namespace Magento\Braintree\Plugin;
99

10-
use Magento\Quote\Api\CartRepositoryInterface;
11-
use Magento\Quote\Api\Data\PaymentInterface;
10+
use Magento\Quote\Model\QuoteManagement;
1211
use Magento\Quote\Api\CartManagementInterface;
12+
use Magento\Quote\Model\Quote;
1313

1414
/**
15-
* Plugin for CartManagementInterface to disable quote address validation
15+
* Plugin for QuoteManagement to disable quote address validation
1616
*/
1717
class DisableQuoteAddressValidation
1818
{
1919
/**
20-
* @var CartRepositoryInterface
21-
*/
22-
private $quoteRepository;
23-
24-
/**
25-
* @param CartRepositoryInterface $quoteRepository
26-
*/
27-
public function __construct(
28-
CartRepositoryInterface $quoteRepository
29-
) {
30-
$this->quoteRepository = $quoteRepository;
31-
}
32-
33-
/**
34-
* Disable quote address validation before place order
20+
* Disable quote address validation before submit order
3521
*
36-
* @param CartManagementInterface $subject
37-
* @param \Closure $proceed
38-
* @param int $cartId
39-
* @param PaymentInterface|null $payment
40-
* @return int
41-
* @throws \Magento\Framework\Exception\NoSuchEntityException
22+
* @param QuoteManagement $subject
23+
* @param Quote $quote
24+
* @param array $orderData
25+
* @return array
26+
* @throws \Exception
27+
* @throws \Magento\Framework\Exception\LocalizedException
4228
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4329
*/
44-
public function aroundPlaceOrder(
45-
CartManagementInterface $subject,
46-
\Closure $proceed,
47-
int $cartId,
48-
PaymentInterface $payment = null
30+
public function beforeSubmit(
31+
QuoteManagement $subject,
32+
Quote $quote,
33+
$orderData = []
4934
) {
50-
$quote = $this->quoteRepository->get($cartId);
5135
if ($quote->getPayment()->getMethod() == 'braintree_paypal' &&
5236
$quote->getCheckoutMethod() == CartManagementInterface::METHOD_GUEST) {
5337
$billingAddress = $quote->getBillingAddress();
5438
$billingAddress->setShouldIgnoreValidation(true);
5539
$quote->setBillingAddress($billingAddress);
5640
}
57-
return $proceed($cartId, $payment);
41+
return [$quote, $orderData];
5842
}
5943
}

app/code/Magento/Braintree/etc/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@
626626

627627
<type name="Magento\Quote\Api\CartManagementInterface">
628628
<plugin name="order_cancellation" type="Magento\Braintree\Plugin\OrderCancellation"/>
629+
</type>
630+
<type name="Magento\Quote\Model\QuoteManagement">
629631
<plugin name="disable_quote_address_validation" type="Magento\Braintree\Plugin\DisableQuoteAddressValidation"/>
630632
</type>
631633
</config>

0 commit comments

Comments
 (0)