Skip to content

Commit 0e0022a

Browse files
committed
Merge branch '2.4-develop' of github.com:magento-commerce/magento2ce into ims-phase1
2 parents 1e0edde + 7d80b87 commit 0e0022a

File tree

32 files changed

+170
-50
lines changed

32 files changed

+170
-50
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/redirect-on-success.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ define(
2222
*/
2323
execute: function () {
2424
fullScreenLoader.startLoader();
25+
this.reloadPage();
26+
},
27+
28+
/**
29+
* Method to reload page
30+
*/
31+
reloadPage: function () {
2532
window.location.replace(url.build(this.redirectUrl));
2633
}
2734
};

app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
messageContainer = messageContainer || globalMessageList;
2525

2626
if (response.status == 401) { //eslint-disable-line eqeqeq
27-
window.location.replace(url.build('customer/account/login/'));
27+
this.reloadPage(url.build('customer/account/login/'));
2828
} else {
2929
try {
3030
error = JSON.parse(response.responseText);
@@ -35,6 +35,13 @@ define([
3535
}
3636
messageContainer.addErrorMessage(error);
3737
}
38+
},
39+
40+
/**
41+
* Method to reload page
42+
*/
43+
reloadPage: function (redirectUrl) {
44+
window.location.replace(redirectUrl);
3845
}
3946
};
4047
});

app/code/Magento/Paypal/Block/Adminhtml/System/Config/PayLaterLink.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class PayLaterLink extends Field
2929
/**
3030
* @var array.
3131
*/
32-
private const ARRAY_PAYLATER_SUPPORTED_COUNTRIES = ['US','GB','DE','FR','AU'];
32+
private const ARRAY_PAYLATER_SUPPORTED_COUNTRIES = ['US','GB','DE','FR','AU','IT','ES'];
3333

3434
/**
3535
* @var ScopeConfigInterface

app/code/Magento/Paypal/Controller/Express/OnAuthorization.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,19 @@
3333
class OnAuthorization extends AbstractExpress implements HttpPostActionInterface
3434
{
3535
/**
36+
* @var PayPalConfig
3637
* @inheritdoc
3738
*/
3839
protected $_configType = PayPalConfig::class;
3940

4041
/**
42+
* @var PayPalConfig
4143
* @inheritdoc
4244
*/
4345
protected $_configMethod = PayPalConfig::METHOD_WPP_EXPRESS;
4446

4547
/**
48+
* @var PayPalCheckout
4649
* @inheritdoc
4750
*/
4851
protected $_checkoutType = PayPalCheckout::class;
@@ -53,8 +56,6 @@ class OnAuthorization extends AbstractExpress implements HttpPostActionInterface
5356
private $cartRepository;
5457

5558
/**
56-
* Url Builder
57-
*
5859
* @var UrlInterface
5960
*/
6061
private $urlBuilder;
@@ -116,6 +117,7 @@ public function execute(): ResultInterface
116117
$controllerResult = $this->resultFactory->create(ResultFactory::TYPE_JSON);
117118
$payerId = $this->getRequest()->getParam('payerId');
118119
$tokenId = $this->getRequest()->getParam('paymentToken');
120+
$fundingSource = $this->getRequest()->getParam('paypalFundingSource');
119121

120122
try {
121123
$quote = $this->_getQuote();
@@ -127,6 +129,7 @@ public function execute(): ResultInterface
127129

128130
/** Populate checkout object with new data */
129131
$this->_initCheckout($quote);
132+
$quote->getPayment()->setAdditionalInformation(PayPalCheckout::PAYMENT_INFO_FUNDING_SOURCE, $fundingSource);
130133
/** Populate quote with information about billing and shipping addresses*/
131134
$this->_checkout->returnFromPaypal($tokenId, $payerId);
132135
if ($this->_checkout->canSkipOrderReviewStep()) {

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Checkout
4242
public const PAYMENT_INFO_TRANSPORT_PAYER_ID = 'paypal_express_checkout_payer_id';
4343
public const PAYMENT_INFO_TRANSPORT_REDIRECT = 'paypal_express_checkout_redirect_required';
4444
public const PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT = 'paypal_ec_create_ba';
45+
public const PAYMENT_INFO_FUNDING_SOURCE = 'paypal_funding_source';
4546

4647
/**
4748
* Flag which says that was used PayPal Express Checkout button for checkout

app/code/Magento/Paypal/Test/Mftf/Test/AdminRegionalLinkForPayLaterTest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,12 @@
4444
<argument name="enabledOption" value="Yes"/>
4545
<argument name="countryCode" value="us"/>
4646
</actionGroup>
47+
<selectOption selector="{{PaymentsConfigSection.merchantCountry}}" userInput="Italy" stepKey="setMerchantCountry4"/>
48+
<waitForPageLoad stepKey="waitForPageLoa4"/>
49+
<actionGroup ref="AdminPayPalRegionalLinkOtherActionGroup" stepKey="verifyPayPalCommentCommentLink4">
50+
<argument name="payPalConfigType" value="PayPalExpressCheckoutOtherCountryConfigSection"/>
51+
<argument name="enabledOption" value="Yes"/>
52+
<argument name="countryCode" value="it"/>
53+
</actionGroup>
4754
</test>
4855
</tests>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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\Paypal\ViewModel;
9+
10+
use Magento\Checkout\Model\Session;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
use Magento\Paypal\Model\Express\Checkout;
13+
14+
/**
15+
* Provides Paypal funding source data
16+
*
17+
*/
18+
class PaypalFundingSourceDataProvider implements ArgumentInterface
19+
{
20+
/**
21+
* @var Session
22+
*/
23+
private $checkoutSession;
24+
25+
/**
26+
* @param Session $checkoutSession
27+
*/
28+
public function __construct(
29+
Session $checkoutSession
30+
) {
31+
$this->checkoutSession = $checkoutSession;
32+
}
33+
34+
/**
35+
* Return paypal funding source
36+
*
37+
* @return string|null
38+
*/
39+
public function getPaypalFundingSource()
40+
{
41+
$quote = $this->checkoutSession->getQuote();
42+
if ($quote->getPayment()->getAdditionalInformation(Checkout::PAYMENT_INFO_FUNDING_SOURCE)) {
43+
return ucfirst($quote->getPayment()->getAdditionalInformation(
44+
Checkout::PAYMENT_INFO_FUNDING_SOURCE
45+
));
46+
}
47+
return null;
48+
}
49+
}

app/code/Magento/Paypal/etc/adminhtml/system/express_checkout.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<config_path>payment/paypal_express/buyer_country</config_path>
109109
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
110110
<attribute type="shared">1</attribute>
111+
<tooltip>The buyer country determines which funding sources are eligible for a given buyer during testing.</tooltip>
111112
<depends>
112113
<field id="sandbox_flag">1</field>
113114
</depends>

app/code/Magento/Paypal/etc/adminhtml/system/payflow_advanced.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<config_path>payment/payflow_advanced/buyer_country</config_path>
6161
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
6262
<attribute type="shared">1</attribute>
63+
<tooltip>The buyer country determines which funding sources are eligible for a given buyer during testing.</tooltip>
6364
<depends>
6465
<field id="sandbox_flag">1</field>
6566
</depends>

app/code/Magento/Paypal/etc/adminhtml/system/payflow_link.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<label>Buyer Country</label>
6161
<config_path>payment/payflow_link/buyer_country</config_path>
6262
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
63+
<tooltip>The buyer country determines which funding sources are eligible for a given buyer during testing.</tooltip>
6364
<attribute type="shared">1</attribute>
6465
<depends>
6566
<field id="sandbox_flag">1</field>

app/code/Magento/Paypal/etc/adminhtml/system/paypal_payflowpro.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<label>Buyer Country</label>
5656
<config_path>payment/payflowpro/buyer_country</config_path>
5757
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
58+
<tooltip>The buyer country determines which funding sources are eligible for a given buyer during testing.</tooltip>
5859
<attribute type="shared">1</attribute>
5960
<depends>
6061
<field id="sandbox_flag">1</field>

app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
</referenceContainer>
2121
<referenceContainer name="content">
2222
<block class="Magento\Paypal\Block\Express\Review" name="paypal.express.review" template="Magento_Paypal::express/review.phtml">
23+
<arguments>
24+
<argument name="PaypalFundingSourceDataProvider" xsi:type="object">Magento\Paypal\ViewModel\PaypalFundingSourceDataProvider</argument>
25+
</arguments>
2326
<block class="Magento\Paypal\Block\Express\Review" name="express.review.shipping.method" as="shipping_method" template="Magento_Paypal::express/review/shipping/method.phtml"/>
2427
<block class="Magento\Framework\View\Element\Text\ListText" name="paypal.additional.actions">
2528
<block class="Magento\Checkout\Block\Cart\Coupon" name="paypal.cart.coupon" as="coupon" template="Magento_Checkout::cart/coupon.phtml"/>

app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
</referenceContainer>
2121
<referenceContainer name="content">
2222
<block class="Magento\Paypal\Block\Express\Review" name="paypal.express.review" template="Magento_Paypal::express/review.phtml">
23+
<arguments>
24+
<argument name="PaypalFundingSourceDataProvider" xsi:type="object">Magento\Paypal\ViewModel\PaypalFundingSourceDataProvider</argument>
25+
</arguments>
2326
<action method="setControllerPath">
2427
<argument name="prefix" xsi:type="string">paypal/payflowexpress</argument>
2528
</action>

app/code/Magento/Paypal/view/frontend/templates/express/review.phtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ use Magento\Paypal\Block\Express\Review;
1313
* @var Escaper $escaper
1414
* @var SecureHtmlRenderer $secureRenderer
1515
*/
16+
17+
/** @var \Magento\Paypal\ViewModel\PaypalFundingSourceDataProvider $paypalFundingSourceDataProvider */
18+
$paypalFundingSourceDataProvider = $block->getData('PaypalFundingSourceDataProvider');
1619
?>
1720
<div class="paypal-review view">
1821
<div class="block block-order-details-view">
@@ -101,7 +104,8 @@ use Magento\Paypal\Block\Express\Review;
101104
<div class="box box-order-billing-address">
102105
<strong class="box-title"><span><?= $escaper->escapeHtml(__('Payment Method')) ?></span></strong>
103106
<div class="box-content">
104-
<?= $escaper->escapeHtml($block->getPaymentMethodTitle()) ?><br>
107+
<?= $escaper->escapeHtml($paypalFundingSourceDataProvider->getPaypalFundingSource()
108+
?? $block->getPaymentMethodTitle()) ?><br>
105109
<?= $escaper->escapeHtml($block->getEmail()) ?> <br>
106110
<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png"
107111
alt="<?= $block->escapeHtml(__('Buy now with PayPal')) ?>"/>
@@ -150,6 +154,7 @@ use Magento\Paypal\Block\Express\Review;
150154
</form>
151155
</div>
152156
</div>
157+
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
153158
<script type="text/x-magento-init">
154159
{
155160
"#order-review-form": {

app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout-smart-buttons.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ define([
77
'underscore',
88
'jquery',
99
'Magento_Paypal/js/in-context/paypal-sdk',
10+
'Magento_Customer/js/customer-data',
1011
'domReady!'
11-
], function (_, $, paypalSdk) {
12+
], function (_, $, paypalSdk, customerData) {
1213
'use strict';
1314

1415
/**
@@ -47,6 +48,7 @@ define([
4748
var params = {
4849
paymentToken: data.orderID,
4950
payerId: data.payerID,
51+
paypalFundingSource: customerData.get('paypal-funding-source'),
5052
'form_key': clientConfig.formKey
5153
};
5254

@@ -56,8 +58,10 @@ define([
5658
$.post(clientConfig.onAuthorizeUrl, params).done(function (res) {
5759
clientConfig.rendererComponent
5860
.afterOnAuthorize(res, deferred.resolve, deferred.reject, actions);
61+
customerData.set('paypal-funding-source', '');
5962
}).fail(function (jqXHR, textStatus, err) {
6063
clientConfig.rendererComponent.catchOnAuthorize(err, deferred.resolve, deferred.reject);
64+
customerData.set('paypal-funding-source', '');
6165
});
6266
});
6367
}).promise();
@@ -97,7 +101,8 @@ define([
97101
/**
98102
* Execute logic on Paypal button click
99103
*/
100-
onClick: function () {
104+
onClick: function (data) {
105+
customerData.set('paypal-funding-source', data.fundingSource);
101106
clientConfig.rendererComponent.validate();
102107
clientConfig.rendererComponent.onClick();
103108
},
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
(function() {
7+
var env = jasmine.getEnv(),
8+
config = {random: false};
9+
10+
env.configure(config);
11+
})();

dev/tests/js/jasmine/spec_runner/tasks/jasmine.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ function init(config) {
6767
/**
6868
* @todo rename "helpers" to "specs" (implies overriding grunt-contrib-jasmine code)
6969
*/
70-
helpers: specs
70+
helpers: specs,
71+
sandboxArgs: {
72+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
73+
defaultViewport: {width: 400, height: 400, hasTouch: true},
74+
slowMo: 10000
75+
}
7176
}
7277
};
7378
});

dev/tests/js/jasmine/spec_runner/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</script>
2121
<% }); %>
2222
<% with (scripts) { %>
23-
<% [].concat(polyfills, jasmine, boot, vendor, src, reporters).forEach(function (script) { %>
23+
<% [].concat(polyfills, jasmine, '.grunt/grunt-contrib-jasmine/boot0.js', 'dev/tests/js/jasmine/spec_runner/jasmine-config.js', '.grunt/grunt-contrib-jasmine/boot1.js', vendor, src, reporters).forEach(function (script) { %>
2424
<script type="text/javascript" src="<%= script %>"></script>
2525
<% }); %>
2626
<% } %>

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/redirect-on-success.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ define([
3535
});
3636

3737
it('Checks if loader is called before redirect to success page.', function () {
38-
spyOn(window.location, 'replace').and.returnValue(false);
39-
38+
spyOn(RedirectOnSuccess, 'reloadPage').and.callFake(function () {});
4039
RedirectOnSuccess.execute();
4140

4241
expect(FullScreenLoader.startLoader).toHaveBeenCalled();

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/error-processor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ define([
6262
it('check on failed status', function () {
6363
var messageContainer = jasmine.createSpyObj('globalMessageList', ['addErrorMessage']);
6464

65-
spyOn(window.location, 'replace').and.callFake(function () {});
65+
spyOn(model, 'reloadPage').and.callFake(function () {});
6666
model.process({
6767
status: 401,
6868
responseText: ''

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/new-customer-address.test.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ define([
2525
});
2626

2727
it('Check on empty object.', function () {
28-
var expected = {
29-
countryId: 'US',
30-
regionCode: null,
31-
region: null
32-
};
28+
var result = newCustomerAddress({}),
29+
expected = {
30+
countryId: 'US',
31+
regionCode: null,
32+
region: null
33+
};
3334

34-
expect(JSON.stringify(newCustomerAddress({}))).toEqual(JSON.stringify(expected));
35+
result.postcode = undefined;
36+
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
3537
});
3638

3739
it('Check on function call with empty address data.', function () {
@@ -57,6 +59,7 @@ define([
5759
regionId: 1
5860
};
5961

62+
result.postcode = undefined;
6063
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
6164
});
6265
it('Check on regionId with countryId in address data.', function () {
@@ -69,6 +72,7 @@ define([
6972
region: null
7073
};
7174

75+
result.postcode = undefined;
7276
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
7377
});
7478
it('Check that extensionAttributes property exists if defined', function () {
@@ -86,6 +90,7 @@ define([
8690
}
8791
};
8892

93+
result.postcode = undefined;
8994
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
9095
});
9196
});

0 commit comments

Comments
 (0)