Skip to content

Commit 54b6c10

Browse files
author
Yaroslav Onischenko
authored
Merge pull request #531 from magento-mpi/PR-2.2
[MPI] OnePageCheckoutWithDiscountTest fix and PayPal configuration changes
2 parents f808b51 + 9d9b422 commit 54b6c10

File tree

13 files changed

+49
-65
lines changed

13 files changed

+49
-65
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/full-screen-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
/**
2525
* Stop full page loader action
2626
*
27-
* @param {Boolean} forceStop
27+
* @param {Boolean} [forceStop]
2828
*/
2929
stopLoader: function (forceStop) {
3030
var $elem = $(containerId),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<label>Express Checkout</label>
2424
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
2525
<field id="business_account" translate="label comment tooltip" showInDefault="1" showInWebsite="1" sortOrder="5">
26-
<label>Email Associated with PayPal Merchant Account</label>
26+
<label>Email Associated with PayPal Merchant Account (Optional)</label>
27+
<frontend_class>not-required</frontend_class>
2728
<comment>
2829
<![CDATA[<a href="http://www.magentocommerce.com/paypal">Start accepting payments via PayPal!</a>]]>
2930
</comment>

app/code/Magento/SalesRule/view/frontend/web/js/action/cancel-coupon.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ define(
1717
'mage/storage',
1818
'Magento_Checkout/js/action/get-payment-information',
1919
'Magento_Checkout/js/model/totals',
20-
'mage/translate'
20+
'mage/translate',
21+
'Magento_Checkout/js/model/full-screen-loader'
2122
],
22-
function ($, quote, urlManager, errorProcessor, messageContainer, storage, getPaymentInformationAction, totals, $t) {
23+
function ($, quote, urlManager, errorProcessor, messageContainer, storage, getPaymentInformationAction, totals, $t,
24+
fullScreenLoader) {
2325
'use strict';
2426

25-
return function (isApplied, isLoading) {
27+
return function (isApplied) {
2628
var quoteId = quote.getQuoteId(),
2729
url = urlManager.getCancelCouponUrl(quoteId),
2830
message = $t('Your coupon was successfully removed.');
31+
2932
messageContainer.clear();
33+
fullScreenLoader.startLoader();
3034

3135
return storage.delete(
3236
url,
@@ -39,6 +43,7 @@ define(
3943
$.when(deferred).done(function () {
4044
isApplied(false);
4145
totals.isLoading(false);
46+
fullScreenLoader.stopLoader();
4247
});
4348
messageContainer.addSuccessMessage({
4449
'message': message
@@ -47,12 +52,9 @@ define(
4752
).fail(
4853
function (response) {
4954
totals.isLoading(false);
55+
fullScreenLoader.stopLoader();
5056
errorProcessor.process(response, messageContainer);
5157
}
52-
).always(
53-
function () {
54-
isLoading(false);
55-
}
5658
);
5759
};
5860
}

app/code/Magento/SalesRule/view/frontend/web/js/action/set-coupon-code.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,22 @@ define(
1818
'mage/storage',
1919
'mage/translate',
2020
'Magento_Checkout/js/action/get-payment-information',
21-
'Magento_Checkout/js/model/totals'
21+
'Magento_Checkout/js/model/totals',
22+
'Magento_Checkout/js/model/full-screen-loader'
2223
],
2324
function (
24-
ko,
25-
$,
26-
quote,
27-
urlManager,
28-
errorProcessor,
29-
messageContainer,
30-
storage,
31-
$t,
32-
getPaymentInformationAction,
33-
totals
25+
ko, $, quote, urlManager, errorProcessor, messageContainer, storage, $t, getPaymentInformationAction, totals,
26+
fullScreenLoader
3427
) {
3528
'use strict';
36-
return function (couponCode, isApplied, isLoading) {
37-
var quoteId = quote.getQuoteId();
38-
var url = urlManager.getApplyCouponUrl(couponCode, quoteId);
39-
var message = $t('Your coupon was successfully applied.');
29+
30+
return function (couponCode, isApplied) {
31+
var quoteId = quote.getQuoteId(),
32+
url = urlManager.getApplyCouponUrl(couponCode, quoteId),
33+
message = $t('Your coupon was successfully applied.');
34+
35+
fullScreenLoader.startLoader();
36+
4037
return storage.put(
4138
url,
4239
{},
@@ -45,19 +42,22 @@ define(
4542
function (response) {
4643
if (response) {
4744
var deferred = $.Deferred();
48-
isLoading(false);
45+
4946
isApplied(true);
5047
totals.isLoading(true);
5148
getPaymentInformationAction(deferred);
5249
$.when(deferred).done(function () {
50+
fullScreenLoader.stopLoader();
5351
totals.isLoading(false);
5452
});
55-
messageContainer.addSuccessMessage({'message': message});
53+
messageContainer.addSuccessMessage({
54+
'message': message
55+
});
5656
}
5757
}
5858
).fail(
5959
function (response) {
60-
isLoading(false);
60+
fullScreenLoader.stopLoader();
6161
totals.isLoading(false);
6262
errorProcessor.process(response, messageContainer);
6363
}

app/code/Magento/SalesRule/view/frontend/web/js/view/payment/discount.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,53 @@ define(
1313
],
1414
function ($, ko, Component, quote, setCouponCodeAction, cancelCouponAction) {
1515
'use strict';
16-
var totals = quote.getTotals();
17-
var couponCode = ko.observable(null);
16+
17+
var totals = quote.getTotals(),
18+
couponCode = ko.observable(null),
19+
isApplied = ko.observable(couponCode() != null);
20+
1821
if (totals()) {
1922
couponCode(totals()['coupon_code']);
2023
}
21-
var isApplied = ko.observable(couponCode() != null);
22-
var isLoading = ko.observable(false);
24+
2325
return Component.extend({
2426
defaults: {
2527
template: 'Magento_SalesRule/payment/discount'
2628
},
2729
couponCode: couponCode,
30+
2831
/**
2932
* Applied flag
3033
*/
3134
isApplied: isApplied,
32-
isLoading: isLoading,
35+
3336
/**
3437
* Coupon code application procedure
3538
*/
3639
apply: function() {
3740
if (this.validate()) {
38-
isLoading(true);
39-
setCouponCodeAction(couponCode(), isApplied, isLoading);
41+
setCouponCodeAction(couponCode(), isApplied);
4042
}
4143
},
44+
4245
/**
4346
* Cancel using coupon
4447
*/
4548
cancel: function() {
4649
if (this.validate()) {
47-
isLoading(true);
4850
couponCode('');
49-
cancelCouponAction(isApplied, isLoading);
51+
cancelCouponAction(isApplied);
5052
}
5153
},
54+
5255
/**
5356
* Coupon form validation
5457
*
55-
* @returns {boolean}
58+
* @returns {Boolean}
5659
*/
57-
validate: function() {
60+
validate: function () {
5861
var form = '#discount-form';
62+
5963
return $(form).validation() && $(form).validation('isValid');
6064
}
6165
});

app/code/Magento/SalesRule/view/frontend/web/template/payment/discount.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<!-- ko foreach: getRegion('messages') -->
1616
<!-- ko template: getTemplate() --><!-- /ko -->
1717
<!--/ko-->
18-
<form class="form form-discount" id="discount-form" data-bind="blockLoader: isLoading">
18+
<form class="form form-discount" id="discount-form">
1919
<div class="payment-option-inner">
2020
<div class="field">
2121
<label class="label" for="discount-code">

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function selectPaymentMethod(array $payment, InjectableFixture $creditCar
8585
$paymentLabelSelector = sprintf($this->paymentMethodLabel, $payment['method']);
8686

8787
try {
88+
$this->waitForElementNotVisible($this->waitElement);
8889
$this->waitForElementVisible($paymentLabelSelector);
8990
} catch (\Exception $exception) {
9091
throw new \Exception('Such payment method is absent.');

dev/tests/functional/tests/app/Magento/Paypal/Test/Block/System/Config/ExpressCheckout.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class ExpressCheckout extends Block
2020
* @var array
2121
*/
2222
private $fields = [
23-
'Email Associated with PayPal Merchant Account' => '#payment_us_paypal_alternative_payment_methods_express_' .
24-
'checkout_us_express_checkout_required_express_checkout_required_express_checkout_business_account',
2523
'API Username' => '#payment_us_paypal_alternative_payment_methods_express_checkout_us_express_checkout_' .
2624
'required_express_checkout_required_express_checkout_api_username',
2725
'API Password' => '#payment_us_paypal_alternative_payment_methods_express_checkout_us_express_checkout_' .
@@ -72,8 +70,6 @@ public function getFields()
7270
*/
7371
public function specifyCredentials()
7472
{
75-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])
76-
->setValue('test@test.com');
7773
$this->_rootElement->find($this->fields['API Username'])->setValue('1');
7874
$this->_rootElement->find($this->fields['API Password'])->setValue('1');
7975
$this->_rootElement->find($this->fields['API Signature'])->setValue('1');
@@ -86,7 +82,6 @@ public function specifyCredentials()
8682
*/
8783
public function clearCredentials()
8884
{
89-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])->setValue('');
9085
$this->_rootElement->find($this->fields['API Username'])->setValue('');
9186
$this->_rootElement->find($this->fields['API Password'])->setValue('');
9287
$this->_rootElement->find($this->fields['API Signature'])->setValue('');

dev/tests/functional/tests/app/Magento/Paypal/Test/Block/System/Config/PayflowLink.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class PayflowLink extends Block
2020
* @var array
2121
*/
2222
private $fields = [
23-
'Email Associated with PayPal Merchant Account' => '#payment_us_paypal_payment_gateways_payflow_link_us_' .
24-
'payflow_link_required_payflow_link_payflow_link_business_account',
2523
'Partner' => '#payment_us_paypal_payment_gateways_payflow_link_us_payflow_link_required_payflow_link_payflow_' .
2624
'link_partner',
2725
'Vendor' => '#payment_us_paypal_payment_gateways_payflow_link_us_payflow_link_required_payflow_link_payflow_' .
@@ -60,8 +58,6 @@ class PayflowLink extends Block
6058
*/
6159
public function specifyCredentials()
6260
{
63-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])
64-
->setValue('test@test.com');
6561
$this->_rootElement->find($this->fields['Partner'])->setValue('1');
6662
$this->_rootElement->find($this->fields['Vendor'])->setValue('1');
6763
$this->_rootElement->find($this->fields['User'])->setValue('1');
@@ -75,7 +71,6 @@ public function specifyCredentials()
7571
*/
7672
public function clearCredentials()
7773
{
78-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])->setValue('');
7974
$this->_rootElement->find($this->fields['Partner'])->setValue('');
8075
$this->_rootElement->find($this->fields['Vendor'])->setValue('');
8176
$this->_rootElement->find($this->fields['User'])->setValue('');

dev/tests/functional/tests/app/Magento/Paypal/Test/Block/System/Config/PayflowPro.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class PayflowPro extends Block
2020
* @var array
2121
*/
2222
private $fields = [
23-
'Email Associated with PayPal Merchant Account' => '#payment_us_paypal_payment_gateways_paypal_payflowpro_' .
24-
'with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_business_account',
2523
'Partner' => '#payment_us_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_' .
2624
'required_paypal_payflow_api_settings_partner',
2725
'Vendor' => '#payment_us_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_' .
@@ -60,8 +58,6 @@ class PayflowPro extends Block
6058
*/
6159
public function specifyCredentials()
6260
{
63-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])
64-
->setValue('test@test.com');
6561
$this->_rootElement->find($this->fields['Partner'])->setValue('1');
6662
$this->_rootElement->find($this->fields['Vendor'])->setValue('1');
6763
$this->_rootElement->find($this->fields['User'])->setValue('1');
@@ -75,7 +71,6 @@ public function specifyCredentials()
7571
*/
7672
public function clearCredentials()
7773
{
78-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])->setValue('');
7974
$this->_rootElement->find($this->fields['Partner'])->setValue('');
8075
$this->_rootElement->find($this->fields['Vendor'])->setValue('');
8176
$this->_rootElement->find($this->fields['User'])->setValue('');

dev/tests/functional/tests/app/Magento/Paypal/Test/Block/System/Config/PaymentsAdvanced.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class PaymentsAdvanced extends Block
2020
* @var array
2121
*/
2222
private $fields = [
23-
'Email Associated with PayPal Merchant Account' => '#payment_us_paypal_group_all_in_one_payflow_advanced_' .
24-
'required_settings_payments_advanced_business_account',
2523
'Partner' => '#payment_us_paypal_group_all_in_one_payflow_advanced_required_settings_payments_advanced_partner',
2624
'Vendor' => '#payment_us_paypal_group_all_in_one_payflow_advanced_required_settings_payments_advanced_vendor',
2725
'User' => '#payment_us_paypal_group_all_in_one_payflow_advanced_required_settings_payments_advanced_user',
@@ -54,8 +52,6 @@ class PaymentsAdvanced extends Block
5452
*/
5553
public function specifyCredentials()
5654
{
57-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])
58-
->setValue('test@test.com');
5955
$this->_rootElement->find($this->fields['Partner'])->setValue('1');
6056
$this->_rootElement->find($this->fields['Vendor'])->setValue('1');
6157
$this->_rootElement->find($this->fields['User'])->setValue('1');
@@ -69,7 +65,6 @@ public function specifyCredentials()
6965
*/
7066
public function clearCredentials()
7167
{
72-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])->setValue('');
7368
$this->_rootElement->find($this->fields['Partner'])->setValue('');
7469
$this->_rootElement->find($this->fields['Vendor'])->setValue('');
7570
$this->_rootElement->find($this->fields['User'])->setValue('');

dev/tests/functional/tests/app/Magento/Paypal/Test/Block/System/Config/PaymentsPro.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class PaymentsPro extends Block
2020
* @var array
2121
*/
2222
private $fields = [
23-
'Email Associated with PayPal Merchant Account' => '#payment_us_paypal_group_all_in_one_wpp_usuk_paypal_' .
24-
'payflow_required_paypal_payflow_api_settings_business_account',
2523
'Partner' => '#payment_us_paypal_group_all_in_one_wpp_usuk_paypal_payflow_required_paypal_payflow_api_' .
2624
'settings_partner',
2725
'Vendor' => '#payment_us_paypal_group_all_in_one_wpp_usuk_paypal_payflow_required_paypal_payflow_api_' .
@@ -60,8 +58,6 @@ class PaymentsPro extends Block
6058
*/
6159
public function specifyCredentials()
6260
{
63-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])
64-
->setValue('test@test.com');
6561
$this->_rootElement->find($this->fields['Partner'])->setValue('1');
6662
$this->_rootElement->find($this->fields['Vendor'])->setValue('1');
6763
$this->_rootElement->find($this->fields['User'])->setValue('1');
@@ -75,7 +71,6 @@ public function specifyCredentials()
7571
*/
7672
public function clearCredentials()
7773
{
78-
$this->_rootElement->find($this->fields['Email Associated with PayPal Merchant Account'])->setValue('');
7974
$this->_rootElement->find($this->fields['Partner'])->setValue('');
8075
$this->_rootElement->find($this->fields['Vendor'])->setValue('');
8176
$this->_rootElement->find($this->fields['User'])->setValue('');

dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@
593593
<label>Express Checkout</label>
594594
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
595595
<field id="business_account" translate="label comment tooltip" showInDefault="1" showInWebsite="1" sortOrder="5">
596-
<label>Email Associated with PayPal Merchant Account</label>
596+
<label>Email Associated with PayPal Merchant Account (Optional)</label>
597+
<frontend_class>not-required</frontend_class>
597598
<comment>
598599
<![CDATA[<a href="http://www.magentocommerce.com/paypal">Start accepting payments via PayPal!</a>]]>
599600
</comment>

0 commit comments

Comments
 (0)