Skip to content

Commit da08b65

Browse files
committed
MC-17462: Empty Order creation with Braintree and multiple address checkout
1 parent 5177344 commit da08b65

File tree

5 files changed

+87
-59
lines changed

5 files changed

+87
-59
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/multishipping/cc-form.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define([
1212
'Magento_Ui/js/model/messageList',
1313
'mage/translate',
1414
'Magento_Checkout/js/model/full-screen-loader',
15-
'Magento_Checkout/js/action/set-payment-information',
15+
'Magento_Checkout/js/action/set-payment-information-extended',
1616
'Magento_Checkout/js/model/payment/additional-validators',
1717
'Magento_Braintree/js/view/payment/validator-handler'
1818
], function (
@@ -22,7 +22,7 @@ define([
2222
messageList,
2323
$t,
2424
fullScreenLoader,
25-
setPaymentInformationAction,
25+
setPaymentInformationExtended,
2626
additionalValidators,
2727
validatorManager
2828
) {
@@ -51,9 +51,10 @@ define([
5151
if (additionalValidators.validate()) {
5252
fullScreenLoader.startLoader();
5353
$.when(
54-
setPaymentInformationAction(
54+
setPaymentInformationExtended(
5555
this.messageContainer,
56-
this.getData()
56+
this.getData(),
57+
true
5758
)
5859
).done(this.done.bind(this))
5960
.fail(this.fail.bind(this));

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ define([
88
'jquery',
99
'underscore',
1010
'Magento_Braintree/js/view/payment/method-renderer/paypal',
11-
'Magento_Checkout/js/action/set-payment-information',
11+
'Magento_Checkout/js/action/set-payment-information-extended',
1212
'Magento_Checkout/js/model/payment/additional-validators',
1313
'Magento_Checkout/js/model/full-screen-loader'
1414
], function (
1515
$,
1616
_,
1717
Component,
18-
setPaymentInformationAction,
18+
setPaymentInformationExtended,
1919
additionalValidators,
2020
fullScreenLoader
2121
) {
@@ -131,9 +131,10 @@ define([
131131
placeOrder: function () {
132132
fullScreenLoader.startLoader();
133133
$.when(
134-
setPaymentInformationAction(
134+
setPaymentInformationExtended(
135135
this.messageContainer,
136-
this.getData()
136+
this.getData(),
137+
true
137138
)
138139
).done(this.done.bind(this))
139140
.fail(this.fail.bind(this));
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* @api
8+
*/
9+
define([
10+
'Magento_Checkout/js/model/quote',
11+
'Magento_Checkout/js/model/url-builder',
12+
'mage/storage',
13+
'Magento_Checkout/js/model/error-processor',
14+
'Magento_Customer/js/model/customer',
15+
'Magento_Checkout/js/action/get-totals',
16+
'Magento_Checkout/js/model/full-screen-loader'
17+
], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader) {
18+
'use strict';
19+
20+
return function (messageContainer, paymentData, skipBilling) {
21+
var serviceUrl,
22+
payload;
23+
24+
skipBilling = skipBilling || false;
25+
payload = {
26+
cartId: quote.getQuoteId(),
27+
paymentMethod: paymentData
28+
};
29+
30+
/**
31+
* Checkout for guest and registered customer.
32+
*/
33+
if (!customer.isLoggedIn()) {
34+
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', {
35+
cartId: quote.getQuoteId()
36+
});
37+
payload.email = quote.guestEmail;
38+
} else {
39+
serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {});
40+
}
41+
42+
if (skipBilling === false) {
43+
payload.billingAddress = quote.billingAddress();
44+
}
45+
46+
fullScreenLoader.startLoader();
47+
48+
return storage.post(
49+
serviceUrl, JSON.stringify(payload)
50+
).fail(
51+
function (response) {
52+
errorProcessor.process(response, messageContainer);
53+
}
54+
).always(
55+
function () {
56+
fullScreenLoader.stopLoader();
57+
}
58+
);
59+
};
60+
});

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

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,13 @@
77
* @api
88
*/
99
define([
10-
'Magento_Checkout/js/model/quote',
11-
'Magento_Checkout/js/model/url-builder',
12-
'mage/storage',
13-
'Magento_Checkout/js/model/error-processor',
14-
'Magento_Customer/js/model/customer',
15-
'Magento_Checkout/js/action/get-totals',
16-
'Magento_Checkout/js/model/full-screen-loader'
17-
], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader) {
10+
'Magento_Checkout/js/action/set-payment-information-extended'
11+
12+
], function (setPaymentInformationExtended) {
1813
'use strict';
1914

2015
return function (messageContainer, paymentData) {
21-
var serviceUrl,
22-
payload;
23-
24-
/**
25-
* Checkout for guest and registered customer.
26-
*/
27-
if (!customer.isLoggedIn()) {
28-
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', {
29-
cartId: quote.getQuoteId()
30-
});
31-
payload = {
32-
cartId: quote.getQuoteId(),
33-
email: quote.guestEmail,
34-
paymentMethod: paymentData,
35-
billingAddress: quote.billingAddress()
36-
};
37-
} else {
38-
serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {});
39-
payload = {
40-
cartId: quote.getQuoteId(),
41-
paymentMethod: paymentData,
42-
billingAddress: quote.billingAddress()
43-
};
44-
}
45-
46-
fullScreenLoader.startLoader();
4716

48-
return storage.post(
49-
serviceUrl, JSON.stringify(payload)
50-
).fail(
51-
function (response) {
52-
errorProcessor.process(response, messageContainer);
53-
}
54-
).always(
55-
function () {
56-
fullScreenLoader.stopLoader();
57-
}
58-
);
17+
return setPaymentInformationExtended(messageContainer, paymentData, false);
5918
};
6019
});

app/code/Magento/Payment/view/frontend/web/js/view/payment/iframe.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,7 @@ define([
125125
this.isPlaceOrderActionAllowed(false);
126126

127127
$.when(
128-
setPaymentInformationAction(
129-
this.messageContainer,
130-
{
131-
method: this.getCode()
132-
}
133-
)
128+
this.setPaymentInformation()
134129
).done(
135130
this.done.bind(this)
136131
).fail(
@@ -145,6 +140,18 @@ define([
145140
}
146141
},
147142

143+
/**
144+
* {Function}
145+
*/
146+
setPaymentInformation: function () {
147+
setPaymentInformationAction(
148+
this.messageContainer,
149+
{
150+
method: this.getCode()
151+
}
152+
);
153+
},
154+
148155
/**
149156
* {Function}
150157
*/

0 commit comments

Comments
 (0)