Skip to content

Commit 0886ccd

Browse files
committed
Merge remote-tracking branch 'origin/2.2.10-develop' into 2.2.10-develop-pr111
2 parents 8579556 + 85bf1e8 commit 0886ccd

File tree

4 files changed

+113
-8
lines changed

4 files changed

+113
-8
lines changed

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- ko template: getTemplate() --><!-- /ko -->
2424
<!--/ko-->
2525
</div>
26-
<form id="co-transparent-form-braintree" class="form" data-bind="" method="post" action="#" novalidate="novalidate">
26+
<form id="co-transparent-form-braintree" class="form" data-bind="afterRender: initHostedFields" method="post" action="#" novalidate="novalidate">
2727
<fieldset data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + getCode()}">
2828
<legend class="legend">
2929
<span><!-- ko i18n: 'Credit Card Information'--><!-- /ko --></span>
@@ -87,7 +87,7 @@
8787
<span><!-- ko i18n: 'Card Verification Number'--><!-- /ko --></span>
8888
</label>
8989
<div class="control _with-tooltip">
90-
<div data-bind="afterRender: initHostedFields, attr: {id: getCode() + '_cc_cid'}" class="hosted-control hosted-cid"></div>
90+
<div data-bind="attr: {id: getCode() + '_cc_cid'}" class="hosted-control hosted-cid"></div>
9191
<div class="hosted-error"><!-- ko i18n: 'Please, enter valid Card Verification Number'--><!-- /ko --></div>
9292

9393
<div class="field-tooltip toggle">

app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ define([
1212
'use strict';
1313

1414
return function (paymentMethod) {
15-
paymentMethod.__disableTmpl = {
16-
title: true
17-
};
18-
15+
if (paymentMethod) {
16+
paymentMethod.__disableTmpl = {
17+
title: true
18+
};
19+
}
1920
quote.paymentMethod(paymentMethod);
2021
};
2122
});

app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,33 @@ define([
1313
'Magento_Checkout/js/model/error-processor',
1414
'Magento_Customer/js/model/customer',
1515
'Magento_Checkout/js/action/get-totals',
16-
'Magento_Checkout/js/model/full-screen-loader'
17-
], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader) {
16+
'Magento_Checkout/js/model/full-screen-loader',
17+
'underscore'
18+
], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader, _) {
1819
'use strict';
1920

21+
/**
22+
* Filter template data.
23+
*
24+
* @param {Object|Array} data
25+
*/
26+
var filterTemplateData = function (data) {
27+
return _.each(data, function (value, key, list) {
28+
if (_.isArray(value) || _.isObject(value)) {
29+
list[key] = filterTemplateData(value);
30+
}
31+
32+
if (key === '__disableTmpl') {
33+
delete list[key];
34+
}
35+
});
36+
};
37+
2038
return function (messageContainer, paymentData, skipBilling) {
2139
var serviceUrl,
2240
payload;
2341

42+
paymentData = filterTemplateData(paymentData);
2443
skipBilling = skipBilling || false;
2544
payload = {
2645
cartId: quote.getQuoteId(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'squire',
8+
'jquery'
9+
], function (Squire, $) {
10+
'use strict';
11+
12+
var injector = new Squire(),
13+
setPaymentInformation,
14+
serviceUrl = 'http://url',
15+
mocks = {
16+
'Magento_Checkout/js/model/quote': {
17+
getQuoteId: jasmine.createSpy().and.returnValue(1),
18+
billingAddress: jasmine.createSpy().and.returnValue(null)
19+
},
20+
'Magento_Checkout/js/model/url-builder': {
21+
createUrl: jasmine.createSpy().and.returnValue(serviceUrl)
22+
},
23+
'mage/storage': {
24+
post: function () {} // jscs:ignore jsDoc
25+
},
26+
'Magento_Customer/js/model/customer': {
27+
isLoggedIn: jasmine.createSpy().and.returnValue(false)
28+
},
29+
'Magento_Checkout/js/model/full-screen-loader': {
30+
startLoader: jasmine.createSpy(),
31+
stopLoader: jasmine.createSpy()
32+
},
33+
'Magento_Checkout/js/action/get-totals': jasmine.createSpy('getTotalsAction'),
34+
'Magento_Checkout/js/model/error-processor': jasmine.createSpy('errorProcessor')
35+
};
36+
37+
beforeEach(function (done) {
38+
injector.mock(mocks);
39+
injector.require(
40+
['Magento_Checkout/js/action/set-payment-information-extended'],
41+
function (action) {
42+
setPaymentInformation = action;
43+
done();
44+
});
45+
});
46+
47+
afterEach(function () {
48+
try {
49+
injector.clean();
50+
injector.remove();
51+
} catch (e) {
52+
}
53+
});
54+
55+
describe('Magento/Checkout/js/action/set-payment-information-extended', function () {
56+
it('Checks that paymentData consist correct data value.', function () {
57+
var messageContainer = jasmine.createSpy('messageContainer'),
58+
deferral = new $.Deferred(),
59+
paymentData = {
60+
method: 'checkmo',
61+
additionalData: null,
62+
__disableTmpl: {
63+
title: true
64+
}
65+
},
66+
payload = {
67+
cartId: 1,
68+
paymentMethod: {
69+
method: 'checkmo',
70+
additionalData: null
71+
},
72+
billingAddress: null
73+
};
74+
75+
spyOn(mocks['mage/storage'], 'post').and.callFake(function () {
76+
return deferral.resolve({});
77+
});
78+
79+
setPaymentInformation(messageContainer, paymentData, false);
80+
expect(mocks['Magento_Checkout/js/model/full-screen-loader'].startLoader).toHaveBeenCalled();
81+
expect(mocks['mage/storage'].post).toHaveBeenCalledWith(serviceUrl, JSON.stringify(payload));
82+
expect(mocks['Magento_Checkout/js/model/full-screen-loader'].stopLoader).toHaveBeenCalled();
83+
});
84+
});
85+
});

0 commit comments

Comments
 (0)