Skip to content

Commit a9bd076

Browse files
author
Oleksii Korshenko
authored
MAGETWO-83742: [Backport 2.1-develop] #10767 Race condition causing duplicate orders with double-clicks on Braintree "Pay" button #11901
2 parents 6637cde + 7918be2 commit a9bd076

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define([
6161
},
6262

6363
/**
64-
* @returns {Bool}
64+
* @returns {Boolean}
6565
*/
6666
isVaultEnabled: function () {
6767
return this.vaultEnabler.isVaultEnabled();
@@ -144,10 +144,19 @@ define([
144144
},
145145

146146
/**
147-
* Trigger order placing
147+
* Returns state of place order button
148+
* @returns {Boolean}
149+
*/
150+
isButtonActive: function () {
151+
return this.isActive() && this.isPlaceOrderActionAllowed();
152+
},
153+
154+
/**
155+
* Triggers order placing
148156
*/
149157
placeOrderClick: function () {
150158
if (this.validateCardType()) {
159+
this.isPlaceOrderActionAllowed(false);
151160
$(this.getSelector('submit')).trigger('click');
152161
}
153162
},

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@
139139
<button class="action primary checkout"
140140
type="submit"
141141
data-bind="
142-
click: placeOrderClick,
143-
attr: {title: $t('Place Order')},
144-
css: {disabled: !isPlaceOrderActionAllowed()},
145-
enable: isActive()
142+
click: placeOrderClick,
143+
attr: {title: $t('Place Order')},
144+
enable: isButtonActive()
146145
"
147146
disabled>
148147
<span data-bind="i18n: 'Place Order'"></span>

0 commit comments

Comments
 (0)