Skip to content

Commit 0fce2fe

Browse files
author
Stanislav Idolov
committed
MAGETWO-39641: Place Order. Prevent Double Click
1 parent eaa0f70 commit 0fce2fe

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/place-order.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ define(
99
'mage/storage',
1010
'mage/url',
1111
'Magento_Checkout/js/model/error-processor',
12-
'Magento_Customer/js/model/customer',
13-
'underscore'
12+
'Magento_Customer/js/model/customer'
1413
],
15-
function (quote, urlBuilder, storage, url, errorProcessor, customer, _) {
14+
function (quote, urlBuilder, storage, url, errorProcessor, customer) {
1615
'use strict';
1716

1817
return function (paymentData, redirectOnSuccess) {
19-
var serviceUrl, payload;
18+
var serviceUrl,
19+
payload;
2020

2121
redirectOnSuccess = redirectOnSuccess === false ? false : true;
22-
/**
23-
* Checkout for guest and registered customer.
24-
*/
22+
23+
/** Checkout for guest and registered customer. */
2524
if (!customer.isLoggedIn()) {
2625
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payment-information', {
2726
quoteId: quote.getQuoteId()
@@ -40,7 +39,7 @@ define(
4039
billingAddress: quote.billingAddress()
4140
};
4241
}
43-
storage.post(
42+
return storage.post(
4443
serviceUrl, JSON.stringify(payload)
4544
).done(
4645
function () {

app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,21 @@ define(
4646
* Place order.
4747
*/
4848
placeOrder: function () {
49-
var emailValidationResult = customer.isLoggedIn(),
49+
var self = this,
50+
placeOrder,
51+
emailValidationResult = customer.isLoggedIn(),
5052
loginFormSelector = 'form[data-role=email-with-possible-login]';
5153
if (!customer.isLoggedIn()) {
5254
$(loginFormSelector).validation();
5355
emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
5456
}
5557
if (emailValidationResult && this.validate()) {
56-
placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
58+
this.isPlaceOrderActionAllowed(false);
59+
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
60+
61+
$.when(placeOrder).fail(function(){
62+
self.isPlaceOrderActionAllowed(true);
63+
});
5764
}
5865
},
5966

app/code/Magento/Payment/Model/IframeConfigProvider.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class IframeConfigProvider implements ConfigProviderInterface
2626
*/
2727
const DEFAULT_YEAR_LENGTH = 2;
2828

29+
/**
30+
* Checkout identifier for transparent iframe payments
31+
*/
32+
const CHECKOUT_IDENTIFIER = 'checkout_flow';
33+
2934
/**
3035
* @var Repository
3136
*/
@@ -93,7 +98,7 @@ public function getConfig()
9398
'dateDelim' => [$this->methodCode => $this->getDateDelim()],
9499
'cardFieldsMap' => [$this->methodCode => $this->getCardFieldsMap()],
95100
'source' => [$this->methodCode => $this->getViewFileUrl('blank.html')],
96-
'controllerName' => [$this->methodCode => $this->getController()],
101+
'controllerName' => [$this->methodCode => self::CHECKOUT_IDENTIFIER],
97102
'cgiUrl' => [$this->methodCode => $this->getCgiUrl()],
98103
'placeOrderUrl' => [$this->methodCode => $this->getPlaceOrderUrl()],
99104
'saveOrderUrl' => [$this->methodCode => $this->getSaveOrderUrl()],
@@ -167,16 +172,6 @@ protected function getViewFileUrl($fileId, array $params = [])
167172
}
168173
}
169174

170-
/**
171-
* Retrieve the controller name
172-
*
173-
* @return string
174-
*/
175-
protected function getController()
176-
{
177-
return $this->request->getControllerName();
178-
}
179-
180175
/**
181176
* Retrieve place order url on front
182177
*

0 commit comments

Comments
 (0)