File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 269
269
</argument >
270
270
</arguments >
271
271
</type >
272
+ <type name =" Magento\Quote\Model\CustomerManagement" >
273
+ <plugin name =" paypal_payment_skip_addresses_validate" type =" Magento\Paypal\Plugin\CustomerManagementPlugin" />
274
+ </type >
272
275
</config >
Original file line number Diff line number Diff line change 16
16
use Magento \Framework \Validator \Exception as ValidatorException ;
17
17
use Magento \Framework \Validator \Factory as ValidatorFactory ;
18
18
use Magento \Quote \Model \Quote as QuoteEntity ;
19
- use Magento \Paypal \Model \Config as PaymentMethod ;
20
19
21
20
/**
22
21
* Class Customer
@@ -160,8 +159,7 @@ public function validateAddresses(QuoteEntity $quote)
160
159
$ quote ->getShippingAddress ()->getCustomerAddressId ()
161
160
);
162
161
}
163
- if (empty ($ addresses ) && $ quote ->getCustomerIsGuest () &&
164
- !in_array ($ quote ->getPayment ()->getMethod (), PaymentMethod::PAYMENT_METHODS_SKIP_ADDRESS_VALIDATION )) {
162
+ if (empty ($ addresses ) && $ quote ->getCustomerIsGuest ()) {
165
163
$ billingAddress = $ quote ->getBillingAddress ();
166
164
$ customerAddress = $ this ->customerAddressFactory ->create ();
167
165
$ customerAddress ->setFirstname ($ billingAddress ->getFirstname ());
You can’t perform that action at this time.
0 commit comments