Skip to content

Commit 2ee062e

Browse files
committed
Merge remote-tracking branch 'github-magento2ce/MC-16375' into EPAM-PR-71
2 parents 5679374 + 18c8be6 commit 2ee062e

File tree

5 files changed

+86
-10
lines changed

5 files changed

+86
-10
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Braintree\Plugin;
9+
10+
use Magento\Quote\Model\QuoteManagement;
11+
use Magento\Quote\Api\CartManagementInterface;
12+
use Magento\Quote\Model\Quote;
13+
14+
/**
15+
* Plugin for QuoteManagement to disable quote address validation
16+
*/
17+
class DisableQuoteAddressValidation
18+
{
19+
/**
20+
* Disable quote address validation before submit order
21+
*
22+
* @param QuoteManagement $subject
23+
* @param Quote $quote
24+
* @param array $orderData
25+
* @return array
26+
* @throws \Exception
27+
* @throws \Magento\Framework\Exception\LocalizedException
28+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
29+
*/
30+
public function beforeSubmit(
31+
QuoteManagement $subject,
32+
Quote $quote,
33+
$orderData = []
34+
) {
35+
if ($quote->getPayment()->getMethod() == 'braintree_paypal' &&
36+
$quote->getCheckoutMethod() == CartManagementInterface::METHOD_GUEST) {
37+
$billingAddress = $quote->getBillingAddress();
38+
$billingAddress->setShouldIgnoreValidation(true);
39+
$quote->setBillingAddress($billingAddress);
40+
}
41+
return [$quote, $orderData];
42+
}
43+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,7 @@
627627
<type name="Magento\Quote\Api\CartManagementInterface">
628628
<plugin name="order_cancellation" type="Magento\Braintree\Plugin\OrderCancellation"/>
629629
</type>
630+
<type name="Magento\Quote\Model\QuoteManagement">
631+
<plugin name="disable_quote_address_validation" type="Magento\Braintree\Plugin\DisableQuoteAddressValidation"/>
632+
</type>
630633
</config>

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,17 @@ define([
187187
*/
188188
setBillingAddress: function (customer, address) {
189189
var billingAddress = {
190-
street: [address.streetAddress],
191-
city: address.locality,
190+
street: [address.line1],
191+
city: address.city,
192192
postcode: address.postalCode,
193-
countryId: address.countryCodeAlpha2,
193+
countryId: address.countryCode,
194194
email: customer.email,
195195
firstname: customer.firstName,
196196
lastname: customer.lastName,
197-
telephone: customer.phone
197+
telephone: customer.phone,
198+
regionCode: address.state
198199
};
199200

200-
billingAddress['region_code'] = address.region;
201201
billingAddress = createBillingAddress(billingAddress);
202202
quote.billingAddress(billingAddress);
203203
},
@@ -209,10 +209,12 @@ define([
209209
beforePlaceOrder: function (payload) {
210210
this.setPaymentPayload(payload);
211211

212-
if ((this.isRequiredBillingAddress() || quote.billingAddress() === null) &&
213-
typeof payload.details.billingAddress !== 'undefined'
214-
) {
215-
this.setBillingAddress(payload.details, payload.details.billingAddress);
212+
if (this.isRequiredBillingAddress() || quote.billingAddress() === null) {
213+
if (typeof payload.details.billingAddress !== 'undefined') {
214+
this.setBillingAddress(payload.details, payload.details.billingAddress);
215+
} else {
216+
this.setBillingAddress(payload.details, payload.details.shippingAddress);
217+
}
216218
}
217219

218220
if (this.isSkipOrderReview()) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="LoginToPayPalPaymentAccount">
11+
<arguments>
12+
<argument name="userName" type="string" defaultValue="{{Payer.buyerEmail}}"/>
13+
<argument name="password" type="string" defaultValue="{{Payer.buyerPassword}"/>
14+
</arguments>
15+
<fillField selector="{{PayPalPaymentSection.email}}" userInput="{{userName}}" stepKey="fillEmail"/>
16+
<click selector="{{PayPalPaymentSection.nextButton}}" stepKey="clickNext"/>
17+
<waitForElementVisible selector="{{PayPalPaymentSection.password}}" stepKey="waitForPasswordField"/>
18+
<fillField selector="{{PayPalPaymentSection.password}}" userInput="{{password}}" stepKey="fillPassword"/>
19+
<click selector="{{PayPalPaymentSection.loginBtn}}" stepKey="clickLogin"/>
20+
<waitForPageLoad stepKey="waitForLoginPageLoad"/>
21+
<click selector="{{PayPalPaymentSection.continueButton}}" stepKey="clickContinue"/>
22+
</actionGroup>
23+
</actionGroups>

app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<element name="color" type="text" selector=".paypal-button-color-{{color}}" parameterized="true"/>
4646
</section>
4747
<section name="CheckoutPaymentSection">
48+
<element name="email" type="input" selector="#checkout-customer-email"/>
49+
<element name="payPalPaymentBraintree" type="radio" selector="#braintree_paypal"/>
50+
<element name="payPalFrame" type="iframe" selector="//iframe[contains(@class, 'zoid-component-frame zoid-visible')]" timeout="5"/>
4851
<element name="PayPalPaymentRadio" type="radio" selector="input#paypal_express.radio" timeout="30"/>
4952
<element name="PayPalBtn" type="radio" selector=".paypal-button.paypal-button-number-0" timeout="30"/>
5053
</section>
@@ -58,5 +61,7 @@
5861
<element name="cartIcon" type="text" selector="#transactionCart"/>
5962
<element name="itemName" type="text" selector="//span[@title='{{productName}}']" parameterized="true"/>
6063
<element name="PayPalSubmitBtn" type="text" selector="//input[@type='submit']"/>
64+
<element name="nextButton" type="button" selector="#btnNext"/>
65+
<element name="continueButton" type="button" selector=".continueButton"/>
6166
</section>
62-
</sections>
67+
</sections>

0 commit comments

Comments
 (0)