Skip to content

Commit 98859c2

Browse files
committed
AC-13828::Unable to place order with paypal express checkout when we are directly checking out from cart page
1 parent efdda6a commit 98859c2

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Paypal\Plugin;
9+
10+
use Magento\Quote\Model\CustomerManagement;
11+
use Magento\Quote\Model\Quote as QuoteEntity;
12+
use Magento\Paypal\Model\Config as PaymentMethodConfig;
13+
use Magento\Framework\Validator\Exception as ValidatorException;
14+
15+
/**
16+
* Skip billing address validation for PayPal payment method
17+
*/
18+
class CustomerManagementPlugin
19+
{
20+
/**
21+
* Around plugin for the validateAddresses method
22+
*
23+
* @param CustomerManagement $subject
24+
* @param \Closure $proceed
25+
* @param QuoteEntity $quote
26+
* @return void
27+
* @throws ValidatorException
28+
*/
29+
public function aroundValidateAddresses(CustomerManagement $subject, \Closure $proceed, QuoteEntity $quote)
30+
{
31+
if ($quote->getCustomerIsGuest() &&
32+
in_array($quote->getPayment()->getMethod(), PaymentMethodConfig::PAYMENT_METHODS_SKIP_ADDRESS_VALIDATION)) {
33+
return;
34+
}
35+
$proceed($quote);
36+
}
37+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,7 @@
269269
</argument>
270270
</arguments>
271271
</type>
272+
<type name="Magento\Quote\Model\CustomerManagement">
273+
<plugin name="paypal_payment_skip_addresses_validate" type="Magento\Paypal\Plugin\CustomerManagementPlugin"/>
274+
</type>
272275
</config>

app/code/Magento/Quote/Model/CustomerManagement.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Magento\Framework\Validator\Exception as ValidatorException;
1717
use Magento\Framework\Validator\Factory as ValidatorFactory;
1818
use Magento\Quote\Model\Quote as QuoteEntity;
19-
use Magento\Paypal\Model\Config as PaymentMethod;
2019

2120
/**
2221
* Class Customer
@@ -160,8 +159,7 @@ public function validateAddresses(QuoteEntity $quote)
160159
$quote->getShippingAddress()->getCustomerAddressId()
161160
);
162161
}
163-
if (empty($addresses) && $quote->getCustomerIsGuest() &&
164-
!in_array($quote->getPayment()->getMethod(), PaymentMethod::PAYMENT_METHODS_SKIP_ADDRESS_VALIDATION)) {
162+
if (empty($addresses) && $quote->getCustomerIsGuest()) {
165163
$billingAddress = $quote->getBillingAddress();
166164
$customerAddress = $this->customerAddressFactory->create();
167165
$customerAddress->setFirstname($billingAddress->getFirstname());

0 commit comments

Comments
 (0)